83.44.5 problem Ex 5 page 37

Internal problem ID [19462]
Book : A Text book for differentional equations for postgraduate students by Ray and Chaturvedi. First edition, 1958. BHASKAR press. INDIA
Section : Book Solved Excercises. Chapter III. Ordinary linear differential equations with constant coefficients
Problem number : Ex 5 page 37
Date solved : Monday, March 31, 2025 at 07:19:25 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} y^{\prime \prime }+n^{2} y&=\sec \left (n x \right ) \end{align*}

Maple. Time used: 0.006 (sec). Leaf size: 40
ode:=diff(diff(y(x),x),x)+n^2*y(x) = sec(n*x); 
dsolve(ode,y(x), singsol=all);
 
\[ y = \sin \left (n x \right ) c_2 +\cos \left (n x \right ) c_1 +\frac {x \sin \left (n x \right ) n -\ln \left (\sec \left (n x \right )\right ) \cos \left (n x \right )}{n^{2}} \]
Mathematica. Time used: 0.037 (sec). Leaf size: 39
ode=D[y[x],{x,2}]+n^2*y[x]==Sec[n*x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \frac {\cos (n x) \left (\log (\cos (n x))+c_1 n^2\right )+n (x+c_2 n) \sin (n x)}{n^2} \]
Sympy. Time used: 0.460 (sec). Leaf size: 58
from sympy import * 
x = symbols("x") 
n = symbols("n") 
y = Function("y") 
ode = Eq(n**2*y(x) + Derivative(y(x), (x, 2)) - 1/cos(n*x),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = \left (C_{1} + \frac {\log {\left (e^{2 i n x} + 1 \right )}}{2 n^{2}}\right ) e^{- i n x} + \left (C_{2} - \frac {i x}{n} + \frac {\log {\left (e^{2 i n x} + 1 \right )}}{2 n^{2}}\right ) e^{i n x} \]