       Re: Wrong ODE solution in Mathematica 7?

• To: mathgroup at smc.vnet.net
• Subject: [mg106211] Re: [mg106177] Wrong ODE solution in Mathematica 7?
• From: DrMajorBob <btreat1 at austin.rr.com>
• Date: Tue, 5 Jan 2010 01:45:27 -0500 (EST)
• References: <201001041058.FAA21179@smc.vnet.net>

```Here are the two solutions:

y1[x_] = y[x] /.
First@DSolve[D[y[x], x, x] == -Cos[x]/(1 + Sin[x])^2, y[x], x]

C + x C + (2 Sin[x/2])/(Cos[x/2] + Sin[x/2])

y2[x_] = -2/(Tan[(1/2)*x] + 1) + C*x + C

x C + C - 2/(1 + Tan[x/2])

error[x_] = y1[x] - y2[x] // Simplify

2 + C + x (C - C) - C

Now take the second derivative:

D[error@x, x, x]

0

or...

d1 = D[y1@x, x, x] // Simplify

(-Cos[x/2] + Sin[x/2])/(Cos[x/2] + Sin[x/2])^3

d2 = D[y2@x, x, x] // TrigExpand // Simplify

(-Cos[x/2] + Sin[x/2])/(Cos[x/2] + Sin[x/2])^3

d1 == d2

True

Hence, both functions have the same second derivative. If either solves
the problem, both of them do.

Does either of them solve it? Simplify says, "Yes!"

d1 == d2 == -Cos[x]/(1 + Sin[x])^2 // Simplify

True

To verify it in a more transparent manner:

-(Cos[x]/(1 + Sin[x])^2) /. x -> 2 y;
% // TrigExpand;
% // Together;
% /. y -> x/2
d1 === %

(-Cos[x/2] + Sin[x/2])/(Cos[x/2] + Sin[x/2])^3

True

TrigExpand applied double angle rules, and Together combined two fractions
with the same denominator.

Bobby

On Mon, 04 Jan 2010 04:58:48 -0600, Zsolt <phyhari at gmail.com> wrote:

> 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?? :(