Suppose we are working with a machine that does arithmetical calculations with a relative accuracy of $\xi, |\xi| \leq \xi '$. We want to calculate $a^2 - b^2$ in the following two ways; $(A);$ $a^2 - b^2 = (a - b)(a+b)$ and $(B)$; $a^2 - b^2 = a \times a - b \times b$. Suppose $a$ and $b$ are machine numbers. Show that the relative error of the result using method $A$ is at most $3\xi'$ and $\frac{1 + (a^2 + b^2)}{|a^2 - b^2|}\xi'$ using method $B$.
The first part (method $(A)$) is not so difficult but I am making a mistake in the second part. Let's start by calculating $a \times a$. This should be equal to $a^2(1+\xi) = a^2 + a^2\xi$. Similarly, $b \times b = b^2 + b^2\xi$. Substracting these two terms gives $(a^2 + a^2\xi - b^2 + b^2\xi)(1+\xi)$ which is equal to $a^2 + a^2\xi - b^2 - b^2\xi + a^2\xi + a^2\xi^2 - b^2\xi - b^2\xi^2$. If we ignore the terms involving $\xi^2$ then we get $a^2 - b^2 + 2\xi(a^2 - b^2)$ and so the relative error is at most $2\xi'$. Obviously this is not even close to the answer I am supposed to be getting but I am not sure where I went wrong.
For the second part of the question, we assume that $a$ and $b$ are not machine numbers. Show that the relative errors are given by $\frac{3 + 2(a^2 + b^2)}{|a^2 - b^2|}\xi$ and $\frac{1 + 3(a^2 + b^2)}{|a^2 - b^2|}$ respectively. I am not really sure what happens when $a$ and $b$ are not machine numbers, besides the fact that we have some sort of extra approximation error that we need to calculate, however I can't find any info on how to do this.
$$3 \xi$$ $$\left({{b^2+a^2}\over{\left| b^2-a^2\right| }}+1\right)\xi$$
$$\left({{\left| b\right| +\left| a\right| }\over{\left| \left| b\right| - \left| a\right| \right| }}+4\right)\xi$$
$$\left({{3,\left(b^2+a^2\right)}\over{\left| b^2-a^2\right| }}+1\right)\xi$$
– miracle173 Jan 27 '14 at 02:06