50.14.14 problem 2(f)

Internal problem ID [8052]
Book : Differential Equations: Theory, Technique, and Practice by George Simmons, Steven Krantz. McGraw-Hill NY. 2007. 1st Edition.
Section : Chapter 2. Problems for Review and Discovery. Drill excercises. Page 105
Problem number : 2(f)
Date solved : Sunday, March 30, 2025 at 12:41:29 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} y^{\prime \prime }-y&=\cos \left (x \right ) \end{align*}

With initial conditions

\begin{align*} y \left (0\right )&=3\\ y^{\prime }\left (2\right )&=2 \end{align*}

Maple. Time used: 0.243 (sec). Leaf size: 27
ode:=diff(diff(y(x),x),x)-y(x) = cos(x); 
ic:=y(0) = 3, D(y)(2) = 2; 
dsolve([ode,ic],y(x), singsol=all);
 
\[ y = -\frac {\cos \left (x \right )}{2}-\frac {\left (\sin \left (2\right )-4\right ) \sinh \left (x \right ) \operatorname {sech}\left (2\right )}{2}+\frac {7 \cosh \left (x -2\right ) \operatorname {sech}\left (2\right )}{2} \]
Mathematica. Time used: 0.031 (sec). Leaf size: 67
ode=D[y[x],{x,2}]-y[x]==Cos[x]; 
ic={y[0]==3,Derivative[1][y][2]==2}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \frac {e^{-x} \left (7 e^{2 x}-e^{2 x+2} (\sin (2)-4)+\left (1+e^4\right ) \left (-e^x\right ) \cos (x)+7 e^4+e^2 (\sin (2)-4)\right )}{2 \left (1+e^4\right )} \]
Sympy. Time used: 0.115 (sec). Leaf size: 58
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-y(x) - cos(x) + Derivative(y(x), (x, 2)),0) 
ics = {y(0): 3, Subs(Derivative(y(x), x), x, 2): 2} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = \frac {\left (- e^{2} \sin {\left (2 \right )} + 7 + 4 e^{2}\right ) e^{x}}{2 + 2 e^{4}} - \frac {\cos {\left (x \right )}}{2} + \frac {\left (- 4 e^{2} + e^{2} \sin {\left (2 \right )} + 7 e^{4}\right ) e^{- x}}{2 + 2 e^{4}} \]