Question

1. Consider the Runge function, f:IH 1/1+25r). (a) Use your Lagrange interpolation code (from the previous worksheets) to app
0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

clc
clear all
xx=linspace(-1,1,1000);
plot(xx,1./(1+25*xx.^2));
s{1}='Original function';
n=[10:10:40];
for i=1:length(n)
x=linspace(-1,1,n(i));
y=1./(1+25*x.^2);
for ii=1:length(xx)
yy(ii) = linterp(x,y,xx(ii));
end
hold on;
plot(xx,yy);
s{i+1}=sprintf('Interpolated using %d points',n(i));
end
legend(s)
function y = linterp(X,Y,x)

sigma =0;

for i=1:numel(X)
pii = 1;
for j=1:numel(X)
if j~=i
pii = pii *(x - X(j))/(X(i)- X(j)) ;
end
end
  
sigma = sigma + Y(i)*pii;
end

y = sigma

end

Figure 1 File Edit View srt Iools Desktop Window Help 16000 Original function 14000 Interpolated using 10 points Interpolated

Kindly revert for any queries

Add a comment
Know the answer?
Add Answer to:
1. Consider the Runge function, f:IH 1/1+25r). (a) Use your Lagrange interpolation code (from the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 2. Consider interpolating the data (x0,yo), . . . , (x64%) given by Xi | 0.1...

    2. Consider interpolating the data (x0,yo), . . . , (x64%) given by Xi | 0.1 | 0.15 | 0.2 | 0.3 | 0.35 | 0.5 | 0.75 yi 4.0 1.0 1.22.12.02.52.5 For all tasks below, please submit your MATLAB code and your plots. You can write all code in a single (a) Using MATLAB, plot the interpolating (6th degree) polynomial given these data on the domain .m-file [0.1,0.75] using the polyfit and polyval commands. To learn how to use...

  • er Lagrange ,Divided difference and Hermitewatnejed, Jnp 1.5, and x2-2, andf (x)ssin(x) * Given the point sx.-1, a) Find its Lagrange interpolation P on these points b) Write its newton's divi...

    er Lagrange ,Divided difference and Hermitewatnejed, Jnp 1.5, and x2-2, andf (x)ssin(x) * Given the point sx.-1, a) Find its Lagrange interpolation P on these points b) Write its newton's divided difference P, polynomial c)Write Hermite Hs by Using part a outcomes d) Write Hermite Hi by Using part b outcomes Rules: Lagrange form of Hermite polynomial of degre at most 2n-+1 Here, L., (r) denotes the Lagrange coefficient polynomial of degree n. If ec la.bl, then the error formula...

  • Eilymai retine, or you m yur ova rodinT ur pl nda listing of your code. (b) Repeat part (a) with ...

    Please help me solve this. #4 a&b. thanks We were unable to transcribe this imageeilymai retine, or you m yur ova rodinT ur pl nda listing of your code. (b) Repeat part (a) with a polynomial of degree 12 that interpolates f at 13 scaled Chebyshev points, x 5 cos 12 Again you may use MATLAB's polyfit and polyval routines to fit the polyno- mial to the function at these points and evaluate the result at points throughout the interval,...

  • Consider the function f(x) 1 25x which is used to test various interpolation methods. For the rem...

    Consider the function f(x) 1 25x which is used to test various interpolation methods. For the remainder of this problem consider only the interval [-1, 1] The x-values for the knots (or base-points) of the interpolation algorithm are located at x--1,-0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75 1. (a) Create a "single" figure in Matlab that contains 6 subplots (2x3) and is labelled as figure (777), i.e the figure number is 777. Plot in each subplot the function f(x) using...

  • Use Matlab code Consider the following function sin(x) Using the following parameters in your functions: -func:...

    Use Matlab code Consider the following function sin(x) Using the following parameters in your functions: -func: the function/equation that you are required to integrate -a, b: the integration limits n: the number of points to be used for the integration I:Integral estimate a) Write a function capable of performing numerical integration of h(x) using the composite trapezoidal rule. Use your function to integration the equation with 9 points. Write a function capable of performing numerical integration of h(x) using the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT