# Wrong ODE solution in Mathematica 7?

Discussion in 'Mathematica' started by Zsolt, Jan 4, 2010.

1. ### ZsoltGuest

Hi!
I tried solve the ODE:
DSolve[D[y[x], x, x] == -Cos[x]/(1 + Sin[x])^2, y[x], x]

The solution what M7 (and Wolfram Alpha) gives is:
y[x] -> C + x C + (2 Sin[x/2])/(Cos[x/2] + Sin[x/2])

I think, it's wrong! (Does anybody know how to check?) Another system gives
for the same diff.eq:
y(x) = -2/(tan((1/2)*x)+1)+_C1*x+_C2
(similar, but not the same->ctan vs tan...)
I found the problem in one of my math books, and the solution there
concours with the other system.
How can I trust Mathematica, if it makes mistakes in such simple
things?? Thank you for your answer! Zsolt, Jan 4, 2010

2. ### dhGuest

Hi,

both are correct. You may check this by calculating the second

derivative of both expressions and show that they are equal:

D[-2/(Tan[(1/2)*x] + 1), {x, 2}] ==

D[(2 Sin[x/2])/(Cos[x/2] + Sin[x/2]), {x, 2}] // Simplify

Daniel

dh, Jan 5, 2010

3. ### Kevin J. McCannGuest

If you take the second derivative of your answer and compare it with the
rhs you will see that it is true, i.e.

Y''[x]== -Cos[x]/(1 + Sin[x])^2//FullSimplify

Kevin J. McCann, Jan 5, 2010
4. ### Peter BreitfeldGuest

There is no mistake, because the solutions are equivalent.

Mathematica solution:
f[x_]=C + x*C + (2*Sin[x/2])/(Cos[x/2] + Sin[x/2])

Other solution:
g[x_]= B + A*x - 2/(1 + Tan[x/2])

Comparison:
f[x]-g[x] //FullSimplify

Out= 2 - B - A x + C + x C

So the solutions are identical, supposed you choose A=C and B=2+C
as integration constants.

Peter Breitfeld, Jan 5, 2010
5. ### Alois SteindlGuest

Hello,
what makes you think, that this solution is wrong?
You should know, that the same function can often be written in many
different ways.

To check the solution, you could simply compare the plots of its 2nd derivative
and the right hand side of the ODE or use TrigExpand[] on both functions
and their difference.

Alois

Alois Steindl, Jan 5, 2010