2
$\begingroup$

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)

$\endgroup$
1
  • $\begingroup$ Just by curiosity, could you tell me how it works for any of your problems ? $\endgroup$ Commented Jun 23, 2019 at 6:17

2 Answers 2

1
$\begingroup$

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.

$\endgroup$
6
  • $\begingroup$ great! I'll try to implement an algorithm of the newton method. Thanks for the help +1 $\endgroup$ Commented Jun 23, 2019 at 6:02
  • $\begingroup$ @FrancoMiranda. I worked this kind of equations for many years. We have a lot of these in chemical engineering. $\endgroup$ Commented Jun 23, 2019 at 6:03
  • $\begingroup$ 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. $\endgroup$ Commented Jun 23, 2019 at 6:26
  • $\begingroup$ This why I wrote that the problem would be simple if $c>0$. For the most general case, have a look at math.stackexchange.com/questions/3078167/… $\endgroup$ Commented Jun 23, 2019 at 6:54
  • $\begingroup$ 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. $\endgroup$ Commented Jun 23, 2019 at 7:00
1
$\begingroup$

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$.

$\endgroup$
2
  • $\begingroup$ 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) $\endgroup$ Commented Jun 23, 2019 at 4:45
  • $\begingroup$ 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. $\endgroup$ Commented Jun 23, 2019 at 4:55

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.