Home » Blog » Minimize the relative error of an approximation

Minimize the relative error of an approximation

We know a real number x satisfies x \in [a,b] where a is positive. Let a \leq t \leq b be an approximation of x such that the relative error,

    \[ \frac{|t-x|}{x}, \]

is minimized. Denote the maximum of this relative error by M(t) as x varies over the interval.

  1. Prove that M(t) has its maximum at one of the end points.
  2. Prove that M(t) is minimal when

        \[ \frac{1}{t} = \frac{1}{2} \left( \frac{1}{a} + \frac{1}{b} \right). \]

    This value of t is called the harmonic mean of a and b.


  1. Proof. We rewrite the error term as a piecewise function (so we can consider the derivative of each piece),

        \[ \frac{|t-x|}{x} = \begin{dcases} \frac{t-x}{x} & \text{if } t \geq x \\ \frac{x-t}{x} & \text{if } t < x \end{dcases}. \]

    So, taking the derivative with respect to x we then have,

        \[ \left( \frac{|t-x|}{x} \right)' = \begin{dcases} -\frac{t}{x^2} & \text{if } t \geq x \\ \frac{t}{x^2} & \text{if } t < x \end{dcases}. \]

    But we know from the problem statement that a > 0 and since both x and t are in the interval [a,b] we have x, t > 0. Therefore, the derivative is not zero anywhere on the interval (since -\frac{t}{x^2} \neq 0 and \frac{t}{x^2} \neq 0 since t is not zero). Hence, M(t) cannot have a maximum on the interior (a,b), so the maximum must be at one of the endpoints, x = a or x = b. \qquad \blacksquare

  2. Proof. Now, we want to find the value of t at which M(t) is smallest (i.e., when the maximum error is smallest). From part (a), we know that for any fixed t the maximum value of the error must occur at an end point, x = a or x = b. Since M(t) is the function which returns the maximum error, we have

        \[ M(t) = \frac{|t-a|}{a} \qquad \text{or} \qquad M(t) = \frac{|t-b|}{b}. \]

    Since this is the maximum error, we then have

        \[ M(t) = \frac{|t-a|}{a} \qquad \text{if} \qquad \frac{|t-a|}{a} > \frac{|t-b|}{b} \]

    and

        \[ M(t) = \frac{|t-b|}{b} \qquad \text{if} \qquad \frac{|t-b|}{b} > \frac{|t-a|}{a}. \]

    Furthermore, since a \leq t \leq b we know that |t-a| = t-a and |t-b| = b-t. Now,

        \[ \frac{t-a}{a} > \frac{b-t}{b} \quad \implies \quad t > \frac{2ab}{a+b} \]

    and

        \[ \frac{b-t}{b} > \frac{t-a}{a} \quad \implies \quad t < \frac{2ab}{a+b}. \]

    Hence, we can give a formula for M(t),

        \[ M(t) = \begin{dcases} \frac{t-a}{a} & \text{if } t > \frac{2ab}{a+b} \\ \frac{b-t}{b} & \text{if } t < \frac{2ab}{a + b}. \end{dcases} \]

    Taking the derivative of M(t) with respect to t we then have

        \[ M'(t) = \begin{dcases} \frac{1}{a} & \text{if } t > \frac{2ab}{a+b} \\ \frac{-1}{b} & \text{if } t < \frac{2ab}{a+b}. \]

    Since a and b are both positive, this means M'(t) is negative if t < \frac{2ab}{a+b} and M'(t) is positive if t > \frac{2ab}{a+b}; hence, M(t) is decreasing for t < \frac{2ab}{a+b} and is increasing for t > \frac{2ab}{a+b}. Therefore, M(t) has a minimum at

        \[ t = \frac{2ab}{a+b} \quad \implies \quad t = \frac{a+b}{2ab} = \frac{1}{2}\left( \frac{1}{a} + \frac{1}{b} \right). \qquad \blacksquare \]

4 comments

  1. tom says:

    I get it now- it helped recently reading Apostol’s functional relation definition. There might be a slight omission though which I think was in the original solution. Doesn’t breaking the interval into a piecewise function introduce another endpoint, x=t? The value of the approximation goes to zero, so obviously not a maximum; I think you specified that originally but left it out this time.

  2. tom says:

    Thanks for the help. This and the previous exercise are new to me and I especially like this one. I did have to think to follow your proof (a good thing). Your time is certainly valuable in light of this ambitious project you are doing so I certainly would not expect these solutions to be spelled out in absurd detail, and may I say your solutions are quite nice. When it comes to continuity, a subject which has taken a considerable amount of time for me to grasp the subtleties, I get more then a little nervous when every contingency isn’t spelled out. Again, thanks a lot. This stuff you are doing is indispensable and I wish you get a lot of recognition for what you are doing, or at least a lot of satisfaction!

  3. Rori says:

    Hi! I don’t think I’ve done a great job writing up the solution to this problem, so I’ll try to clarify it tomorrow. However, I’ll see if I can answer some what you are asking (I also highly recommend math.stackexchange.com since there are way more experts there that can do a better job explaining than I can).

    What you are saying is right, when we take the derivative of the function we find a discontinuity at the point t = x and the derivative is zero nowhere else. I was sloppy here: what this actually allows us to conclude is that any extreme values of the function must occur at the end points or at the point the derivative does not exist (since at x = t the derivative from the left is different from the derivative from the right meaning the derivative does not exist at this point). However, since the function |t-x|/x \geq 0 everywhere (since |t-x| \geq 0 and x > 0) and |t-x|/x = 0 at t = x we know this point must be a minimum. So the only points left at which extreme values might occur are the end points.

    I think I’ve also made some mistakes in which function I was calling M(t). (M(t) should be the function which tells you the maximum of |t-x|/x for each t… at some point in the write up I think I started writing M(t) = |t-x|/x instead which is definitely making things more confusing.) I’ll try to post a fix for this tomorrow that will hopefully clear things up. Thanks for commenting, this solution definitely needs work!

  4. tom says:

    Hi Rori ! This is the first time I’ve ever asked a math question online, hopefully not my last. I’m a 52yrs old whom missed out on higher education in my life so my goal in life now is to try to be smarter. I self study and lack confidence when it comes to solving problems, perhaps partially related to not having anyone to discuss math with, perhaps also because the exercises are tough. So your help with Apostol Calculus, a great book, is indispensable to me.

    My question relates not to your solution but to the exercise itself. First, we are presented with an estimate T of a value X in an interval and requested to find a minimal function M(t) which would locate a ‘special’ value of T, the estimate, and the value of X. We differentiate w/ respect to X and find the derivative is nowhere zero. There is a discontinuity of this function at T=X, and what also slightly confuses me is what to call this function, as it’s not M(t) as we haven’t got to that step yet. So this function actually does have a minimum at X=T but the discontinuity of DF/DX voids the derivative being zero. Also, the derivative does not have an X dependency so any ‘special’ points must be on the endpoints.

    I am assuming it’s meant to be obvious that one endpoint will be the min while the other a max, depending on our choice of X. So evaluating at x=a and b and this time differentiating with respect to T, we again find a discontinuity of the derivative (you can tell that the discontinuities are what bother me) however, we do know the function has a minimum at X=T, and since the function is piecewise, so there exists a crossover point where the the endpoints alternate between being max or min. This crossover point favors the lower endpoint. Again, the derivative is discontinuous at the special point; it’s negative before the harmonic mean and positive after. The inclusion of discontinuity(s) in a exercise that seems to be a round about way of motivating the idea behind the harmonic mean is what bothers me. It does not seem logical to present the HM this way. First we are given the notion of an guesstimate of a singular value of X, then form a new assumption there must be two values of X, and then are expected to overlook some discontinuities while motivating a concept of the harmonic mean. Lacking any real analysis at this point it seems the exercise is skirting the line of being too obtuse, and so my question is: Is this exercise demonstrating the motivation for introducing the harmonic mean, or is it more of a minimal function concept with the harmonic mean idea as an appetizer? Because with the discontinuous derivatives I don’t think I would have ever answered it. Hope I made sense!

Point out an error, ask a question, offer an alternative solution (to use Latex type [latexpage] at the top of your comment):