Undamped Motion 

With r = 0, 

> deq1a := subs(r = 0, deq1); -1; %
 

`+`(`*`(m, `*`(diff(diff(x(t), t), t))), `*`(k, `*`(x(t)))) = 0
 

> dsolve({deq1a, init}, x(t)); 1
 

x(t) = `*`(x[0], `*`(cos(`/`(`*`(`^`(k, `/`(1, 2)), `*`(t)), `*`(`^`(m, `/`(1, 2)))))))
 

> xk := unapply(rhs(%), m, k, x[0], t); -1
 

> with(plots); -1
 

> plot(xk(1, 1, 1, t), t = 0 .. 19, labels = [t, x(t)], labelfont = [TIMES, BOLD, 12]); 1
 

Plot_2d
 

> mass_spring(1, 0, 1, 0, 5, 2, 0, 14, 0, 60, scaling = constrained)
 

 

 

`+`(diff(diff(x(t), t), t), x(t)) = 0
x(t) = `+`(`*`(2, `*`(cos(t))))
Plot_2d
 

Animation