Why do I receive Jacobian singular error while solving second order differential equation with boundary conditions?
1 view (last 30 days)
Show older comments
I am trying to solve the following second order differential equation: ηF''-F'+FF'= 0; The boundary conditions being F(0)=0 , F'(0)=0 and F'(inf)=0.
This is my code:
solinit = bvpinit(linspace(0,10,100),@guess);
solve = bvp4c(@f,@bc,solinit);
plot(solve.x,solve.y(1,:))
xlabel('eta')
ylabel('F')
function dydx = f(x,y)
dydx = [y(2); (1/(x)).*(y(2)-(y(1).*y(2)))];
end
function output = bc(ya,yb)
output = [ya(2)-1; yb(2)];
end
function y = guess(x)
y = [cos(x) -sin(x)];
end
Any help regarding this would be greatly appreciated! Thank you!
0 Comments
Accepted Answer
Torsten
on 2 Jan 2024
Edited: Torsten
on 2 Jan 2024
You need two boundary conditions, not three to fix a solution for a second-order ODE.
Anyhow: in each of your cases, you will get F identically 0 if you use a numerical method for a solution.
I don't know whether a non-trivial solution for your equation exists.
According to the symbolic approach below, there is no bounded solution at x=0 apart from the trivial one.
syms x y(x)
df = diff(y,x);
d2f = diff(y,x,2);
ode = d2f == df*(1-y)/x;
sol = dsolve(ode)
conds = [y(0)==0,df(0)==0];
sol = dsolve(ode,conds)
0 Comments
More Answers (1)
Ayush
on 2 Jan 2024
I understand that you are receiving Jacobian singular error while solving second order differential equation with boundary conditions. Here is the modified code you can try:
% Set up the initial mesh and initial guess
solinit = bvpinit(linspace(0,10,100), @guess);
% Solve the boundary value problem
solve = bvp4c(@f, @bc, solinit);
% Plot the solution
plot(solve.x, solve.y(1,:))
xlabel('eta')
ylabel('F')
% Define the differential equation as a system of first-order ODEs
function dydx = f(x,y)
dydx = [y(2); (1/(x+eps)).*(y(2)-(y(1).*y(2)))]; % Add eps to avoid division by zero
end
% Define the boundary conditions
function res = bc(ya,yb)
res = [ya(1); yb(2)]; % F(0) = 0, F'(inf) = 0
end
% Initial guess for the solution
function y = guess(x)
% Use a cubic polynomial that satisfies the boundary conditions
y = [(x/10).^3; 3*(x/10).^2/10];
end
Thanks,
Ayush
0 Comments
See Also
Categories
Find more on Ordinary Differential Equations 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!