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

  • Thread starter Thread starter amcavoy
  • Start date Start date
  • Tags Tags
    Mathematica
AI Thread Summary
The discussion focuses on graphing two ordinary differential equations (ODEs) in Mathematica, specifically y''+2y'+2y=δ(t−π) and y''+3y'+2y=δ(t−5)+u10(t). Participants suggest using Laplace Transforms to solve the equations before graphing, emphasizing the importance of initial conditions. One user successfully applies Mathematica's InverseLaplaceTransform function, sharing their approach to simplify complex expressions. The conversation highlights the challenges of visualizing solutions and the preference for using Mathematica for clarity in graphing results. Overall, the thread illustrates the collaborative effort to solve and graph ODEs effectively in Mathematica.
amcavoy
Messages
663
Reaction score
0
Could someone tell me how to graph the following ODE's in Mathematica?:

y''+2y'+2y=\delta\left(t-\pi\right)

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

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

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

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

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

and:

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

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:
saltydog said:
Can you solve them using Laplace Transforms first? That is:
\mathcal{L}\left\{\delta(t-a)\right\}=e^{-as}
and:
\mathcal{L}^{-1}\left\{f(s)\right\}=e^{-at}\mathcal{L}^{-1}\left\{f(s-a)\right\}
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:

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

returning a complex expression but then I used:

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

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:

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

where u(t) is the unit step function.
 
Last edited:
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 :)
 
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:

Similar threads

Replies
2
Views
1K
Replies
1
Views
2K
Replies
4
Views
2K
Replies
1
Views
1K
Replies
1
Views
3K
Replies
2
Views
2K
Replies
13
Views
2K
Replies
5
Views
2K
Back
Top