Second order equations. Cauchy task
Show older comments
Hello, I need help with the following Cauchy task:

The graphs in the interval of the approximate solutions obtained by the numerical method for equations of the second order with steps h1 and so on should be drawn. I tried to solve the problem in several ways but I keep getting mistakes.This is the last code I wrote:
function Euler
x0=0;
u0=-1;
Du0=0;
xmax=20;
uu=dsolve('D2u+(1/4)*Du+6*u=0','u(0)=-1','Du(0)=0','x');
s=x0:(xmax-x0)/500:xmax;
z=subs(uu,'x',s);
plot(s,z);
grid on;
hold on;
h1=0.5;
x(1)=x0
u(1)=u0
Du(1)=Du0
x=x0:h1:xmax;
for i=1:length(x)-1
D2u(i+1)+h1*(1/4)*Du(i)+h1*6*u(i)==0
end
plot(x,u,'r.');
%h2=0.4;
%h3=0.01;
end
From this code I get only the graph of the solution but not the approximations, I will be very grateful if you tell me where I'm wrong and what I need to change.
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!