Daily Archives: October 6, 2018

You say, “y” I say, “y[x]”



You see things; and you say “Why?”

But I dream things that never were; and I say “Why not?”

George Bernard Shaw in Back to Methuselah


The Wolfram Language function DSolve and NDSolve can solve differential equations.

Let’s look at a few examples.

Example 1 Solving an ODE symbolically. The solution, a function, is evaluated at a given point.

Screen Shot 2018-10-06 at 8.55.21 PM.png

Example 2 Solving an ODE symbolically. Redefine a function and evaluate it at a given point.

Screen Shot 2018-10-06 at 8.52.38 PM.png

Example 3 Solving an ODE initial-value problem symbolically. Get the value at a given point from the symbolic solution.

Screen Shot 2018-10-06 at 8.44.42 PM.png

Example 4 Solving an ODE initial-value problem numerically. Get the value at a given point from the numerical solution.

Screen Shot 2018-10-06 at 8.57.59 PM.png

Regarding whether to specify ‘y‘ or ‘y[x]‘ in DSolve, the only decent explanation I can find is in Stephen Wolfram’s book “The Mathematica Book”. This is straight from horse’s mouth:

When you ask DSolve to get you a solution for y[x], the rule it returns specify how to replace y[x] in any expression. However, these rules do not specify how to replace objects such as y'[x]. If you want to manipulate solutions that you get from DSolve, you will often find it better to ask for solutions for y, rather than y[x].

He then proceeds to give an illustration:

Screen Shot 2018-10-07 at 12.30.46 AM.png

Had you started with DSolve[y'[x]==x+y[x], y[x], x], the result would be

Screen Shot 2018-10-07 at 12.34.12 AM.png

As expected, only y[x] is replaced.