Graph ODEs in Mathematica: y''+2y'+2y & y''+3y'+2y

  • Mathematica
  • Thread starter amcavoy
  • Start date
  • Tags
    Mathematica
In summary: If[t ≤ Pi, Return[0]; , ]; f[x_] :=Simplify[ComplexExpand[InverseLaplaceTransform](f[x]), {x
  • #1
amcavoy
665
0
Could someone tell me how to graph the following ODE's in Mathematica?:

[tex]y''+2y'+2y=\delta\left(t-\pi\right)[/tex]

[tex]y''+3y'+2y=\delta\left(t-5\right)+u_{10}\left(t\right)[/tex]

Thanks.
 
Physics news on Phys.org
  • #2
I don't understand what you want to graph?

Don't you need the solution first?
 
  • #3
amcavoy said:
Could someone tell me how to graph the following ODE's in Mathematica?:
[tex]y''+2y'+2y=\delta\left(t-\pi\right)[/tex]
[tex]y''+3y'+2y=\delta\left(t-5\right)+u_{10}\left(t\right)[/tex]
Thanks.

Can you solve them using Laplace Transforms first? That is:

[tex]\mathcal{L}\left\{\delta(t-a)\right\}=e^{-as}[/tex]

and:

[tex]\mathcal{L}^{-1}\left\{f(s)\right\}=e^{-at}\mathcal{L}^{-1}\left\{f(s-a)\right\}[/tex]

Edit: I tried using NDSolve in Mathematica. Having a problem with it as the first equation usually has the initial conditions both set to zero with the unit pulse at pi.
 
Last edited:
  • #4
saltydog said:
Can you solve them using Laplace Transforms first? That is:
[tex]\mathcal{L}\left\{\delta(t-a)\right\}=e^{-as}[/tex]
and:
[tex]\mathcal{L}^{-1}\left\{f(s)\right\}=e^{-at}\mathcal{L}^{-1}\left\{f(s-a)\right\}[/tex]
Edit: I tried using NDSolve in Mathematica. Having a problem with it as the first equation usually has the initial conditions both set to zero with the unit pulse at pi.


Well, I'm impressed. At Mathematica anyway. At first I thought it couldn't handle:

[tex]\text{InverseLaplaceTransform}\left[\frac{e^{-\pi s}}{s^2+2s+2}\right][/tex]

returning a complex expression but then I used:

[tex]\text{Simplify[ComplexExpand[InverseLaplaceTransform}\left[\frac{e^{-\pi s}}{s^2+2s+2}\right]]][/tex]

and it returned the correct value. Amcavoy, you gettin' all of this? Really would recommend to you to do all the work by hand first. Right? Just use the relations I gave above and you can invert that last expression by hand.

Set the initial conditions for the first one to 0. As far as the second one, that u10 just ain't happening for me.

Edit:
Oh great, suppose you need another relation:

[tex]\mathcal{L}^{-1}\left\{e^{-as}F(s)\right\}=f(t-a)u(t-a)[/tex]

where u(t) is the unit step function.
 
Last edited:
  • #5
Yeah I did solve them (I had some more too), but they looked too messy for me to "sketch" by hand so I wanted to see what they looked like in Mathematica. Thanks for the help :)
 
  • #6
amcavoy said:
Yeah I did solve them (I had some more too), but they looked too messy for me to "sketch" by hand so I wanted to see what they looked like in Mathematica. Thanks for the help :)

Well, this is the first one in Mathematica for y(0)=0, y'(0)=0:

Code:
f[t_] :=
      If[t ≤  Pi,
          Return[0];
          ,
          Return[Exp[-(t - Pi)] Sin[t - Pi]];
       ];
 Plot[f[x], {x, 0, 4 Pi}, PlotRange -> {{0, 4 Pi}, {-0.4, 0.4}}]

Edit: Jesus, don't even need the 'Module' part.
 
Last edited:

What is an ODE?

An ODE, or ordinary differential equation, is an equation that relates a function to its derivatives. It describes the change of a dependent variable with respect to an independent variable.

What is a graph ODE in Mathematica?

A graph ODE in Mathematica is a graphical representation of the solution to an ODE. It uses the built-in function "NDSolve" to numerically solve the ODE and plot the resulting solution.

What is the difference between y''+2y'+2y and y''+3y'+2y?

The difference between these two ODEs lies in the coefficient of the first derivative term. In the first ODE, the coefficient is 2, while in the second ODE, the coefficient is 3. This difference can lead to different solutions and behaviors for the two ODEs.

How can I graph ODEs in Mathematica?

To graph ODEs in Mathematica, you can use the built-in function "NDSolve" to numerically solve the ODE and then use the "Plot" function to plot the resulting solution. You can also use the "Manipulate" function to create interactive graphs of ODEs.

What is the significance of y''+2y'+2y & y''+3y'+2y in mathematics?

These ODEs are examples of second-order linear differential equations, which have many applications in mathematics, physics, and engineering. They can model a wide range of phenomena, from population growth to oscillations in mechanical systems.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Calculus and Beyond Homework Help
Replies
6
Views
789
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
238
  • Calculus
Replies
9
Views
2K
  • Introductory Physics Homework Help
Replies
10
Views
892
  • Calculus and Beyond Homework Help
Replies
5
Views
1K
  • Introductory Physics Homework Help
Replies
24
Views
998
  • Differential Equations
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
Back
Top