81.3.1 problem 1

Internal problem ID [18540]
Book : A short course on differential equations. By Donald Francis Campbell. Maxmillan company. London. 1907
Section : Chapter III. Ordinary differential equations of the first order and first degree. Exercises at page 33
Problem number : 1
Date solved : Thursday, March 13, 2025 at 12:12:10 PM
CAS classification : [_linear]

\begin{align*} y^{\prime }+\frac {y}{x}&=-x^{2}+1 \end{align*}

Maple. Time used: 0.002 (sec). Leaf size: 19
ode:=diff(y(x),x)+y(x)/x = -x^2+1; 
dsolve(ode,y(x), singsol=all);
 
\[ y \left (x \right ) = \frac {-\frac {\left (x^{2}-1\right )^{2}}{4}+c_{1}}{x} \]
Mathematica. Time used: 0.03 (sec). Leaf size: 24
ode=D[y[x],x]+1/x*y[x]==1-x^2; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to -\frac {x^3}{4}+\frac {x}{2}+\frac {c_1}{x} \]
Sympy. Time used: 0.211 (sec). Leaf size: 14
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(x**2 + Derivative(y(x), x) - 1 + y(x)/x,0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = \frac {C_{1}}{x} - \frac {x^{3}}{4} + \frac {x}{2} \]