On this site I found how to calculate Cd and Crr coefficient from experimantal data:

Measure the drag coefficient of your car

I am trying to implement it in a web page and in a smartphone application, so I must "replace" Excel Solver by an algorithm, but I'm very in trouble.

I figured out how to calculate coefficients of fitting polynomial, so I now have the equation which approximates the speed curve, in form of (1) y = ax^2+bx+c

But now how do I correlate this equation to real data to obtain Cd and Crr?

The excel sheet relies on this formula:

v1 = v0 - a*t

where:

a = F/m

and

F = air drag + roll friction

air drag = 0.5 * r *A * Cd * v^2

roll friction = m * g * Crr

so I think it is:

v1 = v0 - 0.5 * r * A * Cd * v0^2 / m - g * Crr

if this is correct, I can "zip" it to:

(2) v1 = v0 + K v0^2 + H

and

K v0^2 + H = v1-v0

My idea is to use the next sample to build an equation couple which I can solve for K and H, and then get Cd and Crr from them... but it looks like it does not work, what am I doing wrong?

K v0^2 + H = v1-v0

K v1^2 + H = v2-v1

==> K, H ==> Cd, Crr

Any idea?