Answered step by step
Verified Expert Solution
Question
1 Approved Answer
xleft=-2; xright=2; N=20; x=linspace(xleft,xright,N); x=x'; dx=(xright-xleft)/(N-1); yleft=-1; yright=0; M=(diag(-2*ones(N,1),0)+diag(ones(N-1,1),-1)+diag(ones(N-1,1),1))/dx^2; M(1,:)=[1,zeros(1,N-1)]; M(end,:)=[zeros(1,N-1),1]; b=exp(cos(x))-exp(sin(x)); b(1)=yleft; b(end)=yright; y=Mb; plot(xleft:dx:xright,y) i got the answer 3.962 from this and its
xleft=-2;
xright=2;
N=20;
x=linspace(xleft,xright,N);
x=x';
dx=(xright-xleft)/(N-1);
yleft=-1;
yright=0;
M=(diag(-2*ones(N,1),0)+diag(ones(N-1,1),-1)+diag(ones(N-1,1),1))/dx^2;
M(1,:)=[1,zeros(1,N-1)];
M(end,:)=[zeros(1,N-1),1];
b=exp(cos(x))-exp(sin(x));
b(1)=yleft;
b(end)=yright;
y=M\b;
plot(xleft:dx:xright,y)
i got the answer 3.962 from this and its wrong. please correct this. thankyou.
The code provided solves the boundary value problem - = x cos(x), y(1) = 1, y(5) = 2 , on the interval 2 , on the interval d.c2 1Step 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