# Singular Jacobian in bvp4c while Mathematica has no problem

6 views (last 30 days)
Alexander Erlich on 6 Dec 2021
Edited: Torsten on 28 Dec 2021
Hi,
I am trying to solve the following boundary value problem: , with boundary conditions at and at . The parameters are all positive real numbers and .
Sadly, Matlab gives me the classic error: Unable to solve the collocation equations -- a singular Jacobian encountered. I paste my code below.
Note that there is no particular reason this should be ill behaved for , the system has an analytical solution which is regular over the mentioned interval. Mathematica's boundary value problem solver has no problem: A=0.1;
B=7;
mu=1;
gammaR=2;
gammaTheta=5;
solinit = bvpinit( linspace(A,B,100),@(x)guess(x, gammaR, gammaTheta, B, mu));
sol = bvp4c(@(x,y)bvpfcn(x,y, gammaR, gammaTheta, mu), @(ya, yb)bcfcn(ya,yb, A), solinit);
--------------
function dydx = bvpfcn(x,y, gammaR, gammaTheta, mu)
dydx = zeros(2,1);
dydx = [gammaR*gammaTheta*x/y(1)
2*mu*gammaR/(x*gammaTheta)*(1-x^4*gammaTheta^4/y(1)^4 )];
end
--------------
function res = bcfcn(ya,yb, A)
res = [ya(1)-A
yb(1)];
end
--------------
function g = guess(x, gammaR, gammaTheta, B, mu)
g = [mu*(gammaR/gammaTheta - gammaTheta / gammaR)*log(x/B)
x*sqrt(gammaR*gammaTheta)];
end
Torsten on 28 Dec 2021
Edited: Torsten on 28 Dec 2021
function res = bcfcn(ya,yb, A)
res = [ya(1)-A
yb(2)];
...
end

### Categories

Find more on Boundary Value Problems 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!