# Condition number of $a^2-b^2$

Can someone tell me how to count Condition number of $a^2-b^2$ or recommend a site where I can read about this. I know how to count Condition number of a matrix, but here I'm confused

-
Does this answer satisfy you? –  Rustyn Feb 1 '13 at 23:39

Example: Suppose we want to evaluate the expression $z = a^2 - b^2$. With $(a,b)=(10^8,10^8)$ we get $z=0$..., but with $a = 10^8+.01$, $b=10^8$ we get $z \approx 2\times 10^6$. So we would probably say that this expression is ill-conditioned when evaluated for $(a,b)$ near $(10^8,10^8)$.

On the other hand, if we use, $a = 1.01 \text{ and } b = 1$, and we get $z=.0201$. We would say this it is well-conditioned for $(a,b)$ near $(1,1)$.

### Definition

The condition number of a function with respect to an argument measures the asymptotically worst case of how much the function can change in proportion to small changes in the argument. The "function" is the solution of a problem and the "arguments" are the data in the problem.

Let $$f(x) = a^2 - b^2$$ Where $$x = \begin{bmatrix} a \\ b\end{bmatrix}$$
The condition number of $f$ at a point $x$ (specifically, its relative condition number) is then defined to be the maximum ratio of the fractional change in $f(x)$ to any fractional change in $x$, in the limit where the change $\delta x$ in $x$ becomes infinitesimally small: $$\lim_{ \varepsilon \to 0^+ } \sup_{ \Vert \delta x \Vert \leq \varepsilon } \left[ \frac{ \left\Vert f(x + \delta x) - f(x)\right\Vert }{ \Vert f(x) \Vert } / \frac{ \Vert \delta x \Vert }{ \Vert x \Vert } \right],$$ where $\Vert \cdots \Vert$ is a norm on the domain/codomain of $f(x)$.

If $f$ is differentiable, this is equivalent to:

$$\frac{\Vert J \Vert}{ \Vert f(x) \Vert / \Vert x \Vert},$$

where $J$ denotes the Jacobian matrix of partial derivatives of $f$ and $\Vert J \Vert$ is the induced norm on the matrix.
Using the one norm I get: $$\frac{\Vert J \Vert}{ \Vert f(x) \Vert / \Vert x \Vert} = \frac{\left\Vert \begin{bmatrix} 2a \\ -2b \end{bmatrix} \right\Vert_{1} }{\Vert a^2 - b^2 \Vert_{1}/\Vert [a, b]^{T} \Vert_1} = \frac{2|a| + 2|b|}{|a^2 - b^2|/(|a|+|b|)} = \frac{2(|a|+|b|)^2}{|a^2-b^2|}$$ Which has the nice form: $$\frac{2(|a|+|b|)}{|a-b|}$$ Assuming $a,b>0$.

As a motivating example, with $a=3,b=2.999$ $$\kappa \approx 12,000$$ Which is consistent as: $$f\left(\begin{bmatrix} 3 \\ 2.999 \end{bmatrix}\right)= 0.005999 \approx 0$$ Yet $$f\left(\begin{bmatrix} 3 + .1 \\ 2.999 - .1\end{bmatrix}\right)= 1.2058$$ Yet the magnitude of their difference vector is: $$\text{norm}\left(\left(\begin{bmatrix} 3 \\ 2.999 \end{bmatrix}\right) - \left(\begin{bmatrix} 3 + .1 \\ 2.999 - .1\end{bmatrix}\right)\right)_{2} = \sqrt{\left(\frac{1}{50}\right)} \approx 0.1414213562373095048801688724209698078569671875376948$$