38.2.34 problem 34

Internal problem ID [6463]
Book : Engineering Mathematics. By K. A. Stroud. 5th edition. Industrial press Inc. NY. 2001
Section : Program 24. First order differential equations. Further problems 24. page 1068
Problem number : 34
Date solved : Sunday, March 30, 2025 at 11:02:59 AM
CAS classification : [_linear]

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

With initial conditions

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

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