Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

function RungePheo(n) %% plot f(x)=1/(1+x^2) on [-5,5] ezplot('1/(1+x^2)',[-5 5]); hold on; %hold the graph. %% generate x_i=-5+(10)*i, stored in xd=[x0 x1 x2 ... xn] xd=[-5:(10):5];

image text in transcribed

function RungePheo(n)

%% plot f(x)=1/(1+x^2) on [-5,5]

ezplot('1/(1+x^2)',[-5 5]);

hold on; %hold the graph.

%% generate x_i=-5+(10)*i, stored in xd=[x0 x1 x2 ... xn]

xd=[-5:(10):5];

%% Generate y_i=f(x_i), stored in yd=[y0 y1 y2 ... yn]

yd=1./(1+xd.^2);

%% plot Pn(x), where Lagrange method is used.

%disritize [-5:5]

x=[-5:0.01:5];

%compute y=Pn(x) by LagrangePoly

for j=1:length(x)

y(j)=LagrangePoly(xd,yd,x(j));

end

% plot the (x,Pn(x)) in red

plot(x,y,'r'); %'r' indicates that the curve is red.

axis auto;

(Runge's Phenomenon) In this problem, we will see Runge's phenomenon or the function f(x) on the interval -5,5]. To be more precise, we will see that the more node points you put in [-5,5], the worse it becomes. This famous example is due to Carl Runge and the same (up to a scaling) as that demonstrated in class. Let ro ,, r1, ..., Tn be n +1 equally spaced points between -5 and 5 (with 20 =-5 and xn-5) (a) A matlab program named RungePheo.m is attached to illustrate Runge's phenomenon. Run the code to plot a figure with n 10 (your code in problem 4 is needed). Provide your figure. Explain Runge's phe- nomenon (b) As mentioned in class, the solution to Runge's phenomenon is to use polynomials of lower degree and use piecewise polynomial. In partic- ular, the natural cubic spline is a good one. In matlab, the natural cubic spline is implemented by the command spline. Write a mat- lab program to produce a similar figure by replacing the polynomial interpolation in (a) by the natural cubic spline interpolation. Provide your code, and print your figure with n = 10

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Relational Theory Normal Forms And All That Jazz

Authors: Chris Date

1st Edition

1449328016, 978-1449328016

More Books

Students also viewed these Databases questions

Question

Derive expressions for the rates of forward and reverse reactions?

Answered: 1 week ago

Question

Write an expression for half-life and explain it with a diagram.

Answered: 1 week ago

Question

What do you mean by underwriting of shares ?

Answered: 1 week ago

Question

Define "Rights Issue".

Answered: 1 week ago