Second derivative from Mathematica is wrong!

Hellow everyone,

I have this very strange phenomenon happening on my computer. When I try to calculate a simple ODE

DSolve[{y''[x] == y[x]}, y[x], x]

It outputs

DSolve[{True}, y[x], x]

with an error message Equation or list of equations expected instead of True in the first argument {True}

I looked deeper and I found the following. If I do

D[y[x], {x, 1}]

I get

Derivative[1][y][x]

, which is correct.
But if I do

D[y[x], {x, 2}]

I get

y[x]

And if I do

D[y[x], {x, 3}]

I get

Derivative[1][y][x]

again! It shows that whenever I do a second derivative on my Mathematica, it always gives me the original function back. Am I doing something wrong here? Or is there anything I can fix this problem?

Thanks for reading.

Tom

By the way, I am using a student version of Mathematica 9. Version number 9.0.1.0, on a 64bit Linux machine.

Looks like you’ve accidentaly assigned a value to Derivative:

(* How the y''[x] expression looks without nice syntax: *)
y''[x]//FullForm
(* Derivative[2][y][x] *)

DSolve[{y''[x] == y[x]}, y[x], x]
(* {{y[x] -> E^x C[1] + E^-x C[2]}} *)

y''[x] = whoops
D[y[x], {x, 2}]
(* whoops *)

whoops = y[x]
D[y[x], {x,2}]
(* y[x] *)

(* Let's try to fix it by clearing y *)
ClearAll[y];
D[y[x], {x,2}]
(* y[x] didn't work *)


(* Clear the strange definition by: *)
y''[x]=.
D[y[x], {x,2}]
(* y''[x] *)

What goes wrong is the assignment to y’’ which is easier to understand by remembering the FullForm:

Derivative[2][y][x] = something

making all kinds of strange things happen.

Restart Mathematica, type exactly and only this into a notebook, nothing more, nothing less

DSolve[{y''[x] == y[x]}, y[x], x]

followed by shift and enter and I get this

{{y[x] -> E^x C[1] + E^-x C[2]}}

I suspect the reason for what you saw was that you had previously somehow assigned values to some variables or functions. Mathematica does not make that obvious and the results can be very confusing. Sometimes restarting will resolve this. Sometimes using the menu to quit the kernel will resolve this.

Simon, I believe I figured out why that happened. In my first attempt to use the DSolve routine, I mistakenly used ‘=’ for ‘==’. That assignment side effect ruin all later computations.

Thank you guys. Now the expressions work perfectly! I am still new to the language so sorry for the silliness :stuck_out_tongue:

Best regards,
Tom