1
$\begingroup$

I am solving a system of non-linear ODEs but I get the error message:

Cannot find starting value for the variable f'

This is the code:

sol = 
  NDSolve[
    {h'[t] == -2 f[t], 
     f''[t] == -(g[t])^2 + (f[t])^2 + f'[t] h[t], 
     g''[t] == 2 f[t] g[t] + h[t] g'[t], 
     p'[t] == 2 f[t] h[t] - 2 f'[t], 
     f[0] == h[0] == p[0] == 0, g[0] == 1, 
     f[Infinity] == 0, g[Infinity] == 0}, 
    {f, h, g, p}, {t, 0, Infinity}]

Please I need your help.

$\endgroup$
6
  • 1
    $\begingroup$ Are you not missing some initial conditions like that of first derivatives of f and g? $\endgroup$
    – Subho
    May 3, 2018 at 14:24
  • $\begingroup$ No ... These are the boundary conditions I have ... I have the exact numerical solution in my course textbook, but I am required to solve these equations numerically and compare the results $\endgroup$
    – Muhammad
    May 3, 2018 at 14:28
  • 1
    $\begingroup$ @Subho95 No the OP does not miss it. Even if yes, I tried to change the conditions for usual ones, say placing f'[0]==0 instead of the used f[Infinity] == 0. The outcome is invariable. @Muhammad, what system/version do you use? If I put the both conditions to f'[0] == 0, g'[0] == 0 everything starts working. $\endgroup$ May 3, 2018 at 14:29
  • $\begingroup$ @Subho95 In the book, it is written that: To solve these equations numerically, you should start with correct guess values of f' and g' that makes f and g zero at infinity. $\endgroup$
    – Muhammad
    May 3, 2018 at 14:30
  • $\begingroup$ @Alexei Boulbitch I am using Mathematica 11.3 on win7 x64 $\endgroup$
    – Muhammad
    May 3, 2018 at 14:31

1 Answer 1

4
$\begingroup$

EDITED:5.5.2018

This boundary conditions: f'[0] == 510/1000, g'[0] == -609/1000, I'm searched by brute-force and help with Maple 2018.

sol2 = With[{inf = 47}, 
NDSolve[{h'[t] == -2*f[t], 
f''[t] == -(g[t])^2 + (f[t])^2 + f'[t]*h[t], 
g''[t] == 2*f[t]*g[t] + h[t]*g'[t], 
p'[t] == 2 f[t]*h[t] - 2 f'[t], f[0] == h[0] == p[0] == 0, 
g[0] == 1, f[inf] == 0, g[inf] == 0}, {f, h, g, p}, {t, 0, inf}, 
Method -> {"BoundaryValues" -> {"Shooting", 
"StartingInitialConditions" -> {f[0] == h[0] == p[0] == 0, 
g[0] == 1, f'[0] == 510/1000, g'[0] == -609/1000}}}, 
WorkingPrecision -> 20, MaxSteps -> Infinity]];

Plot[Evaluate[{f[t], h[t], g[t], p[t]} /. sol2], {t, 0, 47}, 
PlotLegends -> {"f[t]", "h[t]", "g[t]", "p[t]"}, PlotRange -> All]

enter image description here

Check initial and boundary conditions at: t = 0

{f[t], h[t], g[t], p[t]} /. sol /. t -> 0
(* {{0.*10^-25, 0.*10^-30, 1.0000000000000000000, 0.*10^-25}} *)

at: t = 47

{f[t], h[t], g[t], p[t]} /. sol /. t -> 47
(* {{7.5261038817*10^-11, 0.00014222313818378259662, -1.53486450848720*10^-10,-1.0043080818308*10^-8}} *)
$\endgroup$
3
  • $\begingroup$ Thank you very much. It works but only for inf = 6, and the problem is that I am required to compare my results with another solution that has numeric values at inf greater than 10. How can I work with inf = 15 for example? $\endgroup$
    – Muhammad
    May 4, 2018 at 12:49
  • $\begingroup$ Can you help please? @Mariusz Iwaniuk $\endgroup$
    – Muhammad
    May 4, 2018 at 19:24
  • $\begingroup$ @Muhammad.I edited my Answer. $\endgroup$ May 5, 2018 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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