65.4.8 problem 9.1 (viii)

Internal problem ID [13667]
Book : AN INTRODUCTION TO ORDINARY DIFFERENTIAL EQUATIONS by JAMES C. ROBINSON. Cambridge University Press 2004
Section : Chapter 9, First order linear equations and the integrating factor. Exercises page 86
Problem number : 9.1 (viii)
Date solved : Monday, March 31, 2025 at 08:07:12 AM
CAS classification : [_linear]

\begin{align*} x^{\prime }+\left (a +\frac {1}{t}\right ) x&=b \end{align*}

With initial conditions

\begin{align*} x \left (1\right )&=x_{0} \end{align*}

Maple. Time used: 0.030 (sec). Leaf size: 38
ode:=diff(x(t),t)+(a+1/t)*x(t) = b; 
ic:=x(1) = x__0; 
dsolve([ode,ic],x(t), singsol=all);
 
\[ x = \frac {\left (x_{0} a^{2}-b a +b \right ) {\mathrm e}^{-a \left (t -1\right )}+b \left (a t -1\right )}{a^{2} t} \]
Mathematica. Time used: 0.107 (sec). Leaf size: 44
ode=D[x[t],t]+(a+1/t)*x[t]==b; 
ic={x[1]==x0}; 
DSolve[{ode,ic},x[t],t,IncludeSingularSolutions->True]
 
\[ x(t)\to \frac {e^{-a t-1} \left (\int _1^tb e^{a K[1]+1} K[1]dK[1]+e^{a+1} \text {x0}\right )}{t} \]
Sympy
from sympy import * 
t = symbols("t") 
a = symbols("a") 
b = symbols("b") 
x = Function("x") 
ode = Eq(-b + (a + 1/t)*x(t) + Derivative(x(t), t),0) 
ics = {x(1): x__0} 
dsolve(ode,func=x(t),ics=ics)