Using matlab/mathematica to solve a second order diff.eq.

In summary, the conversation discusses solving a second-order differential equation using MATLAB or Mathematica. It is suggested to treat the equation as a system of first-order equations and to use the MATLAB function ode45 to solve it. The user is looking for assistance in using these programs to solve the equation and is open to trying other programs such as Maple.
  • #1
astropi
47
0

Homework Statement


This is NOT a homework problem, but it is similar. Anyway, let's say we have:

y''+3y' = 2t^4

This is easy to solve by hand. For the particular solution you get:

Yp = At+Bt^2+Ct^3+Dt^4+Et^5

Now, to solve for the coefficients, you can solve them by hand, or you can use some sort of program. Myself, I tried using MATLAB but could not get it to work. So I am hoping someone with MATLAB experience can help me, since I do not want to do all this mundane work by hand!

Homework Equations



You have to take the derivative (1st and second) of Yp and then plug back into the original equation, then equate coefficients. Although it can be done by hand, surely there has to be a better way to do this with Mathematica or matlab?

The Attempt at a Solution



I tried using matlab, as I said, but could not get it to work. If someone has an idea, or wants to see my MATLAB code (which is only 4-5 lines) I would be happy to send it. Otherwise, if someone can help with either MATLAB or mathematica, please let me know. Thanks.
 
Physics news on Phys.org
  • #2
I think you have to treat it as a system:

[tex]
\begin{array}{rcl}
y' & = & z \\
z'+3z & = & 2t^{4}
\end{array}
[/tex]
 
  • #3
hunt_mat said:
I think you have to treat it as a system:

[tex]
\begin{array}{rcl}
y' & = & z \\
z'+3z & = & 2t^{4}
\end{array}
[/tex]

I don't follow you. How is this going to help me use Mathematica or Matlab? If you know how, please provide me with some actual code I could test out. Thanks.
 
  • #4
|If you look in the help files, it's quite clear how to use the ode45 routine to solve a system. Matlab won't solve higher order systems, you have to break them down into first order systems.
 
  • #5
hunt_mat said:
|If you look in the help files, it's quite clear how to use the ode45 routine to solve a system. Matlab won't solve higher order systems, you have to break them down into first order systems.

I'm a MATLAB newbie, so ode45 doesn't look very clear to me. Do you have to have initial conditions for ode45 to work, because in my example there are none. Also, I was fairly certain you can use dsolve to solve second order diff. eq. without much problem. At any rate, I'm not trying to solve the diff.eq. I already did that. I just want some program to do the algebra. Thanks.
 
  • #6
Then use maple or matlab.
 
  • #7
hunt_mat said:
Then use maple or matlab.

I have been trying matlab. I don't know maple, but I would be surprised if people haven't already done this with Mathematica and Matlab. Hopefully someone out there can help...
 

1. What is a second order differential equation?

A second order differential equation is a mathematical equation that involves the second derivative of a function. It is used to describe the relationship between a function and its derivatives, and is commonly used in physics and engineering to model real-world phenomena.

2. How can Matlab/Mathematica be used to solve a second order differential equation?

Matlab and Mathematica are both powerful software tools that can be used to numerically solve differential equations. They have built-in functions and algorithms that allow for efficient and accurate solutions to second order differential equations.

3. What are the steps involved in solving a second order differential equation using Matlab/Mathematica?

The steps involved in solving a second order differential equation using Matlab/Mathematica include defining the equation, setting initial conditions, choosing appropriate solver methods, and plotting the solution. It is also important to check the accuracy and stability of the solution.

4. Are there any limitations to using Matlab/Mathematica to solve second order differential equations?

While Matlab and Mathematica are powerful tools for solving differential equations, they do have some limitations. These include the need for proper parameter tuning, potential for numerical errors, and difficulty in solving certain types of equations (such as stiff equations).

5. Can Matlab/Mathematica be used to solve higher order or non-linear differential equations?

Yes, Matlab and Mathematica have capabilities for solving higher order and non-linear differential equations. However, the complexity and accuracy of the solution may depend on the specific equation and the chosen solver method.

Similar threads

Replies
4
Views
502
  • Calculus and Beyond Homework Help
Replies
14
Views
393
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
Replies
3
Views
1K
  • Calculus and Beyond Homework Help
Replies
9
Views
1K
  • Calculus and Beyond Homework Help
Replies
33
Views
3K
  • Calculus and Beyond Homework Help
Replies
2
Views
1K
  • Calculus and Beyond Homework Help
Replies
14
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Advanced Physics Homework Help
Replies
1
Views
952
Back
Top