29.2.13 problem 38

Internal problem ID [4646]
Book : Ordinary differential equations and their solutions. By George Moseley Murphy. 1960
Section : Various 2
Problem number : 38
Date solved : Sunday, March 30, 2025 at 03:32:18 AM
CAS classification : [_linear]

\begin{align*} y^{\prime }&=f \left (x \right )+g \left (x \right ) y \end{align*}

Maple. Time used: 0.001 (sec). Leaf size: 24
ode:=diff(y(x),x) = f(x)+g(x)*y(x); 
dsolve(ode,y(x), singsol=all);
 
\[ y = \left (\int f \left (x \right ) {\mathrm e}^{-\int g \left (x \right )d x}d x +c_1 \right ) {\mathrm e}^{\int g \left (x \right )d x} \]
Mathematica. Time used: 0.052 (sec). Leaf size: 47
ode=D[y[x],x]==f[x] + g[x] y[x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \exp \left (\int _1^xg(K[1])dK[1]\right ) \left (\int _1^x\exp \left (-\int _1^{K[2]}g(K[1])dK[1]\right ) f(K[2])dK[2]+c_1\right ) \]
Sympy. Time used: 2.027 (sec). Leaf size: 58
from sympy import * 
x = symbols("x") 
y = Function("y") 
f = Function("f") 
g = Function("g") 
ode = Eq(-f(x) - g(x)*y(x) + Derivative(y(x), x),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = \frac {\left (C_{1} + \int f{\left (x \right )} e^{- \int g{\left (x \right )}\, dx}\, dx + \int g{\left (x \right )} y{\left (x \right )} e^{- \int g{\left (x \right )}\, dx}\, dx\right ) e^{\int g{\left (x \right )}\, dx}}{\left (e^{\int g{\left (x \right )}\, dx}\right ) \int g{\left (x \right )} e^{- \int g{\left (x \right )}\, dx}\, dx + 1} \]