Why is dsolve returning an arbitrary constant?

7 views (last 30 days)
I have the following differential equation I want to solve from a simple harmonic motion problem.
diffeq.png
When I enter this into MATLAB including two initial conditions, I get an arbitrary constant even though there should not be one. Why?
>> syms y(t) g L c
S = dsolve(diff(diff(y(t))) -L*y - g == 0, y(0) == c,diff(y(0))== 0)
S =
exp(-L^(1/2)*t)*(c - C5 + g/L) - g/L + C5*exp(L^(1/2)*t)

Accepted Answer

David Goodmanson
David Goodmanson on 25 Nov 2019
Edited: David Goodmanson on 25 Nov 2019
Hi David,
you need slightly different syntax.
syms y(t) g L c
Dy = diff(y)
S = dsolve(diff(diff(y(t))) -L*y - g == 0, y(0) == c,Dy(0)== 0)
S =
(exp(L^(1/2)*t)*(g + L*c))/(2*L) - g/L + (exp(-L^(1/2)*t)*(g + L*c))/(2*L)
Also, assuming k/m = w0^2 is positive as usual, then for harmonic motion the sign of the k/m term needs to change.
syms y(t) g c w0
Dy = diff(y)
S = dsolve(diff(diff(y(t))) +w0^2*y - g == 0, y(0) == c,Dy(0)== 0)
S =
g/w0^2 - (exp(-t*w0*1i)*(- c*w0^2 + g))/(2*w0^2) - (exp(t*w0*1i)*(- c*w0^2 + g))/(2*w0^2)

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!