Project 1 Group 7

481 days ago by edinan

# Group 7: Emily Dinan, Meg Donohue, Ashley Vega # Problem 1A # r(n) will be the interest rate for each month n def r(n): if n==1: return (0.10) else: return (0.10 + .01*(n-1)) # d(n) will be the deposit made at the end of each month n def d(n): return RDF(100) # P(n) will refer to the total balance at the end of each month n def P(n): if n==0: return RDF(2000) else: return RDF((1+(r(n)/12))*(P(n-1))+ d(n)) print " n P"; for n in range(0,36): print "%2s "%(n),; print "%16s "%(P(n)) # It is clear that the balance surpasses $10,000 when n=35. Q = [[n, P(n)] for n in range(36)] pplot= scatter_plot(Q); pplot.show() 
       
 n     P
 0            2000.0 
 1     2116.66666667 
 2     2236.06944444 
 3     2358.43013889 
 4     2483.97979873 
 5     2612.95956305 
 6     2745.62155758 
 7     2882.22984502 
 8     3023.06143449 
 9     3168.40735601 
10     3318.57380581 
11     3473.88336924 
12      3634.6763282 
13     3801.31206089 
14     3974.17054205 
15     4153.65395289 
16     4340.18841025 
17      4534.2258258 
18     4736.24590688 
19     4946.75831137 
20     5166.30497057 
21     5395.46259483 
22     5634.84537853 
23     5885.10792196 
24     6146.94838981 
25     6421.11192752 
26     6708.39435874 
27      7009.6461895 
28     7325.77694701 
29     7657.75988367 
30     8006.63707989 
31     8373.52498255 
32     8759.62041946 
33     9166.20713414 
34     9594.66288978 
35     10046.4671957 
 n     P
 0            2000.0 
 1     2116.66666667 
 2     2236.06944444 
 3     2358.43013889 
 4     2483.97979873 
 5     2612.95956305 
 6     2745.62155758 
 7     2882.22984502 
 8     3023.06143449 
 9     3168.40735601 
10     3318.57380581 
11     3473.88336924 
12      3634.6763282 
13     3801.31206089 
14     3974.17054205 
15     4153.65395289 
16     4340.18841025 
17      4534.2258258 
18     4736.24590688 
19     4946.75831137 
20     5166.30497057 
21     5395.46259483 
22     5634.84537853 
23     5885.10792196 
24     6146.94838981 
25     6421.11192752 
26     6708.39435874 
27      7009.6461895 
28     7325.77694701 
29     7657.75988367 
30     8006.63707989 
31     8373.52498255 
32     8759.62041946 
33     9166.20713414 
34     9594.66288978 
35     10046.4671957 
# Problem 1B def r(n): if n==1: return (0.10) else: return (0.10 + .01*(n-1)) def d(n): if n==1: return (100) else: return RDF(100*((n-1)/2)) def P(n): if n==0: return RDF(2000) else: return RDF(((1+(r(n)/12))*(P(n-1)))+ d(n)) print " n P"; for n in range(0,18): print "%2s "%(n),; print "%16s "%(P(n)) # It is clear that the balance surpasses $10,000 when n=17. Q = [[n, P(n)] for n in range(18)] pplot= scatter_plot(Q); pplot.show() 
       
 n     P
 0            2000.0 
 1     2116.66666667 
 2     2186.06944444 
 3     2307.93013889 
 4     2482.93271539 
 5     2711.90026374 
 6     2995.79901704 
 7     3335.74300393 
 8     3732.99936315 
 9      4188.9943536 
10     4705.32009753 
11     5283.74209916 
12     5926.20758589 
13     6634.85472497 
14     7412.02277386 
15     8260.26322934 
16     9182.35204662 
17     10181.3030076 
 n     P
 0            2000.0 
 1     2116.66666667 
 2     2186.06944444 
 3     2307.93013889 
 4     2482.93271539 
 5     2711.90026374 
 6     2995.79901704 
 7     3335.74300393 
 8     3732.99936315 
 9      4188.9943536 
10     4705.32009753 
11     5283.74209916 
12     5926.20758589 
13     6634.85472497 
14     7412.02277386 
15     8260.26322934 
16     9182.35204662 
17     10181.3030076 
# Problem 1C def r(n): if n==1: return (0.10) else: return (0.10 + .01*(n-1)) def d(n): if n==1: return (100) else: return RDF(d(n-1)+(100*((n-1)/2))) def P(n): if n==0: return RDF(2000) else: return RDF((1+(r(n)/12))*(P(n-1))+ d(n)) print " n P"; for n in range(0,11): print "%2s "%(n),; print "%16s "%(P(n)) # It is clear that the balance surpasses $10,000 when n=10. Q = [[n, P(n)] for n in range(11)] pplot= scatter_plot(Q); pplot.show() 
       
 n     P
 0            2000.0 
 1     2116.66666667 
 2     2286.06944444 
 3     2558.93013889 
 4     2986.65188206 
 5     3621.49615402 
 6     4516.76485594 
 7     5726.98838736 
 8     7308.12072284 
 9     9317.74253369 
10     11815.2734571 
 n     P
 0            2000.0 
 1     2116.66666667 
 2     2286.06944444 
 3     2558.93013889 
 4     2986.65188206 
 5     3621.49615402 
 6     4516.76485594 
 7     5726.98838736 
 8     7308.12072284 
 9     9317.74253369 
10     11815.2734571 
# Problem 2 pp = vector(RDF, 11); pp[0]= 25.7; pp[1]= 18.5; pp[2]= 14.3; pp[3]= 12.2; pp[4]= 11.1; pp[5]= 9.5; pp[6]= 9.1; pp[7]= 8.5; pp[8]= 8.1; pp[9]= 7.5; pp[10]= 7.4; Q = [[pp[i], pp[i+1]] for i in range(10)] Q; pplot= scatter_plot(Q); pplot.show() testline= plot((3/5)*x + 3, (x,0,27),rgbcolor=hue(0.4)) show(pplot+testline) # We found r=(3/5) and k=3 to give the best estimation.