0% found this document useful (0 votes)
8 views4 pages

Homework 2 Spring 2025

The document outlines Homework 2 for MTH4320: Computational Finance, due on February 20th, 2025, consisting of five problems. The problems involve writing MATLAB scripts for quadratic equations, projectile motion, limits, plotting functions, and comparing LU factorization with Gaussian elimination. Each problem includes specific tasks and points allocation for successful completion.

Uploaded by

Jérôme
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

Homework 2 Spring 2025

The document outlines Homework 2 for MTH4320: Computational Finance, due on February 20th, 2025, consisting of five problems. The problems involve writing MATLAB scripts for quadratic equations, projectile motion, limits, plotting functions, and comparing LU factorization with Gaussian elimination. Each problem includes specific tasks and points allocation for successful completion.

Uploaded by

Jérôme
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

MTH4320: COMPUTATIONAL FINANCE — Spring 2025

Homework 2: due on February 20th

Problem 1: (30pts)

a. Write a function that computes the roots of a quadratic equation, q(x) = ax2 + bx + c.

(10pts)

b. To your function codes, add another main file (2pts) where the user is prompted to

enter the value for a, b and c. Enter the values (a, b, c) = (1, 2, −3) and provide the

roots corresponding to this case. (1pt)

c. Enter the one after the other the values (a, b, c) = (1, 1.2123, 2), (1, 12.123, 2), (1, 121.23, 2),

(1, 1212.3, 2) and provide the roots corresponding to these cases. (4pts)

d. Similarly, write another main file, where a, b, c are chosen randomly and print the ran-

domly generated set of numbers a, b, c on the screen. Provide the roots corresponding to

three random choices of the coefficients a, b, c and for each choice of the triplet (a, b, c)

provide in addition the graph of the quadratic function. (7pts) Run your codes three

times and show the results of it. (3pts)

e. Find the zeros of the fourth degree polynomial equation 9x4 − 61x2 + 100 = 0. Explain

how you will proceed to solve this equation using the Matlab code in (a.) (3pts)

1
Problem 2: (10pts)

In the absence of air resistance, the cartesian coordinates of a projectile launched with

an initial velocity (v0 ) and angle θ0 can be computed with

x = v0 cos(θ0 ) t ,

y = v0 sin(θ0 ) t − 0.5gt2 ,

where g = 9.81 m/s2 .

a. Develop a Matlab script to generate an animated plot of the projectile’s trajectory


π
given that v0 = 5 m/s and θ0 = . (6pts) Discuss how this problem is related to
4
Problem 1. (2pts)

b. Based on the trajectory, find approximately the coordinates of the highest point the

projectile will reach and the point he will hit the ground. (2pts)

Problem 3: (20pts)

a. Write a Matlab script file to calculate the following limit (4pts)



2n + 1
n=0
2n

b. Write a Matlab script file to calculate the following limit (4pts)



3n + 1

n=0
n5 + 4n2 + 12

c. Write a Matlab script file to calculate the following limit (4pts)


∑∞
1
n=1
n2


(−1)n−1
n=1
n2

2
d. Write a Matlab script file to calculate the following limit (4pts)



ln(n2 )
n=2
n2

E. Write a Matlab script file to calculate the following limit (4pts)

sin(x11 )
lim
x −→ 0 x7
−x3 + + x3 cos(x2 )
2

Problem 4: (10pts)
( )
ln (ax8 + bx4 + cx3 + dx2 + e)5
Draw the plot of the function, f (x) = on the inter-
(f x2 + g)
vals, [−5, 5] and [−10, 10] for a = 5, b = −6, c = 4, d = 21, e = 14, f = 1, g = 3. Make

sure your provide a label for the x-axis and the y-axis as well as a title that says plot
( )
ln (ax8 + bx4 + cx3 + dx2 + e)5
of the given function, f (x) = , for a = 5, b = −6, c =
(f x2 + g)
4, d = 21, e = 14, f = 1, g = 3. Add a grid to your plot.

Problem 5: (30pts)

a. Using MATLAB, confirm that the LU factorization ([L, U ] = lu(D)) out-performs the

MATLAB’s Gaussian elimination (x = D\b) procedure in terms of speed for solving

the following system of linear equations written in matrix form Dy = b, where the

matrix D and column-vector b are given as follows:

D = [4 2 3; 5 − 8 1; 4 7 − 9]

b = [1 4 0]′ .

Provide the clock time to execute these calculations. (5pts)

3
b. Redo the same task above by generating a set of m random integer values for the vector

b between 1 and 100 inclusive and compare the speed of each methodology for a bunch

of different number of iterations (m = 1000, 50, 000, and 100, 000 simulations). Here,

you must use a for loop. Provide the clock time to execute the m calculations in each

loop. Put those results in table form. (9pts)

c. The matrix A and the column vectors b and y are defined as follows:
     
 0.780 0.563   0.217   −1 
A=  , b=  , y=  .
0.913 0.659 0.254 1

Enter these matrix and vectors into Matlab. (4pts)

d. Compute the vector, Ay. (1pt)

e. Using Matlab, solve the linear equations Ax = b. Use both the LU decomposition and

the Gaussian elimination method. (5pts)

f. Consider the matrix of perturbation E defined as


 
 0.001 0.001 
E =   ,
−0.002 −0.001

Using Matlab solve the perturbed system of equation (A + E)yE = b. Use both the LU

decomposition and the Gaussian elimination method. (5pts) Discuss your funding.

(1pt)

You might also like