# A system of ODE's with one less initial condition

I have a system of two ODE's, each of order 2 with three initial conditions. One of the condition is of the form f(0)+g(0)=1, which is the main reason that NDSolve is unable to find the solution.

Here the system with the initial conditions,

ode1 = f''[x] + (f[x] + g[x])*f'[x] == 0
ode2 = g''[x] + (f[x] + g[x])*g'[x] == 0
ics = {f + g == 1, f' == 0, g' == 1};
system = {ode1, ode2}
NDSolve[Join[system, ics], {f[x], g[x]}, {x, 0, 5}]


NDSolve::ndnco: The number of constraints (3) (initial conditions) is not equal to the total differential order of the system plus the number of discrete variables (4)

How we can handle such situation?

Then there should be infinite solutions. Let's introduce a parameter:

ode1 = f''[x] + (f[x] + g[x])*f'[x] == 0;
ode2 = g''[x] + (f[x] + g[x])*g'[x] == 0;
ics = {f + g == 1, f' == 0, g' == 1};
system = {ode1, ode2};
{solf, solg} =
ParametricNDSolve[{system, ics, f == a}, {f, g}, {x, 0, 5}, a][[All, -1]];

Manipulate[Plot[{solf[a][x], solg[a][x]}, {x, 0, 5}, PlotRange -> 7], {a, -5, 5}] • How I will know that what value of a is the correct one? – zhk Oct 27 '16 at 14:06
• @mmm Well, as said above, with only 3 boundary conditions, this equation set owns infinite possible solutions, so every value of a points to a valid solution, there's no incorrect a. – xzczd Oct 27 '16 at 14:16
• If I understood you correctly, then we can take f(0)=a and g(0)=1-a where $a\in R$? – zhk Oct 27 '16 at 14:21
• @mmm Actually a can even be a complex number. – xzczd Oct 27 '16 at 14:25

Perhaps define an interim function h[x]?

ode1 = f''[x] + h[x]*f'[x] == 0
ode2 = g''[x] + h[x]*g'[x] == 0
ode3 = h[x] == f[x] + g[x]
ics = {h == 1, f' == 0, g' == 1};
system = {ode1, ode2, ode3}
soln = NDSolve[Join[system, ics], {f[x], g[x]}, {x, 0, 5}]


{ {f[x] -> InterpolatingFunction[{{0., 5.}}, <>][x], g[x] -> InterpolatingFunction[{{0., 5.}}, <>][x]} }

Plot[{f[x], g[x]} /. soln, {x, 0, 5}] • Interesting, seems that NDSolve has introduced an artificial boundary f == 0.5 silently in this case, but there should be infinite solutions actually, see my answer. – xzczd Oct 27 '16 at 14:02