0
$\begingroup$

As a neophyte, I'm trying to manipulate the result of a differential equation but I have no idea how to do so.

Here is the equation:

v'[t] + (k v[t]/m) == g

I know how to find the solution, which is given by:

soln = DSolve[{v'[t] + (k/m) v[t] == g, v[0] == 0}, v[t], t]

But after that I am lost. Can someone tell me what should I do if I want to use the results returned by DSolve in further computations?

$\endgroup$
  • $\begingroup$ I transcribed the code from your screenshots into your question, please look over it to make sure it's correct. Typically you use soln by using it for a replacement. For example, to find v[t] at t == 6, you'd type v[6] /. soln (/. is a shorthand for ReplaceAll). $\endgroup$ – eyorble Feb 23 '19 at 0:55
  • 1
    $\begingroup$ In what way are you seeking to manipulate the solution? $\endgroup$ – Edmund Feb 23 '19 at 1:09
  • $\begingroup$ Note the manipulate tag is for questions about the use of the function Manipulate[]. If that's what you have in mind, you should clarify and indicate how you want to use the solution in it. $\endgroup$ – Michael E2 Feb 23 '19 at 2:07
1
$\begingroup$

What exactly you mean by manipulate?

Nevertheless, here are some common examples users ask about further use of DSolve output.

Eq = v'[t] + (k v[t]/m) == g

soln = v[t] /. DSolve[{Eq, v[0] == 0}, v[t], t][[1]]

$\frac{(E^{(-((k t)/m))} (-1 + E^{((k t)/m))} g m)}{k}$

The solution is assigned to soln, now you can use it for further manipulations. For example,

Table[{t, soln /. {g -> 9.8, k -> 1, m -> 1}}, {t, 0, 10}]

or

Plot[soln /. {g -> 9.8, k -> 1, m -> 1}, {t, 0, 10}]
|improve this answer|||||
$\endgroup$
  • $\begingroup$ Thanks! I was thinking of something like that but my teacher told me to use Manipulate, probably to vary the value of g,m and k and see what happens. $\endgroup$ – GalloMathematico Feb 24 '19 at 13:33
  • $\begingroup$ @GalloMathematico OK! But it was not clear from your question. $\endgroup$ – zhk Feb 24 '19 at 13:34
0
$\begingroup$

Here' my standard workflow for a simple ODE exercise:

eqnExample1 = 
 x'[t] == 6 - (6/1000 x[t]) (*NB x'[t]*)
initValExample1 = x[0] == 0
solExample1 = DSolve[{eqnExample1, {initValExample1}}, x[t], t]
solExample1Function[t_] = solExample1[[1, 1, 2]] (* note = NOT := *)
Plot[{500, solExample1Function[t]}, {t, 0, 200}]
Solve[solExample1Function[t] == 500, t, Reals][[1, 1, 2]] /. 
  C[1] -> 1 // N
Print["Note the function is concave down so should approach a \
limiting value:"]
Limit[solExample1Function[t], t -> Infinity]

but i'm merely an egg at both mma and ODEs...

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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