# NDSolve with shooting method

Here are my equations:

eq1 = f'''[t] + (f[t] + g[t])*f''[t] - (f'[t])^2 == 0;
eq2 = g'''[t] + (f[t] + g[t])*g''[t] - (g'[t])^2 == 0;
eq3 = θ''[t] + (f[t] + g[t])*.7*θ'[t] == 0;    ic1 = f == s;
ic2 = g == 0;
ic3 = f' == λ;
ic4 = g' == λ1;
ic5 = θ == 1;
ic6 = f'[η] == 0;
ic7 = g'[η] == 0;
ic8 = θ[η] == 0;
equations = {eq1, eq2, eq3};
initialconditions = {ic1, ic2, ic3, ic4, ic5, ic6, ic7, ic8};


and the solution method:

s4 = Table[{λ, f'' /.  NDSolve[Join[equations,
initialconditions /. {λ1 -> -0.5, η -> 5, s -> 4}], {f'', g', θ}, {t, 0, 20},
Method -> {"Shooting", "StartingInitialConditions" -> {f == 4, f' == -1,
f'' == 20, g == 0, g' == -0.5, g'' == 0, θ == 1,
θ' == 0}}][]}, {λ, -3.70, 0, 0.01}];
s42 = Table[{λ, f'' /. NDSolve[Join[equations,
initialconditions /. {λ1 -> -0.5, η -> 20, s -> 4}], {f'', g, θ}, {t, 0, 20}][]},
{λ, -3.70, 0, 0.1}]

ListPlot[{s4, s42},
PlotStyle -> {Red, {Red, Dashed}, Purple, {Purple, Dashed},
Cyan, {Cyan, Dashed}}, Joined -> True,
AxesLabel -> {Style ["\[Lambda]", 20], Style["f''(0)", 18]},
AspectRatio -> .7, PlotRange -> All]


and I get the following results: how can I remove the noises to get the following results? • It takes forever on my machine to execute s4. I don't why. – zhk May 29 '15 at 8:28
• It takes about 2 minute to solve. you can change {-3.7,0,0.01} to {-3.7,0,0.1} to speedup – Mahdi Erfanian May 29 '15 at 9:20
• why are you not using the shooting method for the problematic solution? – george2079 May 29 '15 at 20:43

The second curve is irregular, because the s42 calculation yields the desired second solution for some values of λ and the first solution for others. To obtain only the desired second solution, use

s42 = Table[{λ, f'' /. NDSolve[{equations,
initialconditions /. {λ1 -> -0.5, η -> 20, s -> 4}}, {f'', g', θ}, {t, 0, 20},
Method -> {"Shooting", "StartingInitialConditions" -> {f == 4, f' == -1,
f'' == .6 λ^2 - 6, g == 0, g' == -0.5, g'' == 1.6, θ == 1,
θ' == -2.1}}][]}, {λ, -3.70, 0, 0.1}] The challenge, of course, is to provide "StartingInitialConditions" for f'', g'', and θ'. A bit of experimentation led to the f'' expression, while the second and third were obtained by computing their more or less constant values from the second solution for λ < -2.5.

Note that in the Question η -> 5 for s4, and η -> 20 for s42. Probably, the values should be the same for meaningful comparison. Also, computing s4 is exceedingly slow due to its 0.01 step size. Instead, I used this small step size only for -3.7 < λ < -3.5, and 0.1 otherwise. Finally, it is not necessary to use Join.

• Can you share the modified code. Pl. subhrasmitamohanty98@gmail.com – smohanty Feb 21 '19 at 15:17
• @smohanty To what modified code are you referring? – bbgodfrey Feb 21 '19 at 16:24