Mathematica and Variation of Parameters

  • Thread starter jaseh86
  • Start date
  • #1
37
0
Hi, I was solving the following second order ODE:

[PLAIN]http://www.texify.com/img/%5CLARGE%5C%21x%5E2%20y%5E%27%27-5xy%5E%27%2B5y%3Dx%5E6%20sinx.gif [Broken]

I used variation of parameters and found this solution:

[PLAIN]http://www.texify.com/img/%5CLARGE%5C%21y%3DC_1%20x%20%2B%20C_2%20x%5E5%20-%20180%20x%20Cosx%20%2B%2090%20x%5E3%20Cosx%20-%20%20%207%20x%5E5%20Cosx%20-%20180%20x%5E2%20Sinx%20%2B%2030%20x%5E4%20Sinx%20-%20x%5E6%20Sinx.gif [Broken]

However if I try DSolve in mathematica, the answer I get is instead:

[PLAIN]http://www.texify.com/img/%5CLARGE%5C%21y%5Bx%5D%20-%3E%20x%20C%5B1%5D%20%2B%20x%5E5%20C%5B2%5D%20%2B%206%20x%20Cos%5Bx%5D%20-%203%20x%5E3%20Cos%5Bx%5D%20%2B%206%20x%5E2%20Sin%5Bx%5D%20-%20%20%20x%5E4%20Sin%5Bx%5D.gif [Broken]

Can anyone verify my answer? (Warning: quite long to integrate) Either I'm typing something wrong in mathematica, I miscalculated the solution or mathematica uses the wrong algorithm.

Thanks.
 
Last edited by a moderator:

Answers and Replies

  • #2
37
0
Woops I just realised that none of the equations showed up. Sorry! Let me try again with latex this time.

The equation was:

[tex] x^2 y'' - 5xy' + 5y = x^6 sinx [/tex]



I used variation of parameters by hand and found this solution:

[tex] y = C_1 x + C_2 x^5 -180 x cosx + 90 x^3 cosx - 7 x^5 cosx - 180 x^2 sinx +
30 x^4 sinx - x^6 sinx
[/tex]


However if I try DSolve in mathematica, the answer I get is instead:

[tex] y = C_1 x + C_2 x^5 +6 x cosx - 3 x^3 cosx + 6 x^2 sinx - x^4 sinx
[/tex]

Can anyone verify my answer? (Warning: quite long to integrate) Either I'm typing something wrong in mathematica, I miscalculated the solution or mathematica uses the wrong algorithm.

Thanks.
 
  • #3
1,796
53
This is what I get:

[tex]
\begin{aligned}
&\text{DSolve}[x{}^{\wedge}2 y\text{''}[x]-5 x y'[x]+5 y[x]==x{}^{\wedge}6 \text{Sin}[x],y,x]
\\
&\left\{\left\{y\to \text{Function}\left[\{x\},x C[1]+x^5 C[2]+6 x \text{Cos}[x]-3 x^3 \text{Cos}[x]+6 x^2 \text{Sin}[x]-x^4 \text{Sin}[x]\right]\right\}\right\}
\end{aligned}
[/tex]

And I think it's good you're using Mathematica to confirm or at least get a handle on, your problem. So that's what I got and Mathematica is pretty good at this, probably 99% or better so good chance that's the right answer. So either you can express your answer in terms of this one, or I'd say there is at least a 99% chance your manual calculations are wrong. And there again, Mathematica can help you: do a step manually, then do it in Mathematica. If agree, then continue, if not, probably you made a mistake and need to correct it before going to the next comparison.
 
  • #4
HallsofIvy
Science Advisor
Homework Helper
41,833
956
You will certainly NOT get terms like [itex]x^5cos(x)[/itex] and [itex]x^4sin(x)[/itex].

When I use "variation of parameters" with [itex]y(x)= xu(x)+ x^5v(x)[/itex], I wind up with the equations [itex]v'= (1/4) sin(x)[/itex], which is easy to integrate, and [itex]u'= -(1/4)x^4sin(x)[/itex] which requires a long integration by parts and gives powers of x times sine and cosine but not any powers of x greater than 4.
 
  • #5
1,796
53
You will certainly NOT get terms like [itex]x^5cos(x)[/itex] and [itex]x^4sin(x)[/itex]..
I don't understand this comment. When I back-substitute the Mathematica solution into the DE, I obtain equality:

Code:
In[6]:=
myf[x_] := x*C[1] + x^5*C[2] + 
    6*x*Cos[x] - 3*x^3*Cos[x] + 
    6*x^2*Sin[x] - x^4*Sin[x]; 
FullSimplify[x^2*D[myf[x], {x, 2}] - 
   5*x*D[myf[x], x] + 5*myf[x]]

Out[7]=
x^6*Sin[x]
 
  • #6
37
0
Ah. I figured out where I went wrong. Wow what a silly error.

My answer now agrees with mathematica *phew*.

Thanks for the replies everyone!
 

Related Threads on Mathematica and Variation of Parameters

  • Last Post
Replies
4
Views
3K
  • Last Post
Replies
1
Views
687
  • Last Post
Replies
3
Views
2K
Replies
6
Views
1K
  • Last Post
Replies
1
Views
2K
Replies
0
Views
883
  • Last Post
Replies
4
Views
2K
  • Last Post
Replies
3
Views
2K
  • Last Post
Replies
2
Views
1K
  • Last Post
Replies
2
Views
4K
Top