# Solving Differential Equation Representing Simple Harmonic Motion in SageMath

``` print "Solving differential equation representing Simple Harmonic
Motion"

#Declaring mass, time and spring constant as m, t and k
respectively
m=var('m')
t=var('t')
k=var('k')

#Declaring displacement is fuction of time
x = function('x',t)

#Assuming spring constant and mass are greater than zero
assume(k>0)
assume(m>0)

#Writing differential equation
de= diff(x,t,2)+(k*x)/m

#Solving differential equation
z = desolve(de,dvar=x,ivar=t)

#printing the result of differential equation
print(z)```

## 4 thoughts on “Solving Differential Equation Representing Simple Harmonic Motion in SageMath”

1. Irina Ledec says:

Excellent article. I definitely love this website. Continue the good work!

2. Jude Soloman says:

Thank you so much for your effort in writing this post.

3. Elizabet Alward says:

Excellent post. I certainly love this site. Keep it up!

4. maillot de foot says:

This is a really good read for me, thank you!