65.4.2 problem 9.1 (ii)

Internal problem ID [13653]
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 (ii)
Date solved : Wednesday, March 05, 2025 at 10:10:02 PM
CAS classification : [_separable]

\begin{align*} x^{\prime }+t x&=4 t \end{align*}

With initial conditions

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

Maple. Time used: 0.017 (sec). Leaf size: 14
ode:=diff(x(t),t)+t*x(t) = 4*t; 
ic:=x(0) = 2; 
dsolve([ode,ic],x(t), singsol=all);
 
\[ x \left (t \right ) = 4-2 \,{\mathrm e}^{-\frac {t^{2}}{2}} \]
Mathematica. Time used: 0.048 (sec). Leaf size: 18
ode=D[x[t],t]+t*x[t]==4*t; 
ic={x[0]==2}; 
DSolve[{ode,ic},x[t],t,IncludeSingularSolutions->True]
 
\[ x(t)\to 4-2 e^{-\frac {t^2}{2}} \]
Sympy. Time used: 0.292 (sec). Leaf size: 12
from sympy import * 
t = symbols("t") 
x = Function("x") 
ode = Eq(t*x(t) - 4*t + Derivative(x(t), t),0) 
ics = {x(0): 2} 
dsolve(ode,func=x(t),ics=ics)
 
\[ x{\left (t \right )} = 4 - 2 e^{- \frac {t^{2}}{2}} \]