Mathematica and Variation of Parameters

In summary, I used variation of parameters to find the solution to the second-order ODE: y=C_1x+C_2x^5-180xcosx+90x^3cosx-7x^5cosx-180x^2sinx+30x^4sinx. However, if I try to solve the equation in Mathematica, I get y=C_1x+C_2x^5+6xcosx-3x^3cosx+6x^2sinx-x^4sinx. Can anyone verify my answer? (Warning: quite long to integrate) Either I'm typing something wrong in Mathematica, I miscal
  • #1
jaseh86
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

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

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

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:
Physics news on Phys.org
  • #2
Woops I just realized 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
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
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
HallsofIvy said:
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
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!
 

1. What is Mathematica and how does it relate to variation of parameters?

Mathematica is a powerful computer algebra system that is commonly used in scientific research and engineering fields. It allows for efficient and accurate computation of mathematical equations, making it a useful tool for analyzing and solving problems involving variation of parameters.

2. What is variation of parameters and why is it important?

Variation of parameters is a method used to solve a type of differential equation known as a nonhomogeneous linear ordinary differential equation. It is important because it allows for the determination of a general solution to these types of equations, which can then be used to solve specific problems or make predictions in various scientific and engineering applications.

3. What are the steps involved in using Mathematica for variation of parameters?

The first step is to input the nonhomogeneous linear differential equation into Mathematica using its built-in functions. Then, the program will use the method of variation of parameters to find the general solution. Finally, any necessary boundary or initial conditions can be applied to determine the specific solution for a given problem.

4. Can Mathematica handle complex or high-dimensional systems of differential equations for variation of parameters?

Yes, Mathematica has the capability to solve complex and high-dimensional systems of differential equations using variation of parameters. However, the computation time and accuracy may vary depending on the complexity of the system and the capabilities of the computer being used.

5. Are there any limitations to using Mathematica for variation of parameters?

While Mathematica is a powerful tool for solving differential equations, it may not always be able to find closed-form solutions for highly nonlinear or complicated systems. In these cases, it may be necessary to use other numerical methods or approximation techniques to solve the problem.

Similar threads

  • Calculus and Beyond Homework Help
Replies
1
Views
2K
  • Calculus and Beyond Homework Help
Replies
5
Views
3K
  • Calculus and Beyond Homework Help
Replies
4
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
4K
  • Precalculus Mathematics Homework Help
Replies
2
Views
2K
  • Calculus and Beyond Homework Help
Replies
2
Views
21K
Back
Top