# How to determine the parameter in a differential equation with some fixed solution

Assuming that I have a ODE system with undetermined parameter $$x''(t) == y(t) x(t)$$ $$y'(t) == 2 - a x(t)$$

and I have some fixed solution condition $$x(0)=0$$ $$x(10)=8$$ $$y(10)=3.5$$

Is there a way to determine the parameter a, I tried to solve this ODEs with both NDSolve and DSolve, but it seems not to work.

 NDSolve[{x''[t] == y[t] x[t], y'[t] == 2 - a x[t], x[0] == 0,
x[10] == 8, y[10] == 3.5}, {x, y}, t]


the output is

NDSolve::ndnum: Encountered non-numerical value for a derivative at t == 0..

can somebody help me? Thank you very much.

• In order to determine a you need one more condition. Three conditions are required to solve the differential equations for a particular parameter, since you've got (effectively) a third-order ordinary differential equation. – march Sep 4 '15 at 2:39
• Hi, @march thank you very much, I have tried to add another condition, such as $y(0)=2.5$. However, the same problem still exist. – Zihu Guo Sep 4 '15 at 7:48
• @ZihuGuo Do u have any conditions on the parameter "a"? – thils Sep 4 '15 at 8:02
• @thils a is a real number – Zihu Guo Sep 4 '15 at 8:15

As a first step:

sol = ParametricNDSolve[{x''[t] == y[t] x[t], y'[t] == 2 - a x[t],
x[0] == 0, x[10] == 8, y[10] == 3.5}, {x, y}, {t, 0, 10}, {a}]


For example a = 1, you can plot

 {Plot[x[a][t] /. a -> 1 /. sol, {t, 0, 10}],
Plot[y[a][t] /. a -> 1 /. sol, {t, 0, 10}]}


To determine a, the following plots can help:

Plot[Evaluate[Table[y[a][t] /. sol, {a, -1, 1}]], {t, 0, 10},
PlotRange -> All, PlotLegends -> Automatic]


Plot[Evaluate[Table[x[a][t] /. sol, {a, -1, 1}]], {t, 0, 10},
PlotRange -> All, PlotLegends -> Automatic]


If you are playing with the value a then verify the bcs and ics! You never get y[0]==2.5

• ， Thank you very much, it is fantastic. But I am afraid it is not a general method. In this example, I just have one parameter a to determine. However, I probably have several parameters to determine in my real problem. – Zihu Guo Sep 4 '15 at 13:44
• @Zihu Guo ParametricNDSolve can work with many Parameters. With the plots you can easily ascertain, if the conditions are complied. – user31001 Sep 4 '15 at 13:58
• thank you very much, I will try this on my problem. – Zihu Guo Sep 4 '15 at 14:20

As an extension to the Answer by Willinski, only limited ranges of a are consistent with the boundary conditions in the Question. So, for instance,

Plot[x[a][10] /. s, {a, -3, 1}]


generates

along with a number of error messages. Consistent with this figure, Willinsi's plots show that a == -1 and a == 0 satisfy the boundary condition x[10] == 8, but a == 1 does not. Warning: Some details of my figure may be incorrect, because Plot samples the function only at a discrete number of points.

Within the wide range for which the figure above shows x[10] == 8 to be satisfied, it is straightforward to obtain y[0], for instance, as a function of a.

ParametricPlot[{a, y[a][0] /. s}, {a, -2.9, -0.6}, AxesLabel -> {"a", "y[0]"}]


One might hope that a could be computed for a particular value of y[0] using the method described in Boundary Value Problems with Parameters.

ss = NDSolve[{x''[t] == y[t] x[t], y'[t] == 2 - a[t] x[t], a'[t] == 0,
x[0] == 0, x[10] == 8, y[0] == -24, y[10] == 3.5}, {x, y, a}, t]
`

Unfortunately, this procedure does not work here, generating error message and an answer that does not satisfy the boundary conditions.