50.3.16 problem 2(f)

Internal problem ID [7840]
Book : Differential Equations: Theory, Technique, and Practice by George Simmons, Steven Krantz. McGraw-Hill NY. 2007. 1st Edition.
Section : Chapter 1. What is a differential equation. Section 1.4 First Order Linear Equations. Page 15
Problem number : 2(f)
Date solved : Wednesday, March 05, 2025 at 05:07:31 AM
CAS classification : [_separable]

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

With initial conditions

\begin{align*} y \left (1\right )&=1 \end{align*}

Maple. Time used: 0.008 (sec). Leaf size: 13
ode:=x^2*diff(y(x),x)+x*y(x) = 2*x; 
ic:=y(1) = 1; 
dsolve([ode,ic],y(x), singsol=all);
 
\[ y = \frac {-1+2 x}{x} \]
Mathematica. Time used: 0.041 (sec). Leaf size: 12
ode=x^2*D[y[x],x]+x*y[x]==2*x; 
ic={y[1]==1}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to 2-\frac {1}{x} \]
Sympy. Time used: 0.164 (sec). Leaf size: 7
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(x**2*Derivative(y(x), x) + x*y(x) - 2*x,0) 
ics = {y(1): 1} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = 2 - \frac {1}{x} \]