Problem 1: Graphing a bivariate function and its second order approximation
Use R to graph a 3–d plot of the function π(π₯1, π₯2) = cosβ‘(π₯1π₯2) and its second order Taylor approximation
β(π₯1, π₯2) = 1 β π2
8 π₯1
2. Following are the requirements:
i. [1 pt] Write an R function that produces the function π.
ii. [1 pt] Write an R function that produces the function β.
iii. [3 pts] Use the functions in (i) and (ii) to plot a 3d graph that contains the surfaces for both π and β on the same frame (axes). Color surface of π red and surface of β blue. The values of π₯1 for your graph should range in the interval [β π
4 , β‘π
4 ] and the values of π₯2 must range in the interval [π
4 , β‘3π
4 ]. You may consider dividing each of the intervals by 30 equal points and evaluate the function on the 30 by 30 grid generated, and then make your plot.
iv. [1 pt] Label the first axis π₯1and the second axis π₯2. Your graph should have the title βTaylor approximation of
cosβ‘(π₯1π₯2).β Make sure to show the plot from an angle with a good view of the function.
v. [3 pts] In a separate 3d plot, graph the absolute value error function π(π₯1, π₯2) = |π(π₯1, π₯2) β β(π₯1, π₯2)|. Use the same range and grid for π₯1 and π₯2 as described in (iii).
vi. [1 pt] Label the first axis π₯1and the second axis π₯2. Title your plot βThe error in second order Taylor expansion of cosβ‘(π₯1π₯2).β
vii. [3 pts] Plot the constant value contours for π(π₯1, π₯2), and explain the magnitude of the error at various locations in the context of the problem.
Problem 2: Given a π Γ 1vector π and a π Γ π positive definite matrix Ξ£, the pdf for a π–variate normal density at a point π = (π₯1, π₯2, … , π₯π)πcan be written as
π(π) = (2π)βπ
2 |Ξ£|β1/2 exp [β 1
2 (π β π)π Ξ£β1(π β π)] .
Now consider the bivariate normal random variable, where
π = (π₯1
π₯2) ,β‘β‘β‘β‘π = (π1
π2) ,β‘β‘β‘β‘β‘β‘Ξ£ = (π11 π12
π21 π22).
(a) [3 pts] Write the second order Taylor expansion for π(π), for the bivariate normal density, around the point
ππ = (π1
π2).
(b) [3 pts] Graph a 3–d plot of the function π(π₯1, π₯2) and its second order Taylor expansion for the following parameters (for each set of parameters, f and its approximation should be on the same frame):
(i)β‘β‘β‘π = (0
0) ,β‘β‘β‘β‘β‘β‘Ξ£ = ( 1 β0.3
β0.3 1 ) β‘;β‘β‘β‘β‘β‘β‘β‘β‘β‘β‘β‘β‘β‘β‘β‘β‘β‘(ii)β‘β‘β‘β‘β‘β‘β‘β‘β‘β‘π = (0
0) ,β‘β‘β‘β‘β‘β‘Ξ£ = ( 1 0.8
0.8 1 )
Note that the means and variances for each of the variables in the cases (i) and (ii) are 0 and 1 respectively. This should guide you an idea for a reasonable range for π₯1 and π₯2 to consider for your graphs.
(c) [3 pts] Graph the constant value contours for π(π) for the cases (i) and (ii) in part
(b). What is the shape of the constant value contours? What is the center of the constant value contours?
(d) [3 pts] Compute the eigenvalues and eigenvectors for each of the covariance matrices π΄ given in part (b).
Superimpose the eigenvectors on each of their corresponding constant value contours that you drew in part (c) and explain how the eigenvectors and eigenvalues are related to the constant value contours.