0
$\begingroup$

So I have a 'fairly simple' problem that needs to be 'solved'. I have been able to solve this running 2 loops in Matlab but I am sure Mathematica should be able to handle this. I have the ODE $$F'(x)+\sqrt{a^3 x F(x)}=0$$ subject to the boundary conditions $$F(0)=\dfrac{1}{a} \quad \text{and} \quad F(1)=0.$$ To complicate the problem, $a$ must satify the condition $$\dfrac{1}{a}=2\int_0^1 F dx.$$

First I tried using With to try 'correct' for the unknown value of $a$

eq = F'[x] + Sqrt[ a^3 x F[x]] == 0;
eps = 10^(-6);
With[{a = 2 NIntegrate[F[x], {x, eps, 1}]}, 
  sol = NDSolve[{eq, F[eps] == 1/a}, F, {x, eps, 1}]];

I used eps to avoid any issues at 0. Naturally this approach caused many errors as $a$ was defined using something that hadn't been calculated yet. So I don't even know if this is possible.

My second thought was to use ParametricNDSolveValue but I don't know if it's possible to integrate a parametric numerical solution. Maybe I should take a path similar to here?

Any advice would be greatly appreciated

$\endgroup$
4
  • $\begingroup$ Have you tried Method->"Shooting"? See also reference.wolfram.com/language/tutorial/NDSolveBVP.html $\endgroup$ – Henrik Schumacher Jan 18 '20 at 18:14
  • $\begingroup$ Will it work when the unknown parameter is both in the ODE, and in the BC ? Should I just add the third condition as an equation ? $\endgroup$ – Kendall Jan 18 '20 at 18:46
  • $\begingroup$ Ah, I see now. Hm. Actually I don't know. I guess you just have to give it a try. $\endgroup$ – Henrik Schumacher Jan 18 '20 at 19:05
  • $\begingroup$ Thanks, will tackle it for awhile and see what I can get working. $\endgroup$ – Kendall Jan 18 '20 at 19:07
2
$\begingroup$

Let DSolve do the job.

eq = F'[x] + Sqrt[ a^3 x F[x]] == 0; 

dsol = DSolve[{eq, F[1] == 0}, F, x]

(*   {{F -> Function[{x}, 1/9 (a^3 - 2 a^3 x^(3/2) + a^3 x^3)]}}   *)

sol = Solve[1/a == 2 Integrate[F[x] /. First@dsol, {x, 0, 1}], a, Reals]

(*   {{a -> -10^(1/4)}, {a -> 10^(1/4)}}   *)

Fsol[x_] = F[x] /. First@dsol /. sol[[2]] // FullSimplify

(*   1/9 10^(3/4) (-1 + x^(3/2))^2   *)

But you get contradiction with initial conditions:

Fsol[0] == 1/a /. sol

(*   {False, False}   *)
$\endgroup$
2
  • $\begingroup$ Thank you for this answer. I know an analytic solution to this equation exists, that's why I chose it. What I am aiming for, is a numerical solution using a shooting method so I can compare the numerical solution to the analytic one. I was able to do this in matlab but I would like to see if Mathematica can solve it faster. I also realised that initial condition is false. I think it's a typo in the BC's that were given. $\endgroup$ – Kendall Jan 19 '20 at 11:45
  • $\begingroup$ That BC is an initial guess for the shooting method. $\endgroup$ – Kendall Jan 19 '20 at 11:58
0
$\begingroup$

This problem was solved, faster, outside of Mathematica using a FVP RK4 method. I am unaware if such a method has been inbuilt/implemented into NDSolve. If it has been, then the accuracy and duration to calculate such an answer is neither trivial nor fast. This answer serves to close the question.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.