How would I enter the Differential Equation y''+100y=2sin(4t)

the correct answer should be C1cos10t + C2sin10t + (1/42)sin4t
I tried this code and got a crazy answer.
dsolve ('D2y+100*y=2*sin(4*t)','t')
ans =
(3*sin(8*t)*((6*cos(4*t))/35 + (2*cos(8*t))/35 + 11/105))/8 - (sin(4*t)*((6*cos(4*t))/35 + (2*cos(8*t))/35 + 11/105))/8 - (3*sin(12*t)*((6*cos(4*t))/35 + (2*cos(8*t))/35 + 11/105))/8 + (sin(16*t)*((6*cos(4*t))/35 + (2*cos(8*t))/35 + 11/105))/8 + sin(10*t)*(cos(6*t)/60 - cos(14*t)/140) + C9*cos(10*t) - C10*sin(10*t)

Answers (2)

Try like so:
syms y(t)
simplify( dsolve(diff(y,2)+100*y==2*sin(4*t),t) )
ans =
sin(4*t)/42 + C1*cos(10*t) - C2*sin(10*t)
Use the simplify function:
syms t y(t) Dy0 y0
Dy = diff(y);
D2y = diff(y,2);
Eqn = D2y + 100*y == 2*sin(4*t);
ys = dsolve(Eqn, Dy(0)==Dy0, y(0)==y0);
ys = simplify(ys, 'Steps',50)
producing:
ys =
sin(4*t)/42 - sin(10*t)/105 + y0*cos(10*t) + (Dy0*sin(10*t))/10
I specified the initial conditions here, so they will appear as ‘y0’ and ‘Dy0’ in the integrated equation.

Categories

Find more on Mathematics and Optimization in Help Center and File Exchange

Asked:

on 5 May 2019

Answered:

on 5 May 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!