2.2.3 Problem 3

Maple
Mathematica
Sympy

Internal problem ID [10331]
Book : First order enumerated odes
Section : section 2 (system of first order odes)
Problem number : 3
Date solved : Thursday, November 27, 2025 at 10:34:27 AM
CAS classification : system_of_ODEs

\begin{align*} x^{\prime }+y^{\prime }-x&=y+t +\sin \left (t \right )+\cos \left (t \right ) \\ x^{\prime }+y^{\prime }&=2 x+3 y+{\mathrm e}^{t} \\ \end{align*}
The system is
\begin{align*} x^{\prime }+y^{\prime }&=x+y+t +\sin \left (t \right )+\cos \left (t \right )\tag {1}\\ x^{\prime }+y^{\prime }&=2 x+3 y+{\mathrm e}^{t}\tag {2} \end{align*}

Since the left side is the same, this implies

\begin{align*} x+y+t +\sin \left (t \right )+\cos \left (t \right )&=2 x+3 y+{\mathrm e}^{t}\\ y&=-\frac {x}{2}-\frac {{\mathrm e}^{t}}{2}+\frac {t}{2}+\frac {\sin \left (t \right )}{2}+\frac {\cos \left (t \right )}{2}\tag {3} \end{align*}

Taking derivative of the above w.r.t. \(t\) gives

\begin{align*} y^{\prime }&=-\frac {x^{\prime }}{2}-\frac {{\mathrm e}^{t}}{2}+\frac {1}{2}+\frac {\cos \left (t \right )}{2}-\frac {\sin \left (t \right )}{2}\tag {4} \end{align*}

Substituting (3,4) in (1) to eliminate \(y,y^{\prime }\) gives

\begin{align*} \frac {x^{\prime }}{2}-\frac {{\mathrm e}^{t}}{2}+\frac {1}{2}+\frac {\cos \left (t \right )}{2}-\frac {\sin \left (t \right )}{2} &= \frac {x}{2}-\frac {{\mathrm e}^{t}}{2}+\frac {3 t}{2}+\frac {3 \sin \left (t \right )}{2}+\frac {3 \cos \left (t \right )}{2}\\ x^{\prime } &= x+3 t +4 \sin \left (t \right )+2 \cos \left (t \right )-1\tag {5} \end{align*}

Which is now solved for \(x\). Solve In canonical form a linear first order is

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

Comparing the above to the given ode shows that

\begin{align*} q(t) &=-1\\ p(t) &=3 t +4 \sin \left (t \right )+2 \cos \left (t \right )-1 \end{align*}

The integrating factor \(\mu \) is

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

The ode becomes

\begin{align*} \frac {\mathop {\mathrm {d}}}{ \mathop {\mathrm {d}t}}\left ( \mu x\right ) &= \mu p \\ \frac {\mathop {\mathrm {d}}}{ \mathop {\mathrm {d}t}}\left ( \mu x\right ) &= \left (\mu \right ) \left (3 t +4 \sin \left (t \right )+2 \cos \left (t \right )-1\right ) \\ \frac {\mathop {\mathrm {d}}}{ \mathop {\mathrm {d}t}} \left (x \,{\mathrm e}^{-t}\right ) &= \left ({\mathrm e}^{-t}\right ) \left (3 t +4 \sin \left (t \right )+2 \cos \left (t \right )-1\right ) \\ \mathrm {d} \left (x \,{\mathrm e}^{-t}\right ) &= \left (\left (3 t +4 \sin \left (t \right )+2 \cos \left (t \right )-1\right ) {\mathrm e}^{-t}\right )\, \mathrm {d} t \\ \end{align*}
Integrating gives
\begin{align*} x \,{\mathrm e}^{-t}&= \int {\left (3 t +4 \sin \left (t \right )+2 \cos \left (t \right )-1\right ) {\mathrm e}^{-t} \,dt} \\ &=\left (-\sin \left (t \right )-3 \cos \left (t \right )-3 t -2\right ) {\mathrm e}^{-t} + c_2 \end{align*}

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

\[ x = -\sin \left (t \right )-3 \cos \left (t \right )-3 t -2+{\mathrm e}^{t} c_2 \]
Given now that we have the solution
\begin{align*} x&=-\sin \left (t \right )-3 \cos \left (t \right )-3 t -2+{\mathrm e}^{t} c_2 \tag {6} \end{align*}

Then substituting (6) into (3) gives

\begin{align*} y&=\sin \left (t \right )+2 \cos \left (t \right )+2 t +1-\frac {{\mathrm e}^{t} c_2}{2}-\frac {{\mathrm e}^{t}}{2} \tag {7} \end{align*}
Maple. Time used: 0.218 (sec). Leaf size: 44
ode:=[diff(x(t),t)+diff(y(t),t)-x(t) = y(t)+t+sin(t)+cos(t), diff(x(t),t)+diff(y(t),t) = 2*x(t)+3*y(t)+exp(t)]; 
dsolve(ode);
 
\begin{align*} x \left (t \right ) &= -\sin \left (t \right )-3 \cos \left (t \right )+{\mathrm e}^{t} c_1 -3 t -2 \\ y \left (t \right ) &= \sin \left (t \right )+2 \cos \left (t \right )-\frac {{\mathrm e}^{t} c_1}{2}+2 t +1-\frac {{\mathrm e}^{t}}{2} \\ \end{align*}
Mathematica. Time used: 0.024 (sec). Leaf size: 102
ode={D[x[t],t]+D[y[t],t]-x[t]==y[t]+t+Sin[t]+Cos[t],D[x[t],t]+D[y[t],t]==2*x[t]+3*y[t]+Exp[t]}; 
ic={}; 
DSolve[{ode,ic},{x[t],y[t]},t,IncludeSingularSolutions->True]
 
\begin{align*} x(t)&\to 2 \int _1^te^{t-K[1]} (\cos (K[1])+K[1]+\sin (K[1]))dK[1]-t+e^t-\sin (t)-\cos (t)+2 c_1 e^t\\ y(t)&\to -\int _1^te^{t-K[1]} (\cos (K[1])+K[1]+\sin (K[1]))dK[1]+t-e^t+\sin (t)+\cos (t)-c_1 e^t \end{align*}
Sympy
from sympy import * 
t = symbols("t") 
x = Function("x") 
y = Function("y") 
ode=[Eq(-t - x(t) - y(t) - sin(t) - cos(t) + Derivative(x(t), t) + Derivative(y(t), t),0),Eq(-2*x(t) - 3*y(t) - exp(t) + Derivative(x(t), t) + Derivative(y(t), t),0)] 
ics = {} 
dsolve(ode,func=[x(t),y(t)],ics=ics)