Friday, February 22, 2013

C++ Coding - Euler's Method

Question

Consider an initial value ODE of the following form

dy-
dx = f (x,y),
x ∈ [a,b] and y (a ) = α
write a function to return the value of y at x=b given
            3x
f (x, y) = xe  −  2y,
a = 0,   b = 1, and α = 0

Thursday, February 7, 2013

C++ - Coding - Deterministic Coupon Bond Pricer

Question You must price a coupon bond with a principle of $100 maturing in 2 years time. Two coupons of $5 are paid at the end of year one and year two, and the continuous compound interest rate is a constant 10%. Extend your code to price a coupon bond with any specification.

C++ - Coding Black Scholes Formula

Question: Write a C++ code to calculate the option values for a call C(t = 0,S), and a put P(t = 0,S) using the Black-Scholes formula:
C(t = 0,S ) = SN (d1) − Xe −r(T−t)N (d2),
(2)

P (t = 0,S ) = Xe − r(T− t)N (− d2) − SN (− d1 )
(3)

Wednesday, February 6, 2013

C++ Examples - Cumulative Normal Distribution Function

Question:
Write a function to calculate N(x) the cumulative normal distribution with mean zero and variance one given by the formula
          1   ∫ x    2
N (x) =  √----    e−t ∕2dt
          2 π  −∞

C++ Examples - Functions Loops

Question: Write a function to calculate sin(x) using the first N terms of the power expansion