Let x", x' and x be column vectors of results calculated at each time step (each vector has n entries).

Then create the matrices:

A = [x" x'] this is a n row, 2 column matrix, and

y = [m ; c] this is a 2 row, 1 column matrix, and

x = [x] this is a n row, 1 column matrix.

Now your DE can be written:

Ay = -kx

we can find the minimum squares solution of this as follows

Ay = -kx

so

A'Ay = -kA'x

so

so