Why do I receive Jacobian singular error while solving second order differential equation with boundary conditions?

1 次查看(过去 30 天)
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);
Error using bvp4c
Unable to solve the collocation equations -- a singular Jacobian encountered.
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!

采纳的回答

Torsten
Torsten 2024-1-2
编辑:Torsten 2024-1-2
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)
sol = 
conds = [y(0)==0,df(0)==0];
sol = dsolve(ode,conds)
sol = 
0

更多回答(1 个)

Ayush
Ayush 2024-1-2
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

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by