VBA Programming homework:
1. A cosine can be approximated by the following infinite series:
cosx=1-(x2/2!)+(x4/4!)-(x6/6!)+...
Write a function that will calculate this for any x and y number of terms. If y > 85 or y is not a positive integer, return an error.
X
|
Y
|
Cos( x)
|
MyCosine (x,y)
|
Approximation error
|
0.31831
|
9
|
|
|
|
0.95493
|
9.5
|
|
|
|
1.27324
|
37
|
|
|
|
1.591549
|
65
|
|
|
|
2.228169
|
88
|
|
|
|
2. A hybrid linked note is an instrument that provides investors fixed income and equity market. It is structured by combining a return that is 75% equity and 25% fixed income. The investment pays the greater of the par value, $1,000, or the price times the 75% percentage increase in the S&P 500 plus 25% the return on the Barclays US Aggregate Index.
Write 2 functions (hlnPayoff, hlnReturn). The first, hlnPayoff, calculates the security payoff at maturity. The second, hlnReturn, calculates the annualized return assuming continuous compounding. The function hlnReturn should call the payoff function.
Price
|
Years
|
SP5000
|
SP5001
|
Barclay US Agg0
|
Barclay US Agg1
|
Payoff
|
Return
|
953
|
1
|
1783
|
1995
|
1810
|
1887
|
|
|
914
|
2
|
1298
|
1498
|
1909
|
1942
|
|
|
811
|
5
|
1288
|
1568
|
1710
|
1887
|
|
|
733
|
8
|
1335
|
1270
|
1612
|
1923
|
|
|