2.1.25 Problem 5

2.1.25.1 Solved using first_order_ode_linear
2.1.25.2 Maple
2.1.25.3 Mathematica
2.1.25.4 Sympy

Internal problem ID [19683]
Book : Elementary Differential Equations. By R.L.E. Schwarzenberger. Chapman and Hall. London. First Edition (1969)
Section : Chapter 3. Solutions of first-order equations. Exercises at page 47
Problem number : 5
Date solved : Thursday, December 11, 2025 at 01:42:02 PM
CAS classification : [_linear]

2.1.25.1 Solved using first_order_ode_linear

0.028 (sec)

Entering first order ode linear solver

\begin{align*} x^{\prime } t +x g \left (t \right )&=h \left (t \right ) \\ \end{align*}
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) &=\frac {g \left (t \right )}{t}\\ p(t) &=\frac {h \left (t \right )}{t} \end{align*}

The integrating factor \(\mu \) is

\[ \mu = {\mathrm e}^{\int \frac {g \left (t \right )}{t}d t} \]
Therefore the solution is
\[ x = \left (\int \frac {h \left (t \right ) {\mathrm e}^{\int \frac {g \left (t \right )}{t}d t}}{t}d t +c_1 \right ) {\mathrm e}^{-\int \frac {g \left (t \right )}{t}d t} \]

Summary of solutions found

\begin{align*} x &= \left (\int \frac {h \left (t \right ) {\mathrm e}^{\int \frac {g \left (t \right )}{t}d t}}{t}d t +c_1 \right ) {\mathrm e}^{-\int \frac {g \left (t \right )}{t}d t} \\ \end{align*}
2.1.25.2 Maple. Time used: 0.001 (sec). Leaf size: 35
ode:=t*diff(x(t),t)+x(t)*g(t) = h(t); 
dsolve(ode,x(t), singsol=all);
 
\[ x = \left (\int \frac {h \left (t \right ) {\mathrm e}^{\int \frac {g \left (t \right )}{t}d t}}{t}d t +c_1 \right ) {\mathrm e}^{-\int \frac {g \left (t \right )}{t}d t} \]

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} \\ {} & {} & t \left (\frac {d}{d t}x \left (t \right )\right )+x \left (t \right ) g \left (t \right )=h \left (t \right ) \\ \bullet & {} & \textrm {Highest derivative means the order of the ODE is}\hspace {3pt} 1 \\ {} & {} & \frac {d}{d t}x \left (t \right ) \\ \bullet & {} & \textrm {Solve for the highest derivative}\hspace {3pt} \\ {} & {} & \frac {d}{d t}x \left (t \right )=\frac {-x \left (t \right ) g \left (t \right )+h \left (t \right )}{t} \\ \bullet & {} & \textrm {Collect w.r.t.}\hspace {3pt} x \left (t \right )\hspace {3pt}\textrm {and simplify}\hspace {3pt} \\ {} & {} & \frac {d}{d t}x \left (t \right )=-\frac {g \left (t \right ) x \left (t \right )}{t}+\frac {h \left (t \right )}{t} \\ \bullet & {} & \textrm {Group terms with}\hspace {3pt} x \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}x \left (t \right )+\frac {g \left (t \right ) x \left (t \right )}{t}=\frac {h \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}x \left (t \right )+\frac {g \left (t \right ) x \left (t \right )}{t}\right )=\frac {\mu \left (t \right ) h \left (t \right )}{t} \\ \bullet & {} & \textrm {Assume the lhs of the ODE is the total derivative}\hspace {3pt} \frac {d}{d t}\left (x \left (t \right ) \mu \left (t \right )\right ) \\ {} & {} & \mu \left (t \right ) \left (\frac {d}{d t}x \left (t \right )+\frac {g \left (t \right ) x \left (t \right )}{t}\right )=\left (\frac {d}{d t}x \left (t \right )\right ) \mu \left (t \right )+x \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 ) g \left (t \right )}{t} \\ \bullet & {} & \textrm {Solve to find the integrating factor}\hspace {3pt} \\ {} & {} & \mu \left (t \right )={\mathrm e}^{\int \frac {g \left (t \right )}{t}d t} \\ \bullet & {} & \textrm {Integrate both sides with respect to}\hspace {3pt} t \\ {} & {} & \int \left (\frac {d}{d t}\left (x \left (t \right ) \mu \left (t \right )\right )\right )d t =\int \frac {\mu \left (t \right ) h \left (t \right )}{t}d t +\mathit {C1} \\ \bullet & {} & \textrm {Evaluate the integral on the lhs}\hspace {3pt} \\ {} & {} & x \left (t \right ) \mu \left (t \right )=\int \frac {\mu \left (t \right ) h \left (t \right )}{t}d t +\mathit {C1} \\ \bullet & {} & \textrm {Solve for}\hspace {3pt} x \left (t \right ) \\ {} & {} & x \left (t \right )=\frac {\int \frac {\mu \left (t \right ) h \left (t \right )}{t}d t +\mathit {C1}}{\mu \left (t \right )} \\ \bullet & {} & \textrm {Substitute}\hspace {3pt} \mu \left (t \right )={\mathrm e}^{\int \frac {g \left (t \right )}{t}d t} \\ {} & {} & x \left (t \right )=\frac {\int \frac {{\mathrm e}^{\int \frac {g \left (t \right )}{t}d t} h \left (t \right )}{t}d t +\mathit {C1}}{{\mathrm e}^{\int \frac {g \left (t \right )}{t}d t}} \\ \bullet & {} & \textrm {Simplify}\hspace {3pt} \\ {} & {} & x \left (t \right )={\mathrm e}^{-\int \frac {g \left (t \right )}{t}d t} \left (\int \frac {{\mathrm e}^{\int \frac {g \left (t \right )}{t}d t} h \left (t \right )}{t}d t +\mathit {C1} \right ) \end {array} \]
2.1.25.3 Mathematica. Time used: 0.075 (sec). Leaf size: 63
ode=t*D[x[t],t]+x[t]*g[t]==h[t]; 
ic={}; 
DSolve[{ode,ic},x[t],t,IncludeSingularSolutions->True]
                                                                                  
                                                                                  
 
\begin{align*} x(t)&\to \exp \left (\int _1^t-\frac {g(K[1])}{K[1]}dK[1]\right ) \left (\int _1^t\frac {\exp \left (-\int _1^{K[2]}-\frac {g(K[1])}{K[1]}dK[1]\right ) h(K[2])}{K[2]}dK[2]+c_1\right ) \end{align*}
2.1.25.4 Sympy. Time used: 29.889 (sec). Leaf size: 49
from sympy import * 
t = symbols("t") 
x = Function("x") 
g = Function("g") 
h = Function("h") 
ode = Eq(t*Derivative(x(t), t) + g(t)*x(t) - h(t),0) 
ics = {} 
dsolve(ode,func=x(t),ics=ics)
 
\[ \left (e^{\int \frac {g{\left (t \right )}}{t}\, dt} - \int \frac {g{\left (t \right )} e^{\int \frac {g{\left (t \right )}}{t}\, dt}}{t}\, dt\right ) x{\left (t \right )} + \int \frac {\left (g{\left (t \right )} x{\left (t \right )} - h{\left (t \right )}\right ) e^{\int \frac {g{\left (t \right )}}{t}\, dt}}{t}\, dt = C_{1} \]