Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Can somebody explain this notation to me? Using Mathematica's first example in the NDSolve documentation:

s = NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 30}]

The output is:

{{y -> InterpolatingFunction[{{0.,30.}}, <>]}}

What do all the curly brackets and the angle signs indicate? Why is there no indication of dependence on x?

I'm also curious why you have to use this result in what I consider to be an awkward way:

Plot[Evaluate[y[x] /. s], {x, 0, 30}, PlotRange -> All]

as opposed to simply:

Plot[s, {x, 0, 30}, PlotRange -> All]
share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

The angle signs mean that you're looking at a shorthanded expression. Take a look at

FullForm[s]

to see the real thing.

The curly braces are there because NDSolve is going to give you consistently formatted results whether you look for only one function with only one solution or your solution involves more than one function, and more than one possible set.

As for the Evaluate thing inside the Plot isn't really needed, although in my opinion shows clearly what you're doing. In any case, if that disturbs you, you may do:

Plot[s[[1, 1, 2]][x], {x, 0, 30}, PlotRange -> All]

Edit:

The form of s is

s == {{y->InterpolatingFunction[{{0.,30.}},<>]}}

So

s[[1]] == {y->InterpolatingFunction[{{0.,30.}},<>]}

and

s[[1,1]] == y->InterpolatingFunction[{{0.,30.}},<>]

further

s[[1,1,2]] == InterpolatingFunction[{{0.,30.}},<>]

and that's why we are plotting s[[1, 1, 2]]

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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