2

I would like to solve the following equation :

f''+tau(x)*f+f^3=0
f'(0)=0
f(inf)=1

Where tau(x) can be any function of x. The problem is to translate the boundary condition f(inf)=1 into matlab. My first solution, by reading different posts on the web was to approximate infinity by a large finite number but it doesn't give satisfying solution. Here is the code that I use :

function f = solve_GL(tau)

options = bvpset('RelTol', 1e-5);

Xstart = 0;
Xend = 1000;

solinit = bvpinit(linspace(Xstart, Xend, 50), [0, 1]);

sol = bvp4c(@twoode, @twobc, solinit, options);

x = linspace(Xstart,Xend);
y = deval(sol,x);

plot(x,y(1,:))

function dydx = twoode(x,y)
dydx = [y(2); (-heaviside(x-2)+1).*y(1)+y(1).^3];

function res = twobc(ya,yb)
res = [ya(2); yb(1)-1];

If somebody has a solution to this problem, I would be glad to hear it !

  • 1
    You would need that the solution flattens toward infinity so that you actually have some asymptotic behavior. For this you need that 1 is a stationary point at infinity. This only happens if `tau(inf)=-1`, in your code however you have `tau(inf)=0` which only has 0 as stationary point. -- For a numerically sound problem you need that the ODE function is as smooth as the order of the method, but at least continuous. Thus you produce an extra problem for numerical stability by introducing a jump into the ODE. – Lutz Lehmann Oct 01 '15 at 10:52
  • Thank you @LutzL , I changed my tau by a more complex function with `tau(inf)=-1` and it works now, I have beautiful solution ! – William Magrini Oct 01 '15 at 13:51

0 Answers0