Chapter 3 Sequences and financeMathematica Commands

1. Arithmetic sequences from first principles

f[x_]:=x+"Common Difference"
NestList[f, "First term",( "How many more terms")]

Example
These are generated by using a function f of the form f(x) = x+ d where d represents the common difference of the sequence, and a is the first term:
Note that the nth term has n - 1 additions of the common difference d. Consider the specific case where a = 3 and d = 5

f[x_]:=x+5

NestList[f, 3, (10)]

2. Graphs of Arithmetic Sequences

f[x_]:=x+"Common Difference"
ListLinePlot[NestList[f, "First term", ("How many more terms")]]

Example

f[x_]:=x+5
ListLinePlot[NestList[f, 3, (10)]]

3. Write Explicit Rule of Arithmetic sequences from Recurrence Relation

RSolve[{t[n+1]==t[n]"+ or -""Common Difference",t[0]=="Value of First Term"},t[n],n]

Example

RSolve[{t[n+1]==t[n]+3,t[0]==13},t[n],n]

4. Find the nth term for an Arithmetic sequences

nthvalue[V0_,n_,D_]:=V0+n*D
NSolve[nthvalue["V0","n","D"]=="Vn",Reals]

nthvalue[V0_,n_,D_]:=V0+n*D
NSolve[nthvalue[21,30,-3]=="Vn",Reals]

5. Geometric sequences from first principles

f[x_]:="Common Ratio" x
NestList[f, "First term",( "How many more terms")]

Example
These are generated by using a function f of the form f(x) = r x where r represents the common ratio between consecutive terms of the sequence, and a is the first term:
Note that the nth term has n - 1 powers of the common ratio r.

f[x_]:=2x

NestList[f, 3, (10)]

6. Graphs of Geometric Sequences

f[x_]:="Common Ratio" x
ListPlot[NestList[f, "First term",( "How many more terms")]]

Example

f[x_]:=2 x
ListLinePlot[NestList[f, 3, (10)]]

7. Write Explicit Rule of Geometric Sequences from Recurrence Relation

RSolve[{t[n+1]=="Common Ratio"t[n],t[0]=="Value of First Term"},t[n],n]

Example

RSolve[{t[n+1]==2t[n],t[0]==3},t[n],n]

8. Find the nth term for an Geometric sequences

nthvalue[V0_,n_,R_]:=V0*R^n
NSolve[nthvalue["V0","n","R"]=="Vn",Reals]//DecimalForm

nthvalue[V0_,n_,R_]:=V0*R^n
NSolve[nthvalue[1,7,2]=="Vn",Reals]//DecimalForm

9. Find the common difference (D) in an arithmetic sequence

Solve["common difference (D)"=="any term"-"the previous term"]

Example
Find the common difference (d) for the arithmetic sequence 3.5,  4.25,  5,  5.75,  6.5

Solve["common difference (D)"==4.25-3.5]

10. Finding the common difference (D) given the percentage rate or D

difference[D_,r_,V0_]:=(r/100)*V0//N
NSolve[difference["Common Difference","Rate","V0"]=="Common Difference",Reals]

difference[D_,r_,V0_]:=(r/100)*V0//N
NSolve[difference[300,"Rate",2400]==300,Reals]

11. Find the common ratio (R) in a geometric sequence

Solve["common ratio (R)"==(("any term")/("the previous term"))]

Example: Find the common ratio (r) of the following geometric sequence 3, 12, 48, 192

Solve["common ratio (R)"==(192/48)]

12. Finding the common ratio (R) given the percentage reduction

ratio[R_,r_]:=(1-(r/100))//N
NSolve[ratio["common ratio (R)","Rate"]=="common ratio (R)",Reals]

ratio[R_,r_]:=(1-(r/100))//N
NSolve[ratio[x,4]==x,Reals]

13. Finding the common ratio (R) given the percentage increase

ratio[R_,r_]:=(1+(r/100))//N
NSolve[ratio["common ratio (R)","Rate"]=="common ratio (R)",Reals]

ratio[R_,r_]:=(1+(r/100))//N
NSolve[ratio["common ratio (R)",4]=="common ratio (R)",Reals]

14. Generating a sequence of terms combined sequences.

f[x_]:="Common Ratio" x+"Common Difference"
NestList[f, "First term",( "How many more terms")]

Example Use a calculator to generate the first five terms of the sequence with a starting value of 5 and the rule 'double and then subtract 3'.

f[x_]:=2 x+-3
NestList[f, 5,( 4)]

15. Finance Solver for Future Value

futurevalue[prin_,r_,n_,t_]:=prin(((1+((((r/n)))/100)))^((n*t)))
NSolve[futurevalue["Principal","Rate per annum","Number of payment per year","Time in YEARS"]==Future Value,Reals]//FullForm

futurevalue[prin_,r_,n_,t_]:=prin(((1+((((r/n)))/100)))^((n*t)))
NSolve[futurevalue[2000,18.9,365,52/365]==Future Value,Reals]//FullForm

16. Simple Interest

a. Finding interest in dollars ( Common difference) for  Simple Interest

difference[V0_,r_,p_,D_]:=(r/(100p))*V0//N
NSolve[difference["Principal","Rate per annum","Number of payment per year","Interest in dollars (Common Difference)"]=="Interest in dollars (Common Difference)",Reals]

b. Generate a table and graph of Simple Interest--Recurrence Relation (Subscript[V, 0])="Principal", (Subscript[V, n+1])= (Subscript[V, n])+ "Interest in dollars (Common Difference)". 
Explicit Rule: (Subscript[V, n])= "Principal"+ n *"Interest in dollars (Common Difference)"

f[x_]:=x+"Interest in dollars (Common Difference)"
NestList[f, "Principal",( "Number of payment per year"*"Time in YEARS")]
ListLinePlot[NestList[f, "Principal", ("Number of payment per year"*"Time in YEARS")]]

c. Explicit Rule Calculation for Simple Interest

nthvalue[V0_,r_,p_,n_]:=V0+n*p*(r/(100p))*V0
NSolve[nthvalue["Principal","Rate per annum","Number of payment per year","Time in YEARS"]==Future Value,Reals]

17. Compound Interest

a. Finding Common Ratio for  Compound Interest

ratio[R_,r_,p_]:=(1+(r/(100p)))//N
NSolve[ratio["common ratio (R)","Rate per annum","Number of payment per year"]=="common ratio (R)",Reals]

b. Generate a table and graph of Compound Interest--Recurrence Relation: (Subscript[V, 0])="Principal", (Subscript[V, n+1])="Common Ratio" *(Subscript[V, n]). 
Explicit Rule: (Subscript[V, n])= "Principal"* (("Common Ratio")^n)

f[x_]:="Common Ratio" x
NestList[f, "Principal",( "Number of payment per year"*"Time in YEARS")]
ListLinePlot[NestList[f, "Principal",( "Number of payment per year"*"Time in YEARS")]]

c. Explicit Rule Calculation for Compound Interest

nthvalue[V0_,r_,p_,n_]:=V0*(1+(r/(100p)))^(n*p)
NSolve[nthvalue["Principal","Rate per annum","Number of payment per year","Time in YEARS"]==Future Value,Reals]//FullForm

18. Flat Rate Depreciation

a. Finding depreciation value in dollars ( Common difference) for  Flat Rate Depreciation

difference[V0_,r_,p_,D_]:=(r/(100p))*V0//N
NSolve[difference["Initial Value","Rate per annum","Number of payment per year","Depreciation value (Common Difference)"]=="Depreciation value (Common Difference)",Reals]

b. Generate a table and graph of Flat Rate Depreciation--Recurrence Relation: (Subscript[V, 0])="Initial Value", (Subscript[V, n+1])=(Subscript[V, n]) - "Depreciation value (Common Difference)". 
Explicit Rule: (Subscript[V, n])= "Initial Value" - n x "Depreciation value (Common Difference)"

f[x_]:=x-"Depreciation value (Common Difference)"
NestList[f, "Initial Value",( "Number of payment per year"*"Time in YEARS")]
ListLinePlot[NestList[f, "Initial Value", ("Number of payment per year"*"Time in YEARS")]]

c. Explicit Rule Calculation for Flat Rate Depreciation

nthvalue[V0_,p_,n_,D_]:=V0-n*p*D
NSolve[nthvalue["Initial Value","Number of payment per year","Time in YEARS","Depreciation value (Common Difference)"]==Future Value,Reals]

19. Unit Cost Depreciation

a. Generate a table and graph of Unit Cost Depreciation--Recurrence Relation: (Subscript[V, 0])= "Initial Value", (Subscript[V, n+1])=(Subscript[V, n]) - "Depreciation Cost per unit in Dollars". 
Explicit Rule: (Subscript[V, n])= "Initial Value"  - n x "Depreciation Cost per unit in Dollars"

f[x_]:=x-"Depreciation Cost per unit in Dollars"
NestList[f, "Initial Value",( "Total units ( kilometres, pages, per thousand km etc)")]
ListLinePlot[NestList[f, "Initial Value", ("Total units ( kilometres, pages, per thousand km etc)")]]

b. Explicit Rule Calculation for Unit Cost Depreciation

nthvalue[V0_,n_,D_]:=V0-n*D
NSolve[nthvalue["Initial Value","Total units ( kilometres, pages, per thousand km etc)","Depreciation Cost per unit in Dollars"]==Future Value,Reals]

nthvalue[V0_,n_,D_]:=V0-n*D
NSolve[nthvalue[60000,"Total units ( kilometres, pages, per thousand km etc)",0.35]==15000,Reals]

20. Reduced Balance Depreciation

a. Finding Common Ratio for  Reduced Balance Depreciation

ratio[R_,r_,p_]:=(1-(r/(100p)))//N
NSolve[ratio["common ratio (R)","Rate per annum","Number of payment per year"]=="common ratio (R)",Reals]

b. Generate a table and graph of Reduced balance Depreciation--Recurrence Relation: (Subscript[V, 0])="Initial Value", (Subscript[V, n+1])="Common Ratio" *(Subscript[V, n]). 
Explicit Rule: (Subscript[V, n])= "Initial Value"* (("Common Ratio")^n)

f[x_]:="Common Ratio" x
NestList[f, "Initial Value",( "Number of payment per year"*"Time in YEARS")]
ListLinePlot[NestList[f, "Initial Value",( "Number of payment per year"*"Time in YEARS")]]

c. Explicit Rule Calculation for Reduced balance Depreciation

nthvalue[V0_,r_,p_,n_]:=V0*(1-(r/(100p)))^(n*p)
NSolve[nthvalue["Initial Value","Rate per annum","Number of payment per year","Time in YEARS"]==Future Value,Reals]//FullForm