0
$\begingroup$

In Mathematica's documentation on interpolating functions, they give an example of how to obtain an interpolating function as a solution of NDSolve,

ifun = First[
  u /. NDSolve[{u''[t] + u[t] == 0, u[0] == 0, u'[0] == 1}, 
    u, {t, 0, \[Pi]}]]

I would like to do something similar, but with two functions. For example, NDSolve might look something like

NDSolve[{u'[t] + v[t] == 0, v'[t] + u[t] == 0, u[0] == 0, v[0] == 1}, 
        {u, v}, {t, 0, \[Pi]}]]

This returns a list of two interpolating functions, but I'm just a bit confused by how to turn that into two functions that can be called like normal functions. Thanks!

$\endgroup$

1 Answer 1

1
$\begingroup$
sol = NDSolve[{u'[t] + v[t] == 0, v'[t] + u[t] == 0, u[0] == 0, v[0] == 1}, 
       {u, v}, {t, 0, \[Pi]}]

{{u, v}} = {u, v} /. sol

Plot[{u[x], v[x]}, {x, 0, Pi}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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