Dear Student,
Following is the answer:
Here, ya and by are the boundary conditions.
The resulting solution curve yt is :
Here, ya and by are the boundary conditions.
The resulting solution curve y(t) is given below:
(a) Consider the following linear Boundary Value Problem, y(0) = 0 »(1) =- The above differential equation at 1, in the discretized form is given by, Wo.-2w,+w,, - h’w – 25 €* =0 W-(2w; +hº)w, + w., _ 24?<" =0 3 The first and last equations along with the boundary conditions are given by, ya-(2+hº)w; - 24*2" + w, = 0 Www-(2+hº)w.-25 <"+y = 0
Differentiate y, -(2+h?) w; -25% e" + W, = 0) with respect to w; . Thus, -(2+h+)=0 y(0) = 0, y(1) --- Use the following MATLAB program to approximate solutions for the linear BVP y" = y + . This program is saved as 'nlbvpfdi.m'. % This program is used to find the approximate solutions for % the boundary value problem(BVP) by using the Finite Difference Method % The interval(inter), boundary values(bv), number of steps(n) are inputs % The solution(w) is an output % Command used: w=nlbvpfdi [O 1].[O exp(1)/3],9) function W=nlbvpfd1(inter, bv,n) a=inter(1); b=inter(2),ya=bv(1); yb=bv(2); h=(b-a)/(n+1); % This gives the step size h W=zeros(n,1); % This initializes solution array w for i=1:20 W=W-jac(Winter, bv,n)\f(Winter, bv,n); end plot([a a+(1:n)*h b],[ya W' yb]); % This gives plot w with boundary data xlabel('t'),ylabel('y') title('Approximate solutions of BVP by the Finite Difference Method')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function y=f(Winter, bv,n) y=zeros(n,1); h=(inter(2)-inter(1)/(n+1); y(1)=bv(1)-(2+h^2)*W(1)-2*h^2*exp(h)/3 +W(2); y(n)=W(n-1)-(2+h^2)*W(n)-(2*h^2/3)*exp(h+bv(2): for i=2:n-1 y(i)=W(i-1)-(2+h^2)*W(1)-(2*(h^2)/3)*exp(h)+W(i+1); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function a=jac(Winter, bv,n) a=zeros(n,n); h=(inter(2)-inter(1)/(n+1); for i=1:n a(i,i)=-2-h^2; end for i=1:n-1 a(i,i+1)=1; a (i+1,1)=1; end Consider n=9 Use the MATLAB command 'w=nlbvpfd1( [0 1], [O exp(1)/3],9)' to approximate solutions for the linear BVP y = y +-e',y - for n=9 See the screenshot given below. 3
HOME PLOTS APPS Ayon 2 County New New Open compare port Des We w e - - - - Users De MATLAB >> veloved to 1). 10 exp (1)/). 201503548 0. 8 0.11 gaaaaaaa999 Vant veltp to . temp . 10 11. (exp(3) 1), 39) trup >> ris po to 11. 3/1. vnpt10 21. 1 /3.9)
CHU Times New Roman - 12 - File Edit View the Tool Detop Window Help AaB obce. A nd S . S Approximate solutions of BVP by the Finite Difference Method 09 01 02 03 04 05 06 07 08 09 e F
The exact solution for the linear BVP Y" = y + e',y(0) = 0, y(1)=-e is given by, v(t) = zce Use the following MATLAB program to plot the approximate solutions together with the exact solutions y(t) = -te'. This program is saved as 'nlbupfdia.m! % This program is used to find the approximate solutions for % the boundary value problem(BVP) by using the Finite Difference Method % The interval(inter), boundary values(bv), number of steps(n) are inputs % The solution(w) is an output % Command used: w=nlbvpfdi( [01],[O exp(1)/3],9) function W=nlbvpfdia(inter, bv,n) a=inter(1); b=inter(2);ya=bv(1); yb=bv(2); h=(b-a)/(n+1); % This gives the step size h W=zeros(n,1); % This initializes solution array w for i=1:20 % loop of Newton step W=W-jac(Winter, bv,n)\f(Winter, bv,n); end for i=1:11 z(i)=0; t(i)=0; end
for i=0:10 t(i+1)=t(i+1)+i/10; z(i+1)=z(i+1)+t(i+1)*exp(t(i+1))/3; end plot([a a+(1:n)*h b].[ya W' yb]);hold on plot(t,z) xlabel('t'),ylabel(y) title('Approximate solutions of BVP by the Finite Difference Method') function y=f(Winter,bv,n) y=zeros(n,1); h=(inter(2)-inter(1))/(n+1); y(1)=bv(1)-(2+h^2)*W(1)-2*h^2*exp(h)/3 +W(2); y(n)=W(n-1)-(2+h^2)*W(n)-(2*h^2/3)*exp(h)+by(2); for i=2:n-1 yO=W(1-1)-(2+h^2)*W(1)-(2*(h^2)/3)*exp(h)+W(i+1); end function a=jac(W,inter,bv,n) a=zeros(n,n); h=(inter(2)-inter(1))/(n+1); for i=1:n a(i,i)=-2-h^2; end for i=1:n-1
a(i,i+1)=1; a (i+1,1)=1; end Use the MATLAB command 'w=nlbvpfdia( [0 1],[0 exp(1)/3],9)' to plot the approximate solutions together with the exact solutions y The screenshot of the output of the above program is given below.
MARA 2013 HOME PLOTS APPS w e Es www Open de View that too Desktop Window DOBRODD Plot of the approximate and the exact solutions Users Dev MAT 0.000000 011 om LELBLODOBE 01 02 03 04 05 06 07 08 09 venlbup to 1). exp)/), 9) tro van lupaa 10), 10 exp (3)/931
Use the following MATLAB program to calculate errors and make a semilog plot for the errors. This program is saved as 'nlbvpfdial.m! % This program is used to find the approximate solutions for % the boundary value problem(BVP) by using the Finite Difference Method % The interval(inter), boundary values(bv), number of steps(n) are inputs % This program gives semilog plot for errors. % Command used: w=nlbvpfd1( [0 1], [0 exp(1)/3],9) function W=nlbvpfdial(inter, bv,n) a=inter(1); b=inter(2),ya=bv(1); yb=bv(2); h=(b-a)/(n+1); % This gives the step size h Wrzeros(n,1); % This initializes solution array w for i=1:20 % loop of Newton step W=W-jac(Winter, bv,n)\f(W,inter, bv,n); end for i=1:10 z(i)=0; t(i)=0; err(i)=0; end W(10)=bv(2); for i=1:10 t(i)=t(i)+i/10;
z(i)=z(i)+t(i)*exp(t1))/3; err(i)=err(i)+abs(w(1)-z(i)); end disp([' Errors=']) disp(err) semilogy(t.err) xlabel('t'),ylabel('Error') title('A semilog plot for the errors') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function y=f(winter, bv,n) y=zeros(n,1); h=(inter(2)-inter(1))/(n+1); y(1)=bv(1)-(2+h^2)*W(1)-2*h^2*exp(h)/3 +W(2); y(n)=W(n-1)-(2+h^2)*W(n)-(2*h^2/3)*exp(h)+bv(2); for i=2:n-1 y(i)=W(i-1)-(2+h^2) *W(1)-(2*(h^2)/3)*exp(h)+W(i+1); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function a=jac(Winter,bv,n) a=zeros(n,n); h=(inter(2)-inter(1))/(n+1); for i=1:n a(i,i)=-2-h^2;
end for i=1:n-1 a(i,i+1)=1; a (i+1,1)=1; end Use the MATLAB command 'w=nlbvpfdia( [01],[O exp(1)/3],9)' to calculate errors and make a semilog plot for the errors. The screenshot of the output of the above program is given below.
MAR 2018 HOME PLOTS APPS s e Save New Come t de de view met Tool Desktop Window Help waa94. GOED A semilog plot for the errors MAT Users Dev 1. 360. 00 10 / lvplom ẽ làm sáng tác, 01 02 03 04 05 06 07 08 09 tremor edilm venitpraat 10:30 exp (3/3). enp alal 1). O expi/3). van lupaal to :).[ x )/3).
(b) Consider the following linear Boundary Value Problem, y" = (2+41?)y y(0)=1 y(1)=e The above differential equation at 1, in the discretized form is given by, W.-2w, + W-1 w, = 0 W-, -2w; + W-,-h (2+4h?)w; = 0 W*-(2+ 2h? + 4h* )w, +W;+1 = 0 The first and last equations along with the boundary conditions are given by, y. -(2+ 2h +4h*) w; +w, = 0 W-1-(2+ 2h +4h*)w, + y) = 0
Use the following MATLAB program to approximate solutions for the linear BVP y" = (2+41° ) y, y(0)=1, y(1)=e. This program is saved as 'nlbvpfdib.m. % This program is used to find the approximate solutions for % the boundary value problem(BVP) by using the Finite Difference Method % The interval(inter), boundary values(bv), number of steps(n) are inputs % The solution(w) is an output % Command used: w=nlbvpfd1( [01],[1 exp(1)],9) function W=nlbvpfdi(inter, bv,n) a=inter(1); b=inter(2);ya=bv(1); yb=bv(2); h=(b-a)/(n+1); % This gives the step size h Wrzeros(n,1); % This initializes solution array w for i=1:20 % loop of Newton step W=W-jac(Winter, bv,n)\f(Winter, bv,n); end plot([a a+(1:n)*h b].[ya W' yb]); % This gives plot w with boundary data xlabel('x'),ylabel('y') title('Approximate solutions of BVP by the Finite Difference Method') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function y=f(Winter,bv,n) y=zeros(n,1); h=(inter(2)-inter(1))/(n+1);
y(1)=bv(1)-(2+2+h^2+4*h^4)*W(1)+W(2); y(n)=W(n-1)-(2+2*h^2+4**40*W(n)+bv(2); for i=2:n-1 y(i)=W(i-1)-(2+2*h^2+4*h^4)*W(1)+W(i+1); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function a=jac(Winter,bv,n) a=zeros(n,n); h=(inter(2)-inter(1))/(n+1); for i=1:n a(i,i)=-2-2*h^2-4*h^4; end for i=1:-1 a(i,i+1)=1; a (i+1,i)=1; end
Consider n=9. Use the MATLAB command 'w=nlbvpfdib( [01],[1 exp(1)],9)' to approximate solutions for the linear BVP y" = (2+41?) y, y(0) = 1, y(1) = e for n=9 .See the screenshot given below.
HOME APPS L PLOTS E compare Wate Aye Cute h oto 2 Community New New Open port Gew e - Ch . The Users De MATLAB 19EPAT I Error: Unbalanced expected par platbu wide dre olt! 01 te/ ots/Total pada m edium e11 ore dra olit ol Jatradau te/ 16/ ) de l'Isolated (6 De
MARA 2013 HOME PLOTS APPS F porte e e t View It To Desktop Window Help New New Open compare Approximate solutions of BVP by the Finite Difference Method a Users Don MA nbsplat trup at to exp 33/3). velpaal O3). Exp!/3), m edium venitpro Venlo 3.0 /3. O ). O exp(1/3). velbruptabt 10 , 11 exp()). De GUYEN .
The exact solution for the linear BVP y" = (2+41?)y, y(0) = 1, y(1)= e is given by, y(t)=en Use the following MATLAB program to plot the approximate solutions together with the exact solutions y(t)=e. This program is saved as 'nlbvpfdibi.m! % This program is used to find the approximate solutions for % the boundary value problem(BVP) by using the Finite Difference Method % The interval(inter), boundary values(bv), number of steps(n) are inputs % The solution(w) is an output % This program plots the approximate and the exact solutions. % Command used: w=nlbvpfd1 [O 1],[O exp(1)/3],9) function W=nlbvpfd1b1(inter,bv,n) a=inter(1); b=inter(2),ya=bv(1); yb=bv(2); h=(b-a)/(n+1); % This gives the step size h Wrzeros(n,1); % This initializes solution array w for i=1:20 % loop of Newton step W=W-jac(Winter, bv,n)\f(W,inter,bv,n); end for i=1:11 z(i)=0; t(i)=0; end
for i=0:10 t(i+1)=t(i+1)+i/10; z(i+1)=z(i+1)+exp(t(i+1)^2); end disp(['The exact solutions are']) disp(z) plot([a a+(1:n)*h b],[ya W' yb]);hold on plot(t,z) xlabel('t'),ylabel('') title('Plot of the approximate and the exact solutions) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function y=f(Winter, bv,n) y=zeros(n,1); h=(inter(2)-inter(1))/(n+1); y(1)=bv(1)-(2+2*h^2+4*h^4)*W(1)+W(2); y(n)= (n-1)-(2+2*h^2+4*5*40*W(n)+bv(2); for i=2:n-1 y(i)=W(i-1)-(2+2*h^2+4*h^4)*W(1)+W(i+1); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function a=jac(W,inter,bv,n) a=zeros(n,n); h=(inter(2)-inter(1))/(n+1);
for i=1:n ali,i)=-2-2*h^2-4*h^4; end for i=1:n-1 a(i,i+1)=1; a (i+1,1)=1; end Use the MATLAB command 'w=nlbvpfdib( [01],[1 exp(1)],9)' to plot the approximate solutions together with the exact solutions y(t) = e. See the screenshot given below.
ONU File Edit View AaB BCAA and Tool Detop Window Help OR GOOD Plot of the approximate and the exact solutions AaB 1 e Same Set Pherome BUXAD . AS Change Select The sereenshot of the output of the above program is given below. Por of Words e F 33
t(i)=t(i)+i/10; z(i)=z(i)+t(i)*exp(ti))/3; err(i)=err(i)+abs(w(1)-z(i)); end disp('Errors=']) disp(err) semilogy(t,err) xlabel('t'),ylabel('Error') title('A semilog plot for the errors') %%%%%%%%%%%%%%%%%%%%%%%%%%%%% function y=f(Winter,bv,n) y=zeros(n,1); h=(inter(2)-inter(1))/(n+1); y(1)=bv(1)-(2+2*h^2+4*h^4)*W(1+W(2); y(n)=W(n-1)-(2+2*1^2+4*5*40*W(n)+bv(2); for i=2:n-1 y(i)=W(i-1)-(2+2*h^2+4*h^4)*W(1)+W(i+1); end %%%%%%%%%%%%%%%%%%%%%%%%%% function a=jac(W,inter, bv,n) a=zeros(n,n); h=(inter(2)-inter(1))/(n+1); for i=1:n
a(i,i)=-2-2*h^2-4*h^4; end for i=1:n-1 a(i,i+1)=1; a (i+1,1)=1; end
Use the MATLAB command 'w=nlbvpfd1b2( [01],[1 exp(1)],9)' to calculate errors and make a semilog plot for the errors. See the screenshot given below.
HU ... 1 AN File Edit View the Tool Desktop Window Help Times New Roman AaB chce. A nd S e Suite Change Select A semilog plot for the errors 01 02 03 04 05 06 07 08 09 1 Prof Wonder 2 e F1
Consider n=19 Use the MATLAB command 'w=nlbvpfdib( [01],[1 exp(1)],19) to approximate solutions for the linear BVP b) = 1, y(1)= e for n=19 See the screenshot given below.
ONU File Edit View the Tool Desktop Window Help AdD ABG ABOCA Approximate solutions of BVP by the Finite Differrace Method Approximate Terrons BVP by The FINE DINE Method Profonden e FE 1 ,
Consider n = 39 Use the MATLAB command 'w=nlbvpfdi( [01],[1 exp(1)],39)' to approximate solutions for the linear BVP y" = (2+41?)y, y(0)=1, y(1)= e for n = 39 .See the screenshot given below.
MARA 2013 HOME PLOTS APPS F www com Nome mot Save e e t View It To Desktop Window Help waaASSO926.& DEOD Approximate solutions of BVP by the Finite Difference Method PO Users Do MAT nbsplat SEDDELDUDDDDDDDDDD venp alat 1.10 exp (1)/3). vapaalt D2. /31.9 nl pla rungkutan n a toto exp 33/3). Venlo b !). ! exp() ) Venlop 10 1.1 Rp11). venitpreibi . ). veltpal D 1). [ ex (1)1,9) Fat to 11.11 p .15 vanlibutab 1 ) (exp(33.39) e