1

I have been given a problem where someone is driving a car whose speedometer is off by some constant c (e.g. if the speedometer shows 30, but the true speed is 45, then c=15)

They begin to log their n drives, each time taking note of the distance traveled and speedometer reading during that drive. (assume the speed was constant throughout the whole ride)

I am given the total time t driven over all the drives, but not the time for each individual drive.

I am supposed to find the error, c, given n, t, and d1,d2,...,dn and s1,s2,...sn where d(i) is the distance traveled during a drive and s(i) is the speedometer reading on that drive

So far I've found that t = [d1/(r1+c)]+[d2/(r2+c)]+...+[dn/(rn+c)]

I'm wondering how to algebraically solve this equation for c

Any help is appreciated (or perhaps there is a better way to solve this problem, any help in that direction would be appreciated too)

2 Answers2

1

As far as I can tell, your reasoning is correct.

If you have just two terms, you can solve it like this: $$t=\frac{d_1}{r_1+c}+\frac{d_2}{r_2+c}$$

$$t=\frac{d_1 (r_2+c)+d_2(r_1+c)}{(r_1+c)(r_2+c)}$$

$$t(r_1+c)(r_2+c)=d_1 (r_2+c)+d_2(r_1+c)$$

$$t r_1 r_2+t (r_1+r_2)c+t c^2=d_1 (r_2+c)+d_2(r_1+c)$$

$$t r_1 r_2+(t (r_1+r_2)-d_1-d_2)c+t c^2=d_1 r_2+d_2 r_1$$

then use the quadratic formula

If you have $n$ terms, you will in general get an $n$th degree equation, which cannot be solved algebraically for $n>4$.

Wouter
  • 8,117
  • I see, so this actually ends up becoming an nth degree polynomial. This question I'm doing is actually a computer science problem, so the n can be as high as 1000. I guess I should find a new way to solve it as i doubt there is an efficient method to solve 1000th degree polynomials. (also setting up the polynomial would be a difficult problem in itself) – Franco Miranda Jun 23 '19 at 04:45
  • Some generic root-finding algorithm, like Newton's method, should work just fine. Even simpler, if you don't want to calculate derivatives, you could do a binary search. – Wouter Jun 23 '19 at 04:55
1

Starting from @Wouter's answer, you are looking for the zero of function $$f(c)=\sum_{i=1}^n \frac{d_i}{r_i+c}-t$$ I would not recommend to transform it to a polynomial. Just keep it like that and use Newton method with analytical derivatives with $c_0=0$. It should converge quite fast (assuming $c >0$).

Since the higher order derivatives are very simple, you could even use Halley or Householder methods for faster convergence.

Notice that starting with $c_0=0$, since $f''(0)>0$ and $f(0)<0$, by Darboux theorem, there will be one overshoot of the solution.

  • great! I'll try to implement an algorithm of the newton method. Thanks for the help +1 – Franco Miranda Jun 23 '19 at 06:02
  • @FrancoMiranda. I worked this kind of equations for many years. We have a lot of these in chemical engineering. – Claude Leibovici Jun 23 '19 at 06:03
  • I've run into the problem that the derivative is undefined when r(i)=-c. however your problem was a great general solution so I'll try to find a work around for this on my own. – Franco Miranda Jun 23 '19 at 06:26
  • This why I wrote that the problem would be simple if $c>0$. For the most general case, have a look at https://math.stackexchange.com/questions/3078167/efficient-algorithm-for-solving-equation-sum-n-a-n-x-x-n-1/3078999#3078999 – Claude Leibovici Jun 23 '19 at 06:54
  • Wow, thanks for that article. I will check out that paper. I'm fascinated as to why that much heavy duty maths would be need for chemical engineering? I had no idea it was such a math intensive field. – Franco Miranda Jun 23 '19 at 07:00
  • @FrancoMiranda. To give you an idea, in the dynamic simulation of a plant (chemicals, oil & gas,...), this equation must be solved zillions of times. Now, do you know what was a computer 60 years ago when I started. My goal is numerical efficiency and I spent (wasted ?) a significant part of my life with apparently simple equations like this one. – Claude Leibovici Jun 23 '19 at 07:31