14.11.15 problem 15

Internal problem ID [2608]
Book : Differential equations and their applications, 4th ed., M. Braun
Section : Chapter 2. Second order differential equations. Section 2.5. Method of judicious guessing. Excercises page 164
Problem number : 15
Date solved : Sunday, March 30, 2025 at 12:11:27 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} y^{\prime \prime }+y&=\cos \left (t \right ) \cos \left (2 t \right ) \end{align*}

Maple. Time used: 0.002 (sec). Leaf size: 29
ode:=diff(diff(y(t),t),t)+y(t) = cos(t)*cos(2*t); 
dsolve(ode,y(t), singsol=all);
 
\[ y = -\frac {\cos \left (t \right )^{3}}{4}+\frac {\left (8 c_1 +3\right ) \cos \left (t \right )}{8}+\frac {\sin \left (t \right ) \left (t +4 c_2 \right )}{4} \]
Mathematica. Time used: 0.04 (sec). Leaf size: 35
ode=D[y[t],{t,2}]+y[t]==Cos[t]*Cos[2*t]; 
ic={}; 
DSolve[{ode,ic},y[t],t,IncludeSingularSolutions->True]
 
\[ y(t)\to -\frac {1}{16} \cos (3 t)+\left (\frac {1}{8}+c_1\right ) \cos (t)+\frac {1}{4} (t+4 c_2) \sin (t) \]
Sympy. Time used: 0.620 (sec). Leaf size: 22
from sympy import * 
t = symbols("t") 
y = Function("y") 
ode = Eq(y(t) - cos(t)*cos(2*t) + Derivative(y(t), (t, 2)),0) 
ics = {} 
dsolve(ode,func=y(t),ics=ics)
 
\[ y{\left (t \right )} = C_{2} \cos {\left (t \right )} + \left (C_{1} + \frac {t}{4}\right ) \sin {\left (t \right )} - \frac {\cos {\left (3 t \right )}}{16} \]