Question
Please modify my code ( MY CODE BELOW) using the built-in MATLAB functions spline and ppval to build a clamped spline that solves the problem
Please modify my code (MY CODE BELOW) using the built-in MATLAB functions spline and ppval to build a clamped spline that solves the problem. Here is an example script from Mathworks.com to get you started.
x=-4:4; y=[0 .15 1.12 2.36 2.36 1.46 .49 .06 0]; clamped=spline(x,[0 y 0]); xx=linspace(-4,4,101); plot(x,y,o,xx,ppval(clamped,xx),-);
Use 50 equispaced points for this problem.
MAT 340 NUMERICAL METHODS. THANKS IN ADVANCE!
f=@(x) 1./(1+10.*x.^2);
X=linspace(-1,1); %% domain in order to plot
%% s for the error
s=linspace(0,1);
plot(X,f(X),'k','lineWidth',3)
hold on
for n=3:12
x=linspace(-1,1,n+1);
y=f(x);
P=lagrangepoly(x,y);
plot(X,P(X),'--')
n
Error_n=max(abs(f(s)-P(s)))
end
%%
% The error was decreasing up until the odd n's up until 7 and increasing for even n's
% For n=100 the error should be large
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started