# Mathematica and Variation of Parameters

1. Sep 14, 2010

### jaseh86

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: May 4, 2017
2. Sep 18, 2010

### jaseh86

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

The equation was:

$$x^2 y'' - 5xy' + 5y = x^6 sinx$$

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

$$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$$

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

$$y = C_1 x + C_2 x^5 +6 x cosx - 3 x^3 cosx + 6 x^2 sinx - x^4 sinx$$

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. Sep 19, 2010

### jackmell

This is what I get:

\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}

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. Sep 19, 2010

### HallsofIvy

You will certainly NOT get terms like $x^5cos(x)$ and $x^4sin(x)$.

When I use "variation of parameters" with $y(x)= xu(x)+ x^5v(x)$, I wind up with the equations $v'= (1/4) sin(x)$, which is easy to integrate, and $u'= -(1/4)x^4sin(x)$ 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. Sep 19, 2010

### jackmell

I don't understand this comment. When I back-substitute the Mathematica solution into the DE, I obtain equality:

Code (Text):

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. Sep 19, 2010

### jaseh86

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!