# Singular Jacobian using bvp4c

11 Ansichten (letzte 30 Tage)
Marcus Rosales am 3 Feb. 2024
Beantwortet: Neelanshu am 29 Feb. 2024
I know similar questions have been asked, but I am wondering if there any tricks to help out here. I've tried changing variables, but the divergence just moves around...
I am trying to solve a second order equation, given in the screen shot below, and the associated code is attached:
I did not impose the condition f>=0, so maybe that is my issue? The hyperbolic tanh might also be a good initial guess, but I was relying on the Sxint = deval() to get me started. Any obvious problems? Thanks in advanced for any help!
xl = 0;
xr = 10;
[Sxint, xint] =bvp4c_mathworks_Abrikosov(xl,xr);
Error using bvp4c
Unable to solve the collocation equations -- a singular Jacobian encountered.

Error in solution>bvp4c_mathworks_Abrikosov (line 13)
sol = bvp4c(@myode,@mybc,solinit);
plot(xint,Sxint)
function [Sxint, xint] =bvp4c_mathworks_Abrikosov(xl,xr)
N = 500;
xint = linspace(xl,xr,N);
solinit = bvpinit(xint,[0 0]);
sol = bvp4c(@myode,@mybc,solinit);
Sxint = deval(sol,xint);
end
function dy = myode(r,y)
k = 1/sqrt(1.8);
dy(1,1) = y(2);
dy(2,1) = k^2*(y(1)^2-1)*y(1)+y(1)/r^2-y(2)/r;
end
function res = mybc(ya,yb)
res = [ya(1)
yb(1)-1];
end
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Antworten (1)

Neelanshu am 29 Feb. 2024
Hello Marcus,
I understand that you're encountering the "Singular Jacobian using bvp4c" error while attempting to solve a boundary value problem.
Upon inspecting the code, it appears that the issue arises when the function 'myode' is called with the value of 'r' being zero, as shown:
This results in the computation of 'dy(2,1)' to be 'NaN' because it involves division of zero by zero, which leads to the error you're experiencing. To rectify this, you should either initialize 'r' with a non-zero value or adjust the formula used to compute 'dy(2,1)' to handle the case when 'r' is zero.
Hope this helps.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Boundary Value Problems finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by