Question

For the following differential equation, answer the questions. -y+y=x (0.0 SX 35.0) y(0.0)=1.0, y(5.0)= 2.0 (1) Solve the di

solve using matlab or by hand.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The problem is solved analytically by hand and then for comparison, the result is inserted into the MATLAB in the form of the equation.

While solving (2) question central finite difference is used and formed a tridiagonal matrix using the MATLAB and solve the value of y at X=0,1,2,3,4,5 to compare the same value with the analytical solution.

In MATLAB results y is the solution from the analytical equation while D is the solution from the discretize equation.

I have included the script which you can directly copy-paste in MATLAB to get the result shown in the snip of the result.

comment if any query.

y- Audeng equotion mt particwon soutian 제 1 DAI 머 Lori - [+] = 3 lito 즐 Cs +1-8)= کیا کی [1-o] + x[ito ass - so Solution y=ceatsex tx at x=0, y=1 Ct2=1, C = 1-2 at x=s, y=2 a=cies the +5 c estges= -3 -(a)х ч = -( 3-5) estes + (3 tes es-c-s 2) Ч = x р 6 b: w - nes 1 3 - 4 = -х Ox2 9. - 24 Ч- - Ч Чs - 2 ч. - Ч. - 3 + - с = 2 XA S=s, x= ч Чs - 3 1 = -Ч - 5s ч -Ч- - 3Чs 4 = -6 this form a tridiagona matrix of to SS

SCRIPT OF MATLAB TO COMPARE BOTH RESULTS

clear all
clc
% %ANALYTICAL RESULT
x=0:5;
y=((-(3+exp(-5))*exp(x)+(3+exp(5))*exp(-x))/(exp(5)+exp(-5)))+x
%MATLAB DISCRETIZE RESULT
nn=6;
nn1=nn-2;
y(1)=1;
y(6)=2;
c1=-(2+1);
c2=1;
E=[x(2):x(5)]';
time=0;
%DEFINING TRIDIAGONAL MATRIX
A=full(gallery('tridiag',4,c2,c1,c2));
B=-E;
B(1)=B(1)-y(1); B(4)=B(4)-y(6);
C=A\B;
%y value AFTER FIRST ITERATION
D=[y(1);C;y(6)]'

SNIP OF MATLAB PROGRAM
clear all clc SANALYTICAL RESULT x=0:5; y=((-(3+exp(-5)) *exp(x)+(3+exp (5)) *exp(-x))/(exp(5) +exp(-5) ) ) +x SMATLAB DISCRE

SNIP OF RESULT FROM MATLAB:

y = 0.9999 1.3202 1.9884 2.6439 2.9126 2.0003 D = 1.0000 1.3273 1.9818 2.6182 2.8727 2.0000

where y is the value that is obtained from the Analytical solution while D is the value of y from the MATLAB discretization.

comment if any query.

Add a comment
Know the answer?
Add Answer to:
solve using matlab or by hand. For the following differential equation, answer the questions. -y"+y=x (0.0...
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
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