2.1.25 Problem 5

Solved using first_order_ode_linear
Maple
Mathematica
Sympy

Internal problem ID [18441]
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 : Monday, March 31, 2025 at 05:29:23 PM
CAS classification : [_linear]

Solved using first_order_ode_linear

Time used: 0.040 (sec)

Solve

tx+xg(t)=h(t)

In canonical form a linear first order is

x+q(t)x=p(t)

Comparing the above to the given ode shows that

q(t)=g(t)tp(t)=h(t)t

The integrating factor μ is

μ=eg(t)tdt

Therefore the solution is

x=(h(t)eg(t)tdttdt+c1)eg(t)tdt

Summary of solutions found

x=(h(t)eg(t)tdttdt+c1)eg(t)tdt
Maple. Time used: 0.002 (sec). Leaf size: 35
ode:=diff(x(t),t)*t+x(t)*g(t) = h(t); 
dsolve(ode,x(t), singsol=all);
 
x=(h(t)eg(t)tdttdt+c1)eg(t)tdt

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

Let’s solvet(ddtx(t))+x(t)g(t)=h(t)Highest derivative means the order of the ODE is1ddtx(t)Solve for the highest derivativeddtx(t)=x(t)g(t)+h(t)tCollect w.r.t.x(t)and simplifyddtx(t)=g(t)x(t)t+h(t)tGroup terms withx(t)on the lhs of the ODE and the rest on the rhs of the ODEddtx(t)+g(t)x(t)t=h(t)tThe ODE is linear; multiply by an integrating factorμ(t)μ(t)(ddtx(t)+g(t)x(t)t)=μ(t)h(t)tAssume the lhs of the ODE is the total derivativeddt(x(t)μ(t))μ(t)(ddtx(t)+g(t)x(t)t)=(ddtx(t))μ(t)+x(t)(ddtμ(t))Isolateddtμ(t)ddtμ(t)=μ(t)g(t)tSolve to find the integrating factorμ(t)=eg(t)tdtIntegrate both sides with respect tot(ddt(x(t)μ(t)))dt=μ(t)h(t)tdt+C1Evaluate the integral on the lhsx(t)μ(t)=μ(t)h(t)tdt+C1Solve forx(t)x(t)=μ(t)h(t)tdt+C1μ(t)Substituteμ(t)=eg(t)tdtx(t)=eg(t)tdth(t)tdt+C1eg(t)tdtSimplifyx(t)=eg(t)tdt(eg(t)tdth(t)tdt+C1)
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]
 
x(t)exp(1tg(K[1])K[1]dK[1])(1texp(1K[2]g(K[1])K[1]dK[1])h(K[2])K[2]dK[2]+c1)
Sympy. Time used: 41.881 (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)
 
(eg(t)tdtg(t)eg(t)tdttdt)x(t)+(g(t)x(t)h(t))eg(t)tdttdt=C1