Question: In polynomial _ interpolation. py you will find a function with definition def compute _ piecewise _ errors ( a , b , n _

In polynomial_interpolation. py you will find a function with definition
def compute_piecewise_errors(a,b,n_m, M, n_p, P,f)
The function should return as output:
u_error_matrix, nu_error_matrix - two numpy.ndarrays, each of shape
(n_m,n_p).
u_fig, nu_fig - two matplotlib.figure.Figures.
Complete the function to compute (approximations to) the error
maxxin[a,b]|Spkml(x)-f(x)| for a range of polynomial degrees P={pk}k=0np-1 and
numbers of subintervals M={ml}l=0nm-1. Row l of u_error_matrix should
contain the errors when a uniform set of interpolating nodes is used in each
subinterval, while row l of nu_error_matrix should contain the errors when the
nonuniform set of interpolating nodes is used in each subinterval.
Compute the approximation to the error by evaluating the error |Spkml(x)-f(x)|
for 2500 equally spaced points over a,b and take the maximum of those.
The function should create two plots, one for the uniform errors and one for
the nonuniform errors. Each plot should be of the errors against {ml}l=0nm-1, have
a separate line for each {pk}k=0np-1, and use plt.loglog. The figures should be
returned in u_fig and nu_fig.
Add a description at the top of your compute_piecewise_errors function
as a "docstring" that, when help(p_int.compute_piecewise_errors) is run,
will briefly comment on and explain the results when P={1,2,3,4,5,6} and
M={1,2,4,8,16,32,64,128,256,512,1024}, with
(a)f(x)=sin(x)+110cos(8x),[a,b]=[-1,1].
(b)f(x)=|x-13|2,[a,b]=[-1,1].
You should also comment briefly in the "docstring" on the relative effectiveness
of increasing p and m at reducing the error.
 In polynomial_interpolation. py you will find a function with definition def

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!