# Solving Differential Equation depending on variables solved by NDSolve

How to solve a differential equation which consists of variables depending upon another differential equation?

-
At least give an example problem which shows you really have a problem at hand and you tried something already ... – PlatoManiac Sep 25 '12 at 16:09
@Julia - Begging doesn't help. There are enough competent people here willing to help you, but something has to come from you. Provide an example of what you want to do and what you already tried. – stevenvh Sep 25 '12 at 16:24
@Julia, welcome to this site! I'd like to suggest you that when you post a question, be prepared to stay online at least for an hour or so, answering comments, commenting on answers and editing your question. That way you'll receive quicker and better answers – Dr. belisarius Sep 25 '12 at 16:41

NDSolve doesn't yield a symbolic solution so you can't directly derive variable values from it. If you have an idea of the solution you could try to fit the output of NDSolve to that model.

If your question is "Can I use the numerical solution from a NDSolve in an DSolve?" the answer is "Yes, sort of".

Let's demonstrate this with an example.

A simple harmonic oscillator can be specified with this DE: y''[t] == -y[t]. With some boundary and initial conditions it can be solved both numerically and symbolically:

g[t_] = y[t] /. First@NDSolve[{y''[t] == -y[t], y[0] == 0, y'[0] == 1}, y[t], {t, 0, 30}]


h[t_] = y[t] /. First@DSolve[{y''[t] == -y[t], y[0] == 0, y'[0] == 1}, y[t], t]


Sin[t]

A simple driven harmonic oscillator is given by: y''[t] == -k^2 y[t] + d[t] where d[t] is the driving force function. Let's have the driven harmonic oscillator be driven by another harmonic oscillator. Let's pick k^2=2.

In a pure symbolic situation (symbolically solved driven oscillator + symbolically solved driver h[t]) this would lead to the following:

solDD[t_] = y[t] /. First@DSolve[{y''[t] == -2 y[t] + h[t], y[0] == 0, y'[0] == 1}, y[t], t]


Cos[Sqrt[2] t]^2 Sin[t] + Sin[t] Sin[Sqrt[2] t]^2

In a pure numerical situation (numerically solved driven oscillator + numerically solved driver g[t]) we get:

solNN[t_] =
y[t] /. First@NDSolve[{y''[t] == -2 y[t] + g[t], y[0] == 0, y'[0] == 1}, y[t], {t, 1, 30}]


These two are easily plotted and appear identical:

 Plot[{solDD[t], solNN[t]}, {t, 0, 30}]


A mixed situation (symbolically solved driven oscillator + numerically solved driver g[t]), which seems to be the target of your question yields:

solDN[t_] = y[t] /. First@DSolve[{y''[t] == -2 y[t] + g[t], y[0] == 0, y'[0] == 1}, y[t], t]


This result can be readily evaluated or plotted, though the latter will be fairly slow because a numerical integral needs to be calculated for every single point in the plot.

The following plot took an estimated 15 minutes, but is the same as the two above.

-
Thanks ..I will keep in mind to frame the question properly – student_curious Sep 26 '12 at 5:00