2.3.8 Problem 8

Maple
Mathematica
Sympy

Internal problem ID [10339]
Book : First order enumerated odes
Section : section 3. First order odes solved using Laplace method
Problem number : 8
Date solved : Thursday, November 27, 2025 at 10:34:39 AM
CAS classification : [_linear]

\begin{align*} y^{\prime } t +y&=\sin \left (t \right ) \\ y \left (1\right ) &= 0 \\ \end{align*}
Using Laplace transform method.

Since initial condition is not at zero, then change of variable is used to transform the ode so that initial condition is at zero.

\begin{align*} \tau = t -1 \end{align*}

We will now apply Laplace transform to each term in the ode. Since this is time varying, the following Laplace transform property will be used

\begin{align*} \tau ^{n} f \left (\tau \right ) &\xrightarrow {\mathscr {L}} (-1)^n \frac {d^n}{ds^n} F(s) \end{align*}

Where in the above \(F(s)\) is the laplace transform of \(f \left (\tau \right )\). Applying the above property to each term of the ode gives

\begin{align*} y &\xrightarrow {\mathscr {L}} Y \left (s \right )\\ y^{\prime } \left (\tau +1\right ) &\xrightarrow {\mathscr {L}} -Y \left (s \right )-s \left (\frac {d}{d s}Y \left (s \right )\right )+s Y \left (s \right )-y \left (0\right )\\ \sin \left (\tau +1\right ) &\xrightarrow {\mathscr {L}} \frac {\sin \left (1\right ) s +\cos \left (1\right )}{s^{2}+1} \end{align*}

Collecting all the terms above, the ode in Laplace domain becomes

\[ -s Y^{\prime }+s Y-y \left (0\right ) = \frac {\sin \left (1\right ) s +\cos \left (1\right )}{s^{2}+1} \]
Replacing \(y \left (0\right ) = 0\) in the above results in
\[ -s Y^{\prime }+s Y = \frac {\sin \left (1\right ) s +\cos \left (1\right )}{s^{2}+1} \]
The above ode in Y(s) is now solved.

Solve In canonical form a linear first order is

\begin{align*} Y^{\prime } + q(s)Y &= p(s) \end{align*}

Comparing the above to the given ode shows that

\begin{align*} q(s) &=-1\\ p(s) &=\frac {-\sin \left (1\right ) s -\cos \left (1\right )}{\left (s^{2}+1\right ) s} \end{align*}

The integrating factor \(\mu \) is

\begin{align*} \mu &= e^{\int {q\,ds}}\\ &= {\mathrm e}^{\int \left (-1\right )d s}\\ &= {\mathrm e}^{-s} \end{align*}

The ode becomes

\begin{align*} \frac {\mathop {\mathrm {d}}}{ \mathop {\mathrm {d}s}}\left ( \mu Y\right ) &= \mu p \\ \frac {\mathop {\mathrm {d}}}{ \mathop {\mathrm {d}s}}\left ( \mu Y\right ) &= \left (\mu \right ) \left (\frac {-\sin \left (1\right ) s -\cos \left (1\right )}{\left (s^{2}+1\right ) s}\right ) \\ \frac {\mathop {\mathrm {d}}}{ \mathop {\mathrm {d}s}} \left (Y \,{\mathrm e}^{-s}\right ) &= \left ({\mathrm e}^{-s}\right ) \left (\frac {-\sin \left (1\right ) s -\cos \left (1\right )}{\left (s^{2}+1\right ) s}\right ) \\ \mathrm {d} \left (Y \,{\mathrm e}^{-s}\right ) &= \left (\frac {\left (-\sin \left (1\right ) s -\cos \left (1\right )\right ) {\mathrm e}^{-s}}{\left (s^{2}+1\right ) s}\right )\, \mathrm {d} s \\ \end{align*}
Integrating gives
\begin{align*} Y \,{\mathrm e}^{-s}&= \int {\frac {\left (-\sin \left (1\right ) s -\cos \left (1\right )\right ) {\mathrm e}^{-s}}{\left (s^{2}+1\right ) s} \,ds} \\ &=-\frac {\operatorname {Ei}_{1}\left (s +i\right )}{2}-\frac {\operatorname {Ei}_{1}\left (s -i\right )}{2}+\cos \left (1\right ) \operatorname {Ei}_{1}\left (s \right ) + c_1 \end{align*}

Dividing throughout by the integrating factor \({\mathrm e}^{-s}\) gives the final solution

\[ Y = -\frac {\left (-2 \cos \left (1\right ) \operatorname {Ei}_{1}\left (s \right )+\operatorname {Ei}_{1}\left (s +i\right )+\operatorname {Ei}_{1}\left (s -i\right )-2 c_1 \right ) {\mathrm e}^{s}}{2} \]
Applying inverse Laplace transform on the above gives.
\begin{align*} y = \frac {\cos \left (1\right )}{\tau +1}+c_1 \operatorname {Typesetting}\mcoloneq \operatorname {msup}\left (\operatorname {Typesetting}\mcoloneq \operatorname {mi}\left (\text {``$\mathcal \{L\}$''}\right ), \operatorname {Typesetting}\mcoloneq \operatorname {mrow}\left (\operatorname {Typesetting}\mcoloneq \operatorname {mo}\left (\text {``$-$''}\right ), \operatorname {Typesetting}\mcoloneq \operatorname {mn}\left (``1''\right )\right ), \operatorname {Typesetting}\mcoloneq \operatorname {msemantics}=\text {``atomic''}\right )\left ({\mathrm e}^{s}, s , \tau \right )-\frac {\cos \left (\tau +1\right )}{2+\tau }\tag {1} \end{align*}

Substituting initial conditions \(y \left (0\right ) = 0\) and \(y^{\prime }\left (0\right ) = 0\) into the above solution Gives

\[ 0 = c_1 \operatorname {Typesetting}\mcoloneq \operatorname {msup}\left (\operatorname {Typesetting}\mcoloneq \operatorname {mi}\left (\text {``$\mathcal \{L\}$''}\right ), \operatorname {Typesetting}\mcoloneq \operatorname {mrow}\left (\operatorname {Typesetting}\mcoloneq \operatorname {mo}\left (\text {``$-$''}\right ), \operatorname {Typesetting}\mcoloneq \operatorname {mn}\left (``1''\right )\right ), \operatorname {Typesetting}\mcoloneq \operatorname {msemantics}=\text {``atomic''}\right )\left ({\mathrm e}^{s}, s , \tau \right )+\frac {\cos \left (1\right )}{2} \]
Solving for the constant \(c_1\) from the above equation gives
\begin{align*} c_1 = -\frac {\cos \left (1\right )}{2 \operatorname {Typesetting}\mcoloneq \operatorname {msup}\left (\operatorname {Typesetting}\mcoloneq \operatorname {mi}\left (\text {``$\mathcal \{L\}$''}\right ), \operatorname {Typesetting}\mcoloneq \operatorname {mrow}\left (\operatorname {Typesetting}\mcoloneq \operatorname {mo}\left (\text {``$-$''}\right ), \operatorname {Typesetting}\mcoloneq \operatorname {mn}\left (``1''\right )\right ), \operatorname {Typesetting}\mcoloneq \operatorname {msemantics}=\text {``atomic''}\right )\left ({\mathrm e}^{s}, s , \tau \right )} \end{align*}

Substituting the above back into the solution (1) gives

\[ y = \frac {\cos \left (1\right )}{\tau +1}-\frac {\cos \left (1\right )}{2}-\frac {\cos \left (\tau +1\right )}{2+\tau } \]
Changing back the solution from \(\tau \) to \(t\) using
\begin{align*} \tau = t -1 \end{align*}

the solution becomes

\begin{align*} y \left (t \right ) = \frac {\cos \left (1\right )}{t}-\frac {\cos \left (1\right )}{2}-\frac {\cos \left (t \right )}{t +1} \end{align*}
Solution plot Slope field \(\left (\frac {d}{d t}y \left (t \right )\right ) t +y \left (t \right ) = \sin \left (t \right )\)
Maple
ode:=t*diff(y(t),t)+y(t) = sin(t); 
ic:=[y(1) = 0]; 
dsolve([ode,op(ic)],y(t),method='laplace');
 
\[ \text {No solution found} \]

Maple trace

Methods for first order ODEs: 
--- Trying classification methods --- 
trying a quadrature 
trying 1st order linear 
<- 1st order linear successful
 

Maple step by step

\[ \begin {array}{lll} & {} & \textrm {Let's solve}\hspace {3pt} \\ {} & {} & \left [t \left (\frac {d}{d t}y \left (t \right )\right )+y \left (t \right )=\sin \left (t \right ), y \left (1\right )=0\right ] \\ \bullet & {} & \textrm {Highest derivative means the order of the ODE is}\hspace {3pt} 1 \\ {} & {} & \frac {d}{d t}y \left (t \right ) \\ \bullet & {} & \textrm {Isolate the derivative}\hspace {3pt} \\ {} & {} & \frac {d}{d t}y \left (t \right )=-\frac {y \left (t \right )}{t}+\frac {\sin \left (t \right )}{t} \\ \bullet & {} & \textrm {Group terms with}\hspace {3pt} y \left (t \right )\hspace {3pt}\textrm {on the lhs of the ODE and the rest on the rhs of the ODE}\hspace {3pt} \\ {} & {} & \frac {d}{d t}y \left (t \right )+\frac {y \left (t \right )}{t}=\frac {\sin \left (t \right )}{t} \\ \bullet & {} & \textrm {The ODE is linear; multiply by an integrating factor}\hspace {3pt} \mu \left (t \right ) \\ {} & {} & \mu \left (t \right ) \left (\frac {d}{d t}y \left (t \right )+\frac {y \left (t \right )}{t}\right )=\frac {\mu \left (t \right ) \sin \left (t \right )}{t} \\ \bullet & {} & \textrm {Assume the lhs of the ODE is the total derivative}\hspace {3pt} \frac {d}{d t}\left (y \left (t \right ) \mu \left (t \right )\right ) \\ {} & {} & \mu \left (t \right ) \left (\frac {d}{d t}y \left (t \right )+\frac {y \left (t \right )}{t}\right )=\left (\frac {d}{d t}y \left (t \right )\right ) \mu \left (t \right )+y \left (t \right ) \left (\frac {d}{d t}\mu \left (t \right )\right ) \\ \bullet & {} & \textrm {Isolate}\hspace {3pt} \frac {d}{d t}\mu \left (t \right ) \\ {} & {} & \frac {d}{d t}\mu \left (t \right )=\frac {\mu \left (t \right )}{t} \\ \bullet & {} & \textrm {Solve to find the integrating factor}\hspace {3pt} \\ {} & {} & \mu \left (t \right )=t \\ \bullet & {} & \textrm {Integrate both sides with respect to}\hspace {3pt} t \\ {} & {} & \int \left (\frac {d}{d t}\left (y \left (t \right ) \mu \left (t \right )\right )\right )d t =\int \frac {\mu \left (t \right ) \sin \left (t \right )}{t}d t +\mathit {C1} \\ \bullet & {} & \textrm {Evaluate the integral on the lhs}\hspace {3pt} \\ {} & {} & y \left (t \right ) \mu \left (t \right )=\int \frac {\mu \left (t \right ) \sin \left (t \right )}{t}d t +\mathit {C1} \\ \bullet & {} & \textrm {Solve for}\hspace {3pt} y \left (t \right ) \\ {} & {} & y \left (t \right )=\frac {\int \frac {\mu \left (t \right ) \sin \left (t \right )}{t}d t +\mathit {C1}}{\mu \left (t \right )} \\ \bullet & {} & \textrm {Substitute}\hspace {3pt} \mu \left (t \right )=t \\ {} & {} & y \left (t \right )=\frac {\int \sin \left (t \right )d t +\mathit {C1}}{t} \\ \bullet & {} & \textrm {Evaluate the integrals on the rhs}\hspace {3pt} \\ {} & {} & y \left (t \right )=\frac {-\cos \left (t \right )+\mathit {C1}}{t} \\ \bullet & {} & \textrm {Use initial condition}\hspace {3pt} y \left (1\right )=0 \\ {} & {} & 0=-\cos \left (1\right )+\mathit {C1} \\ \bullet & {} & \textrm {Solve for}\hspace {3pt} \textit {\_C1} \\ {} & {} & \mathit {C1} =\cos \left (1\right ) \\ \bullet & {} & \textrm {Substitute}\hspace {3pt} \textit {\_C1} =\cos \left (1\right )\hspace {3pt}\textrm {into general solution and simplify}\hspace {3pt} \\ {} & {} & y \left (t \right )=\frac {-\cos \left (t \right )+\cos \left (1\right )}{t} \\ \bullet & {} & \textrm {Solution to the IVP}\hspace {3pt} \\ {} & {} & y \left (t \right )=\frac {-\cos \left (t \right )+\cos \left (1\right )}{t} \end {array} \]
Mathematica. Time used: 0.023 (sec). Leaf size: 19
ode=t*D[y[t],t]+y[t]==Sin[t]; 
ic=y[1]==0; 
DSolve[{ode,ic},y[t],t,IncludeSingularSolutions->True]
 
\begin{align*} y(t)&\to \frac {\int _1^t\sin (K[1])dK[1]}{t} \end{align*}
Sympy. Time used: 0.152 (sec). Leaf size: 10
from sympy import * 
t = symbols("t") 
y = Function("y") 
ode = Eq(t*Derivative(y(t), t) + y(t) - sin(t),0) 
ics = {y(1): 0} 
dsolve(ode,func=y(t),ics=ics)
 
\[ y{\left (t \right )} = \frac {- \cos {\left (t \right )} + \cos {\left (1 \right )}}{t} \]