YaK:: compounding [Changes]   [Calendar]   [Search]   [Index]   [PhotoTags]   
[mega_changes]
[photos]

compounding


$ r=5.09453 b=139000 p=3267 python3 loan.py
Initial Balance: 139000.00  Annualized Rate: 5.094530  Quarterly Mult: 1.012500
quarter  1:  payment=   3267.00  bal= 137429.66   (sum_payments=   3267.00  re-invested=   3267.00)
quarter  2:  payment=   3267.00  bal= 135839.69   (sum_payments=   6534.00  re-invested=   6574.84)
quarter  3:  payment=   3267.00  bal= 134229.85   (sum_payments=   9801.00  re-invested=   9924.02)
quarter  4:  payment=   3267.00  bal= 132599.89   (sum_payments=  13068.00  re-invested=  13315.07)
quarter  5:  payment=   3267.00  bal= 130949.55   (sum_payments=  16335.00  re-invested=  16748.51)
quarter  6:  payment=   3267.00  bal= 129278.58   (sum_payments=  19602.00  re-invested=  20224.87)
quarter  7:  payment=   3267.00  bal= 127586.72   (sum_payments=  22869.00  re-invested=  23744.68)
quarter  8:  payment=   3267.00  bal= 125873.71   (sum_payments=  26136.00  re-invested=  27308.49)
quarter  9:  payment=   3267.00  bal= 124139.30   (sum_payments=  29403.00  re-invested=  30916.84)
quarter 10:  payment=   3267.00  bal= 122383.20   (sum_payments=  32670.00  re-invested=  34570.30)
quarter 11:  payment=   3267.00  bal= 120605.15   (sum_payments=  35937.00  re-invested=  38269.43)
quarter 12:  payment=   3267.00  bal= 118804.88   (sum_payments=  39204.00  re-invested=  42014.80)
quarter 13:  payment=   3267.00  bal= 116982.10   (sum_payments=  42471.00  re-invested=  45806.98)
quarter 14:  payment=   3267.00  bal= 115136.54   (sum_payments=  45738.00  re-invested=  49646.57)
quarter 15:  payment=   3267.00  bal= 113267.91   (sum_payments=  49005.00  re-invested=  53534.15)
quarter 16:  payment=   3267.00  bal= 111375.92   (sum_payments=  52272.00  re-invested=  57470.33)
quarter 17:  payment=   3267.00  bal= 109460.28   (sum_payments=  55539.00  re-invested=  61455.71)
quarter 18:  payment=   3267.00  bal= 107520.69   (sum_payments=  58806.00  re-invested=  65490.90)
quarter 19:  payment=   3267.00  bal= 105556.86   (sum_payments=  62073.00  re-invested=  69576.54)
quarter 20:  payment=   3267.00  bal= 103568.48   (sum_payments=  65340.00  re-invested=  73713.24)
quarter 21:  payment=   3267.00  bal= 101555.25   (sum_payments=  68607.00  re-invested=  77901.66)
quarter 22:  payment=   3267.00  bal=  99516.85   (sum_payments=  71874.00  re-invested=  82142.43)
quarter 23:  payment=   3267.00  bal=  97452.98   (sum_payments=  75141.00  re-invested=  86436.21)
quarter 24:  payment=   3267.00  bal=  95363.30   (sum_payments=  78408.00  re-invested=  90783.66)
quarter 25:  payment=   3267.00  bal=  93247.50   (sum_payments=  81675.00  re-invested=  95185.46)
quarter 26:  payment=   3267.00  bal=  91105.26   (sum_payments=  84942.00  re-invested=  99642.27)
quarter 27:  payment=   3267.00  bal=  88936.24   (sum_payments=  88209.00  re-invested= 104154.80)
quarter 28:  payment=   3267.00  bal=  86740.10   (sum_payments=  91476.00  re-invested= 108723.73)
quarter 29:  payment=   3267.00  bal=  84516.51   (sum_payments=  94743.00  re-invested= 113349.78)
quarter 30:  payment=   3267.00  bal=  82265.13   (sum_payments=  98010.00  re-invested= 118033.65)
quarter 31:  payment=   3267.00  bal=  79985.61   (sum_payments= 101277.00  re-invested= 122776.07)
quarter 32:  payment=   3267.00  bal=  77677.59   (sum_payments= 104544.00  re-invested= 127577.77)
quarter 33:  payment=   3267.00  bal=  75340.72   (sum_payments= 107811.00  re-invested= 132439.49)
quarter 34:  payment=   3267.00  bal=  72974.64   (sum_payments= 111078.00  re-invested= 137361.98)
quarter 35:  payment=   3267.00  bal=  70578.99   (sum_payments= 114345.00  re-invested= 142346.01)
quarter 36:  payment=   3267.00  bal=  68153.39   (sum_payments= 117612.00  re-invested= 147392.33)
quarter 37:  payment=   3267.00  bal=  65697.47   (sum_payments= 120879.00  re-invested= 152501.73)
quarter 38:  payment=   3267.00  bal=  63210.85   (sum_payments= 124146.00  re-invested= 157675.01)
quarter 39:  payment=   3267.00  bal=  60693.14   (sum_payments= 127413.00  re-invested= 162912.94)
quarter 40:  payment=   3267.00  bal=  58143.97   (sum_payments= 130680.00  re-invested= 168216.35)
quarter 41:  payment=   3267.00  bal=  55562.93   (sum_payments= 133947.00  re-invested= 173586.05)
quarter 42:  payment=   3267.00  bal=  52949.63   (sum_payments= 137214.00  re-invested= 179022.88)
quarter 43:  payment=   3267.00  bal=  50303.66   (sum_payments= 140481.00  re-invested= 184527.66)
quarter 44:  payment=   3267.00  bal=  47624.62   (sum_payments= 143748.00  re-invested= 190101.26)
quarter 45:  payment=   3267.00  bal=  44912.09   (sum_payments= 147015.00  re-invested= 195744.52)
quarter 46:  payment=   3267.00  bal=  42165.65   (sum_payments= 150282.00  re-invested= 201458.33)
quarter 47:  payment=   3267.00  bal=  39384.89   (sum_payments= 153549.00  re-invested= 207243.55)
quarter 48:  payment=   3267.00  bal=  36569.36   (sum_payments= 156816.00  re-invested= 213101.10)
quarter 49:  payment=   3267.00  bal=  33718.64   (sum_payments= 160083.00  re-invested= 219031.86)
quarter 50:  payment=   3267.00  bal=  30832.28   (sum_payments= 163350.00  re-invested= 225036.75)
quarter 51:  payment=   3267.00  bal=  27909.85   (sum_payments= 166617.00  re-invested= 231116.71)
quarter 52:  payment=   3267.00  bal=  24950.89   (sum_payments= 169884.00  re-invested= 237272.67)
quarter 53:  payment=   3267.00  bal=  21954.93   (sum_payments= 173151.00  re-invested= 243505.57)
quarter 54:  payment=   3267.00  bal=  18921.53   (sum_payments= 176418.00  re-invested= 249816.39)
quarter 55:  payment=   3267.00  bal=  15850.22   (sum_payments= 179685.00  re-invested= 256206.09)
quarter 56:  payment=   3267.00  bal=  12740.51   (sum_payments= 182952.00  re-invested= 262675.67)
quarter 57:  payment=   3267.00  bal=   9591.92   (sum_payments= 186219.00  re-invested= 269226.11)
quarter 58:  payment=   3267.00  bal=   6403.99   (sum_payments= 189486.00  re-invested= 275858.44)
quarter 59:  payment=   3267.00  bal=   3176.20   (sum_payments= 192753.00  re-invested= 282573.66)
quarter 60:  payment=   3267.00  bal=    -91.94   (sum_payments= 196020.00  re-invested= 289372.83)


$ r=5.09453 b=139000 p=4000 python3 loan.py
Initial Balance: 139000.00  Annualized Rate: 5.094530  Quarterly Mult: 1.012500
quarter  1:  payment=   4000.00  bal= 136687.50   (sum_payments=   4000.00  re-invested=   4000.00)
quarter  2:  payment=   4000.00  bal= 134346.09   (sum_payments=   8000.00  re-invested=   8050.00)
quarter  3:  payment=   4000.00  bal= 131975.42   (sum_payments=  12000.00  re-invested=  12150.62)
quarter  4:  payment=   4000.00  bal= 129575.11   (sum_payments=  16000.00  re-invested=  16302.51)
quarter  5:  payment=   4000.00  bal= 127144.80   (sum_payments=  20000.00  re-invested=  20506.29)
quarter  6:  payment=   4000.00  bal= 124684.10   (sum_payments=  24000.00  re-invested=  24762.62)
quarter  7:  payment=   4000.00  bal= 122192.65   (sum_payments=  28000.00  re-invested=  29072.15)
quarter  8:  payment=   4000.00  bal= 119670.06   (sum_payments=  32000.00  re-invested=  33435.55)
quarter  9:  payment=   4000.00  bal= 117115.94   (sum_payments=  36000.00  re-invested=  37853.50)
quarter 10:  payment=   4000.00  bal= 114529.88   (sum_payments=  40000.00  re-invested=  42326.66)
quarter 11:  payment=   4000.00  bal= 111911.51   (sum_payments=  44000.00  re-invested=  46855.75)
quarter 12:  payment=   4000.00  bal= 109260.40   (sum_payments=  48000.00  re-invested=  51441.44)
quarter 13:  payment=   4000.00  bal= 106576.15   (sum_payments=  52000.00  re-invested=  56084.46)
quarter 14:  payment=   4000.00  bal= 103858.36   (sum_payments=  56000.00  re-invested=  60785.52)
quarter 15:  payment=   4000.00  bal= 101106.58   (sum_payments=  60000.00  re-invested=  65545.33)
quarter 16:  payment=   4000.00  bal=  98320.42   (sum_payments=  64000.00  re-invested=  70364.65)
quarter 17:  payment=   4000.00  bal=  95499.42   (sum_payments=  68000.00  re-invested=  75244.21)
quarter 18:  payment=   4000.00  bal=  92643.16   (sum_payments=  72000.00  re-invested=  80184.76)
quarter 19:  payment=   4000.00  bal=  89751.20   (sum_payments=  76000.00  re-invested=  85187.07)
quarter 20:  payment=   4000.00  bal=  86823.09   (sum_payments=  80000.00  re-invested=  90251.91)
quarter 21:  payment=   4000.00  bal=  83858.38   (sum_payments=  84000.00  re-invested=  95380.05)
quarter 22:  payment=   4000.00  bal=  80856.61   (sum_payments=  88000.00  re-invested= 100572.30)
quarter 23:  payment=   4000.00  bal=  77817.31   (sum_payments=  92000.00  re-invested= 105829.46)
quarter 24:  payment=   4000.00  bal=  74740.03   (sum_payments=  96000.00  re-invested= 111152.32)
quarter 25:  payment=   4000.00  bal=  71624.28   (sum_payments= 100000.00  re-invested= 116541.73)
quarter 26:  payment=   4000.00  bal=  68469.58   (sum_payments= 104000.00  re-invested= 121998.50)
quarter 27:  payment=   4000.00  bal=  65275.45   (sum_payments= 108000.00  re-invested= 127523.48)
quarter 28:  payment=   4000.00  bal=  62041.39   (sum_payments= 112000.00  re-invested= 133117.52)
quarter 29:  payment=   4000.00  bal=  58766.91   (sum_payments= 116000.00  re-invested= 138781.49)
quarter 30:  payment=   4000.00  bal=  55451.50   (sum_payments= 120000.00  re-invested= 144516.26)
quarter 31:  payment=   4000.00  bal=  52094.64   (sum_payments= 124000.00  re-invested= 150322.71)
quarter 32:  payment=   4000.00  bal=  48695.82   (sum_payments= 128000.00  re-invested= 156201.74)
quarter 33:  payment=   4000.00  bal=  45254.52   (sum_payments= 132000.00  re-invested= 162154.26)
quarter 34:  payment=   4000.00  bal=  41770.20   (sum_payments= 136000.00  re-invested= 168181.19)
quarter 35:  payment=   4000.00  bal=  38242.33   (sum_payments= 140000.00  re-invested= 174283.45)
quarter 36:  payment=   4000.00  bal=  34670.36   (sum_payments= 144000.00  re-invested= 180461.99)
quarter 37:  payment=   4000.00  bal=  31053.74   (sum_payments= 148000.00  re-invested= 186717.77)
quarter 38:  payment=   4000.00  bal=  27391.91   (sum_payments= 152000.00  re-invested= 193051.74)
quarter 39:  payment=   4000.00  bal=  23684.31   (sum_payments= 156000.00  re-invested= 199464.88)
quarter 40:  payment=   4000.00  bal=  19930.36   (sum_payments= 160000.00  re-invested= 205958.19)
quarter 41:  payment=   4000.00  bal=  16129.49   (sum_payments= 164000.00  re-invested= 212532.67)
quarter 42:  payment=   4000.00  bal=  12281.11   (sum_payments= 168000.00  re-invested= 219189.32)
quarter 43:  payment=   4000.00  bal=   8384.62   (sum_payments= 172000.00  re-invested= 225929.19)
quarter 44:  payment=   4000.00  bal=   4439.43   (sum_payments= 176000.00  re-invested= 232753.30)
quarter 45:  payment=   4000.00  bal=    444.92   (sum_payments= 180000.00  re-invested= 239662.71)
quarter 46:  payment=   4000.00  bal=  -3599.52   (sum_payments= 184000.00  re-invested= 246658.50)



$ cat loan.py
import os

bal = float(os.getenv('b'))  # Initial balance to be paid.
annualized_rate = float(os.getenv('r'))   # percent per annum
payment = float(os.getenv('p'))
multiplier = (1.0 + annualized_rate/100.0) ** (1.0 / 4.0)

print("Initial Balance: %.2f  Annualized Rate: %.6f  Quarterly Mult: %.6f" % (bal, annualized_rate, multiplier))

sum_payments = 0.0
future = 0.0 # Future value of accumulated payments, at same rate.
for i in range(9999):
  bal = bal - payment
  bal *= multiplier

  sum_payments += payment
  future *= multiplier
  future = future + payment

  print ("quarter %2d:  payment=%10.2f  bal=%10.2f   (sum_payments=%10.2f  re-invested=%10.2f)" % (i+1, payment, bal, sum_payments, future))

  if bal <= 0.0: break


(unless otherwise marked) Copyright 2002-2014 YakPeople. All rights reserved.
(last modified 2022-06-16)       [Login]
(No back references.)