The solution what M7 (and Wolfram Alpha) gives is:
y[x] -> C[1] + x C[2] + (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! :)
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
eq = D[y[x], x, x] == -Cos[x]/(1 + Sin[x])^2
sol = DSolve[eq, y, x]
eq /. sol[[1]] // Simplify
returns True.
So the solution is correct, and if you think about it the difference
between Mathematica's solution and the other one is only a matter of a
difference in the additive constant.
Tony
]-> -----Original Message-----
]-> From: Zsolt [mailto:phy...@gmail.com]
]-> Sent: 04 January 2010 10:59
]-> To: math...@smc.vnet.net
]-> Subject: Wrong ODE solution in Mathematica 7?
]->
]-> 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[1] + x C[2] + (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! :)
]->
]->
Clear[y]
DSolve[y''[x] == -Cos[x]/(1 + Sin[x])^2, y, x][[1, 1]];
y[x_] = y[x] /. %
C[1] + x C[2] + (2 Sin[x/2])/(Cos[x/2] + Sin[x/2])
Check the solution:
y''[x] == -Cos[x]/(1 + Sin[x])^2 // Simplify
True
Here is your second solution:
y2[x_] = C[1] + C[2] x - 2/(Tan[x/2] + 1);
Check it:
y2''[x] == -Cos[x]/(1 + Sin[x])^2 // Simplify
True
Add the constant 2, which could be absorbed into C[1], to the y2 solution
and see if it is equal to the y solution:
y2[x] + 2 == y[x] // Simplify
True
How did I figure out how to add 2? By plotting and trying various constants.
Start out with zero and you can see that you need to shift the second curve
up.
Plot[{(2 Sin[x/2])/(
Cos[x/2] + Sin[x/2]), -(2/(Tan[x/2] + 1)) + 2}, {x, -2 \[Pi],
2 \[Pi]}]
David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/
From: Zsolt [mailto:phy...@gmail.com]
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[1] + x C[2] + (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
Y''[x]== -Cos[x]/(1 + Sin[x])^2//FullSimplify
There is no mistake, because the solutions are equivalent.
Mathematica solution:
f[x_]=C[1] + x*C[2] + (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[1] + x C[2]
So the solutions are identical, supposed you choose A=C[2] and B=2+C[1]
as integration constants.
--
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de
Let's try it:
y[x_] = C[1] + x*C[2] + (2*Sin[x/2])/(Cos[x/2] + Sin[x/2])
y''[x] == -Cos[x]/(1 + Sin[x])^2 // Simplify
True
(I presume you trust that Mathematica knows how to take derivatives and
do simple algebraic and trig simplifications!)
Now what about the solution provided by the "other system"? Let's plug
that in and check:
z[x_] = -2/(Tan[(1/2)*x] + 1) + C1*x + C2
z''[x] == -Cos[x]/(1 + Sin[x])^2 // Simplify
True
Hmm... two solutions for the same 2nd order ODE. If we specify a set of
two initial conditions, we hope the solution will be unique (on some
suitable interval). Let's use the values of the function and its
derivative at 0.
cstRules=First@Solve[{y[0],y'[0]}=={z[0],z'[0]},{C1,C2}]
{C2 -> 2 + C[1], C1 -> C[2]}
w[x_] = z[x] /. cstRules;
w[x] == y[x] // Simplify
True
Tada! I leave it as an exercise to see why the two solutions are just
different forms of the same function.
Zsolt 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[1] + x C[2] + (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! :)
>
--
Murray Eisenberg mur...@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305
y1[x_] = y[x] /.
First@DSolve[D[y[x], x, x] == -Cos[x]/(1 + Sin[x])^2, y[x], x]
C[1] + x C[2] + (2 Sin[x/2])/(Cos[x/2] + Sin[x/2])
y2[x_] = -2/(Tan[(1/2)*x] + 1) + C[3]*x + C[4]
x C[3] + C[4] - 2/(1 + Tan[x/2])
error[x_] = y1[x] - y2[x] // Simplify
2 + C[1] + x (C[2] - C[3]) - C[4]
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 <phy...@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[1] + x C[2] + (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! :)
>
eqn = D[y[x], x, x] == -Cos[x]/(1 + Sin[x])^2;
soln1 = DSolve[eqn, y[x], x][[1, 1]]
y[x] -> C[2]*x + C[1] + (2*Sin[x/2])/(Sin[x/2] + Cos[x/2])
D[y[x] /. soln1, x, x] == (eqn // Last) // Simplify
True
The solution satisfies the equation.
soln2 = (y[x] -> -2/(Tan[(1/2)*x] + 1) + C[4]*x + C[3]);
Series[Evaluate[y[x] /. soln1], {x, 0, 1}] // Normal
(C[2] + 1)*x + C[1]
Series[Evaluate[y[x] /. soln2], {x, 0, 1}] // Normal
(C[4] + 1)*x + C[3] - 2
(y[x] /. soln1) == (y[x] /. soln2 /.
{C[3] -> C[1] + 2,
C[4] -> C[2]}) // Simplify
True
The solutions are equivalent.
Bob Hanlon
---- Zsolt <phy...@gmail.com> wrote:
=============
Your equation can be solved by simply integrating both parts twice over x.
The part with unknown constants emerges as a result of this integration and
is a solution of the homogeneous equation (with the zero r.h.s). Integrating
the r.h.s:
In[1]:= Integrate[-Cos[x]/(1 + Sin[x])^2, x]
Out[1]= 1/(1 + Sin[x])
In[2]:= Integrate[1/(1 + Sin[x]), x]
Out[2]= (2 Sin[x/2])/(Cos[x/2] + Sin[x/2])
The first integral is also trivial to do by hand. One way to do the second
integral manually is to expand Sin :
In[3]:= 1/(1 + Sin[x]) /.
Sin[x] -> 1/(2 I) (Exp[I*x] - Exp[-I*x]) // Simplify
Out[3]= (2 I E^(I x))/(I + E^(I x))^2
By substituting Exp[I*x]->t we have an integral
Integrate[2/(I+t)^2,t], which is trivial. The result is
In[4]:= Integrate[2/(I + t)^2, t] /. t -> Exp[I*x]
Out[4]= -(2/(I + E^(I x)))
This can be simplified to be a desired answer plus a constant (I -1), the
latter can be absorbed in the constant part C[1] of the solution:
In[5]:= FullSimplify[-(2/(I + E^(I x))) - (2 Sin[x/2])/(
Cos[x/2] + Sin[x/2])]
Out[5]= -1 + I
You could also check the final result by a direct differentiation:
In[6]:= D[C[1] + x C[2] + (2 Sin[x/2])/(Cos[x/2] + Sin[x/2]), x,
x] == -Cos[x]/(1 + Sin[x])^2 // FullSimplify
Out[6]= True
As to a seeming discrepancy with the other sources, I think you should pay
more attention to signs. Perhaps, observing this may be helpful:
In[7]:= 1/(1 + Tan[x]) + 1/(1 + Cot[x]) // FullSimplify
Out[7]= 1
As before, constants don't matter - they are absorbed into the definition of
C[1].
Hope this helps.
Regards,
Leonid
> 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[1] + x C[2] + (2 Sin[x/2])/(Cos[x/2] + Sin[x/2])
>
> I think, it's wrong! (Does anybody know how to check?)
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
Bobby
On Tue, 05 Jan 2010 00:42:00 -0600, Tony Harker <a.ha...@ucl.ac.uk> wrote:
> Let Mathematica check it:
>
> eq = D[y[x], x, x] == -Cos[x]/(1 + Sin[x])^2
> sol = DSolve[eq, y, x]
> eq /. sol[[1]] // Simplify
>
> returns True.
>
> So the solution is correct, and if you think about it the difference
> between Mathematica's solution and the other one is only a matter of a
> difference in the additive constant.
>
> Tony
>
> ]-> -----Original Message-----
> ]-> From: Zsolt [mailto:phy...@gmail.com]
> ]-> Sent: 04 January 2010 10:59
> ]-> To: math...@smc.vnet.net
> ]-> Subject: Wrong ODE solution in Mathematica 7?
> ]->
> ]-> 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[1] + x C[2] + (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! :)
> ]->
> ]->
>
>