3rd order non-linear differential equation (shooting method)
Show older comments
Hi, I have to solve the following equation --- f*f'' + 2*f''' = 0 with the boundary conditions --- for eta = 0: f = 0, f' = 0 and for eta = infinity (let's say it's 20): f' = 1 and I have a problem with the shooting method. If my initial solutions for f, f' and f'' are not near the real solution for the before mentioned then I don't get the right graph. Does anybody know what to do? Thanks in advance!
My code:
beskonacno = 20;
etaint = [0:.01:0.2 0.2:.02:0.8 0.8:.01:1]*20;
solinit = bvpinit(linspace(0,beskonacno,50000),@dbinit);
options = bvpset('stats','on');
sol = bvp4c(@difjedn,@rubuvj,solinit,options);
eta = sol.x;
f = sol.y;
figure
plot(eta,f(1,:),'b',eta,f(2,:),'m',eta,f(3,:),'k');
axis([0 beskonacno -1000 1000]);
title(' Rješenje ')
xlabel('\eta')
ylabel('f , df/d\eta , d^2f/d\eta^2')
legend('f','df/d\eta','d^2f/d\eta^2')
fi = deval(sol,etaint);
Tablica = table(etaint',fi(1,:)',fi(2,:)',fi(3,:)','VariableNames',{'eta' 'f' 'df' 'd2f'})
a = fi(3,1)
function dfdeta = difjedn(eta,f)
dfdeta(1) = f(2);
dfdeta(2) = f(3);
dfdeta(3) = -(f(1)*f(3))/2;
end
function res = rubuvj(f0,fbes)
res = [f0(1);
f0(2);
fbes(2)-1;]
end
function yinit = dbinit(x)
yinit = [x^4;
4*x^3;
12*x^2;
];
end
Answers (1)
hashem
on 11 Jan 2024
0 votes
let if you have many value for like f = -2s ,where s= -2.5,-2,-1.5,-1.-0.5,0 , what will be your code
Categories
Find more on Mathematics 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!