Question

In: Advanced Math

Part c). is needed On the interval [-1,1], consider interpolating Runge’s function f(x) = 1/ (1...

Part c). is needed

On the interval [-1,1], consider interpolating Runge’s function f(x) = 1/ (1 + 25x^2) By Pn(x), use computer to graph:

(a) Take the nodes xi to be –1, 0, 1 and obtain P2(x). In the same graph, plot the two functions f(x) and P2(x) over the interval [-1,1]. Use different line-styles, so that f(x) and P2(x) look distinct.

(b) Take five nodes xi to be -1, -0.5, 0, 0.5, 1 and obtain P4(x). In the same graph, plot the two functions f(x) & P4(x) over the interval [-1,1] . Use different line-styles, so that f(x) and P4(x) look distinct.

(c) Take 11 equally spaced nodes in [-1,1], starting at –1, ending at 1, and obtain the interpolating polynomial P10(x). Also, use 11 Chebyshev nodes in [-1,1] and obtain Pc(x), the corresponding interpolating polynomial. In the same graph, plot the three functions f(x), P10(x) and Pc(x) over the interval [-1,1] . Use different line-styles, so that f(x), P10(x) and Pc(x) look distinct.

Solutions

Expert Solution

We have developed a MATLAB code for the given problem. Here, input of the function is the degree of the polynomial.

---------------------MATLAB code---------------------

function Runge_function(n)
% n=degree of the polynomial;
% Therefore, number of data popints is n+1;

fx=@(x) 1./(1+25*x.^2);
a=-1;
b=1;
x_exact=a:0.01:b;
y_exact=fx(x_exact);

x=(a:(b-a)/n:b)';
y=fx(x);

A=x.^(0:n);
coeff=(A'*A)\(A'*y);

fprintf('\nRequired %g th degree polynomial is: \n\n',n)
fprintf(' y= %g + (%g) x',coeff(1),coeff(2))
for i=3:n+1
fprintf(' + (%g) x^%g',coeff(i),i-1);
end
fprintf('\n\n')

xx=a:0.01:b;
yy=0*xx;
y2=0*x;

for j=0:n
yy=yy+coeff(j+1)*xx.^j;
y2=y2+coeff(j+1)*x.^j;
end

VarNames = {'x','exact_y','approx_y','Absolute_error'};
TT=table(x,y,y2,abs(y-y2), 'VariableNames',VarNames);
disp(TT);

figure(1)
plot(xx,yy,'-',x_exact,y_exact,'--',x,y,'*k','LineWidth',1.25);
xlabel('x','fontsize',14)
ylabel('y(x)','fontsize',14)
legend('Polynomial','Actual curve','Node points')
title('Regression line vs Actual data','fontsize',14);
end

(a)

(b)

(c)


Related Solutions

On the interval [-1,1], consider interpolating Runge’s function f(x) = 1/ (1 + 25x^2) By Pn(x),...
On the interval [-1,1], consider interpolating Runge’s function f(x) = 1/ (1 + 25x^2) By Pn(x), use computer to graph: (c) Take 11 equally spaced nodes in [-1,1], starting at –1, ending at 1, and obtain the interpolating polynomial P10(x). Also, use 11 Chebyshev nodes in [-1,1] and obtain Pc(x), the corresponding interpolating polynomial. In the same graph, plot the three functions f(x), P10(x) and Pc(x) over the interval [-1,1] . Use different line-styles, so that f(x), P10(x) and Pc(x)...
Consider polynomial interpolation of the function f(x)=1/(1+25x^2) on the interval [-1,1] by (1) an interpolating polynomial...
Consider polynomial interpolation of the function f(x)=1/(1+25x^2) on the interval [-1,1] by (1) an interpolating polynomial determined by m equidistant interpolation points, (2) an interpolating polynomial determined by interpolation at the m zeros of the Chebyshev polynomial T_m(x), and (3) by interpolating by cubic splines instead of by a polynomial. Estimate the approximation error by evaluation max_i |f(z_i)-p(z_i)| for many points z_i on [-1,1]. For instance, you could use 10m points z_i. The cubic spline interpolant can be determined in...
Consider the function f(x)= x3 x2 − 1 Express the domain of the function in interval...
Consider the function f(x)= x3 x2 − 1 Express the domain of the function in interval notation: Find the y-intercept: y=   . Find all the x-intercepts (enter your answer as a comma-separated list): x=   . On which intervals is the function positive?   On which intervals is the function negative?   Does f have any symmetries? f is even;f is odd;     f is periodic;None of the above. Find all the asymptotes of f (enter your answers as equations): Vertical asymptote (left):   ; Vertical...
the function F:(-1,1)toR dfined by F(x)=x/(1-x^2) is homeomorphism in a topology.. please explain the answer for...
the function F:(-1,1)toR dfined by F(x)=x/(1-x^2) is homeomorphism in a topology.. please explain the answer for me
Consider the function f(x)=arctan [(x+6)/(x+5)] Express the domain of the function in interval notation: Find the...
Consider the function f(x)=arctan [(x+6)/(x+5)] Express the domain of the function in interval notation: Find the y-intercept: y= . Find all the x-intercepts (enter your answer as a comma-separated list): x= . Does f have any symmetries? f is even; f is odd; f is periodic; None of the above. Find all the asymptotes of f (enter your answers as comma-separated list; if the list is empty, enter DNE): Vertical asymptotes: ; Horizontal asymptotes: ; Slant asymptotes: . Determine the...
Consider the function f(x)=arctan [(x+6)/(x+5)] Express the domain of the function in interval notation: Find the...
Consider the function f(x)=arctan [(x+6)/(x+5)] Express the domain of the function in interval notation: Find the y-intercept: y= . Find all the x-intercepts (enter your answer as a comma-separated list): x= . Does f have any symmetries? f is even; f is odd; f is periodic; None of the above. Find all the asymptotes of f (enter your answers as comma-separated list; if the list is empty, enter DNE): Vertical asymptotes: ; Horizontal asymptotes: ; Slant asymptotes: . Determine the...
Consider the function on the interval (0, 2π). f(x) = sin(x) cos(x) + 2 (a) Find...
Consider the function on the interval (0, 2π). f(x) = sin(x) cos(x) + 2 (a) Find the open interval(s) on which the function is increasing or decreasing. (Enter your answers using interval notation.) increasing     ( )    decreasing     ( )   (b) Apply the First Derivative Test to identify all relative extrema. relative maxima     (x, y) =    (smaller x-value) (x, y) = ( )    (larger x-value) relative minima (x, y) =    (smaller x-value) (x, y) = ​   ...
Using Matlab, consider the function f(x) = x^3 – 2x + 4 on the interval [-2,...
Using Matlab, consider the function f(x) = x^3 – 2x + 4 on the interval [-2, 2] with h = 0.25. Write the MATLAB function file to find the first derivatives in the entire interval by all three methods i.e., forward, backward, and centered finite difference approximations. Could you please add the copiable Matlab code and the associated screenshots? Thank you!
Consider the function f(x)= 7 - 7x^2/3 defined on the interval [-1, 1]. State which of...
Consider the function f(x)= 7 - 7x^2/3 defined on the interval [-1, 1]. State which of the three hypotheses of Rolle’s Theorem fail(s) for f(x) on the given interval.
Consider the function ?: (−1,1) × (−1,1) → ℝ given by ?(?, ?) = sin(?? +...
Consider the function ?: (−1,1) × (−1,1) → ℝ given by ?(?, ?) = sin(?? + ?? + ?2 ). 1. Find a bound for the directional derivative of ? in any direction, i.e. find a constant ? such that |???(?, ?)| ≤ ? for all (?, ?) ∈ (−1,1) × (−1,1) and ? ∈ ℝ 2 with |?| = 1.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT