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 : Wednesday, January 28, 2026 at 10:46:52 AM
CAS classification : [_linear]

2.1.25.1 Solved using first_order_ode_linear

0.123 (sec)

Entering first order ode linear solver

\begin{align*} t x^{\prime }+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

\begin{align*} \mu &= e^{\int {q\,dt}}\\ &= {\mathrm e}^{\int \frac {g \left (t \right )}{t}d t}\\ &= {\mathrm e}^{\int \frac {g \left (t \right )}{t}d 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 (\frac {h \left (t \right )}{t}\right ) \\ \frac {\mathop {\mathrm {d}}}{ \mathop {\mathrm {d}t}} \left (x \,{\mathrm e}^{\int \frac {g \left (t \right )}{t}d t}\right ) &= \left ({\mathrm e}^{\int \frac {g \left (t \right )}{t}d t}\right ) \left (\frac {h \left (t \right )}{t}\right ) \\ \mathrm {d} \left (x \,{\mathrm e}^{\int \frac {g \left (t \right )}{t}d t}\right ) &= \left (\frac {h \left (t \right ) {\mathrm e}^{\int \frac {g \left (t \right )}{t}d t}}{t}\right )\, \mathrm {d} t \\ \end{align*}
Integrating gives
\begin{align*} x \,{\mathrm e}^{\int \frac {g \left (t \right )}{t}d t}&= \int {\frac {h \left (t \right ) {\mathrm e}^{\int \frac {g \left (t \right )}{t}d t}}{t} \,dt} \\ &=\int \frac {h \left (t \right ) {\mathrm e}^{\int \frac {g \left (t \right )}{t}d t}}{t}d t + c_1 \end{align*}

Dividing throughout by the integrating factor \({\mathrm e}^{\int \frac {g \left (t \right )}{t}d t}\) gives the final solution

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

Summary of solutions found

\begin{align*} x &= {\mathrm e}^{\int -\frac {g \left (t \right )}{t}d t} \left (\int \frac {h \left (t \right ) {\mathrm e}^{\int \frac {g \left (t \right )}{t}d t}}{t}d t +c_1 \right ) \\ \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: 20.330 (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} \]
Python version: 3.12.3 (main, Aug 14 2025, 17:47:21) [GCC 13.3.0] 
Sympy version 1.14.0
 
classify_ode(ode,func=x(t)) 
 
('factorable', '1st_exact', '1st_linear', 'Bernoulli', 'almost_linear', 'lie_group', '1st_exact_Integral', '1st_linear_Integral', 'Bernoulli_Integral', 'almost_linear_Integral')