1. (Extensions to the Excel Driver) There are many ways to add new functionality to the Excel...
Question:
1. (Extensions to the Excel Driver)
There are many ways to add new functionality to the Excel driver. In this exercise we focus on generalising the code.We wish to display functions of arity one and two.We hide low-level details such as the creation of mesh arrays and other supporting code. The desired functions have the following interfaces:
using Function1DType = std::function
using Function2DType = std::function
void printDiscreteFunctionValues(const Function1DType& f, double A, double B,long nSteps, const std::string& title, const std::string& horizontal, const std::string& vertical, const std::string& legend);
void printDiscreteFunctionValues(const Function1DType& f, const std::vector
void printDiscreteFunctionValues(const Function2DType& f, double A, double B,long xSteps, double C, double D,long ySteps, const std::string& title, const std::string& horizontal, const std::string& vertical, const std::string& legend);
void printDiscreteFunctionValues(const Function2DType&
f, const std::vector
Answer the following questions:
a) Write the code for the above functions based on existing code in the driver.
b) Test functions of arity one on Black–Scholes call option prices and the corresponding greeks:
ΔC = ????C ????S = e(b−r)TN(d1)
ΓC ≡ ????
2C ????S2 = ????ΔC ????S = n(d1)e(b−r)T S????
√
T VegaC ≡ ????C ????????
= S √
Te(b−r)Tn(d1)
ΘC ≡ −????C ????T = −S????e(b−r)T n(d1)
2 √
T − (b − r)Se(b−r)TN(d1) − rKe−rTN(d2).
c) Test functions of arity two by displaying the probability density function of the bivariate t-distribution on a given interval (Nadarajah and Kotz, 2005):
f (x, y; ????, ????) = 1 2????
√
1 − ????
2 {
1 + x2 − 2????xy + y2 ????(1 − ????
2)
}−(????+2)∕2 .
We shall discuss this distribution in more detail in Chapter 16 when we discuss ways to compute the (cumulative) probability integral:
P(x, y; ????, ????) = ∫
x −∞
∫
y −∞
f (x, y; ????, ????)dxdy.
Step by Step Answer: