#%% Q4 code def poly_interpolation_2d(p,a,b,c,d,X,Y,n,m,f,produce_fig): #Remove the following two lines when you have completed the code interpolant = None fig = None return interpolant,fig #%% Q4 Test ################ f = lambda x,y : np.exp(x**2+y**2) n = 4; m = 3 a = 0; b = 1; c = -1; d = 1 x = np.linspace(a,b,n) y = np.linspace(c,d,m) X,Y = np.meshgrid(x,y) interpolant,fig = poly_interpolation_2d(11,a,b,c,d,X,Y,n,m,f,False) print("\n################################") print('Q4 TEST OUTPUT:\n') print("interpolant = \n") print(interpolant) ################ using python Interpolation of Multivariate functions Lagrange interpolation can also be used for interpolation of multivariate functions. Suppose we have a function f:R2R that we would like to approximate over the rectangular region [a,b][c,d]. To interpolate with a polynomial of degree p, we can define a set of p+1 distinct nodal points in both the x and y directions: {x^i}i=0p and {y^i}i=0p, respectively. f can then be interpolated by the function pp(x,y)=i=0pj=0pf(x^i,y^j)Lx,i(x)Ly,j(y), where {Lx,i(x)}i=0p are the Lagrange polynomials associated with x nodal points and {Ly,j(y)}j=0p are the Lagrange polynomials associated with the y nodal points. 4 In approximations . py you will find a function with the following definition: def poly_interpolation_2d (p,a,b, ,d,X,Y,n,m,f, produce_fig) The function should return as output: - interpolant - a numpy . ndarray of shape (m,n); - fig - a matplotlib.figure.Figure when the Boolean input produce_fig is True and None if produce_fig is False. - Complete the function so that it evaluates the p th order polynomial pp(x,y) of a function at a set of grid points stored in the mn arrays X and Y. Here, X and Y are assumed to have been created using the numpy .meshgrid function. Hence, the ij th component of interpolant should contain the value of pp(Xij,Yij). The nodal interpolating points in x and y should be uniformly spaced over the intervals [a,b] and [c,d] respectively, including the endpoints. - The function must call lagrange_poly from Q1 with tol =1.0e10. - If produce_fig is True then the function should produce a contour plot of the interpolant pp(x,y), which is returned in fig. - Once you have written poly_interpolation_2d test it by running approximations. py. You should obtain: interpolant =[[2.718281833.037731784.239496217.3890561][0.999999931.117518991.559623392.7182816 4][2.718281833.037731784.239496217.3890561].