MTH4320: COMPUTATIONAL FINANCE — Spring 2025
Homework 1: due on February 13th
Problem 1: (30pts)
a. Write two Matlab functional scripts that calculate the present value of an ordinary
perpetuity and a growing perpetuity. (4pts)
b. Write two Matlab functional scripts that calculate the future value at a date t in years
in the future of a perpetuity and a growing perpetuity. (4pts)
c. Write two Matlab functional scripts that compute the present value of an ordinary
annuity and a growing ordinary annuity for which the first cash flow starts in k years
from today (k ≥ 1) and last for T years. (8pts)
d. Write two Matlab functional scripts that compute the present value of an annuity due
and a growing annuity due for which the first cash flow starts today and last for T − 1
more years. (4pts)
e. Write two Matlab functional scripts that compute the future value of an ordinary
annuity and a growing ordinary annuity at a date t in years in the future (k < t ≤ T )
for which the first cash flow starts in k year from today (k ≥ 1) and last for T years.
(6pts)
f. Write two Matlab functional scripts that compute the future value of an annuity due
and a growing annuity due at a date t in years in the future (0 < t ≤ T ) for which the
first cash flow starts today and last for T years. (4pts)
1
Problem 2: (20pts)
a. Draw the plot of the cubic function, f (x) = ax3 + bx2 + cx + d on the interval [−4, 4]
for a = 1, b = 1, c = −4, d = 1. Make sure your provide a label for the x-axis and the
y-axis as well as a title that says plot of the cubic function, f (x) = ax3 + bx2 + cx + d,
for a = 1, b = 1, c = −4, d = 1. Add a grid to your plot. (5pts)
b. Draw the plot of the cubic function, f (x) = x3 + cx on the interval [−3, 3] for c =
−5.0, −3.0, −1.0, 0.0, 1.0, 3.0, 5.0. Make sure you provide a label for the x-axis and the
y-axis as well as a title that says plot of the cubic function, f (x) = x3 + cx and a
provide a legend for the value of c. Add a grid to your plot. (15pts)
Problem 3: (12pts)
(√ ) √
a. Draw the plot of the function, g(x, y) = sin x2 + y 2 / x2 + y 2 in 3-D. Make sure
you provide a label for the x-axis and the y-axis as well as a title that says plot of the
(√ ) √
function, g(x, y) = sin x2 + y 2 / x2 + y 2 . (8pts)
b. Replace x2 + y 2 by r2 and provide a 2-D plot g(r) against r in 2-D. Make sure you
provide a label for the x-axis and the y-axis as well as a title that says plot of the
function, g(r) = . . . . (4pts)
Problem 4: (18pts)
Draw the plot of the four functions, y1 (x) = x2 sin2 (x), y2 (x) = y1 (x) + x cos2 (x),
x2 y1 (x)
y3 (x) = , y4 (x) = x2 , and y5 (x) = x2 + x on the interval [0, 6π] in the same
y2 (x) + 1
graphical area. Make sure you provide a label for the x-axis and the y-axis as well as
a title that says plot of the 5 functions, y1 (x), y2 (x), y3 (x), y4 (x), y5 (x). Provide also
a legend that details the expressions of those 5 functions.
2
Problem 5: (20pts)
Write two Matlab script files that computes the following infinite sums of series with
an accuracy of 10−7 .
1 1 1 1 1 1 1 1 1 1 1
S1 = 1 − + − + − + − + − + − + ···
2 3 4 5 6 7 8 9 10 11 12
41 42 43 44 45 46 47 48 49 410
S2 = 1+ + + + + + + + + + + ···
1! 2! 3! 4! 5! 6! 7! 8! 9! 10!
1 1 1 1 1 1 1 1 1 1 1 1
S3 = 2 − 2 + 2 − 2 + 2 − 2 + 2 − 2 + 2 − 2 + 2 − 2 + ···
1 2 3 4 5 6 7 8 9 10 11 12
1 1 1 1 1 1 1 1 1 1 1 1
S4 = 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + ···
1 2 3 4 5 6 7 8 9 10 11 12
π2
Note that the first sum is ln(2), the second sum is exp(4), the third sum is , and
12
π2
the fourth sum is . Do not use these values in your codes, i.e., pretend you do not
6
know the results of these sums.