I'll start by saying I'm no mathematician, so excuse my stupid question. I was doing my math homework, CS student, and I stumbled upon this formula for approximating the difference between the hypotenuse and the opposite.
$$C - A = \frac{B^2}{2C}$$ where $C$ is the hypotenuse, $A$ is the opposite, and $B$ is the adjacent.
The formula (?) is more accurate the smaller $B$ is in relation to $A$.
I only came across it because the task at hand required finding the difference which was smaller than what floats allow, so I couldn't use $\sqrt{a^2 + b^2} - a$.
Could anyone explain why it works?
Notice that $$c-a = \dfrac{(c-a)(c+a)}{c+a} = \dfrac{c^2-a^2}{c+a} = \dfrac{b^2}{c+a}.$$
If $b$ is much smaller than $a$ and $c$, then, $c$ will only be slightly larger than $a$ and so $\dfrac{b^2}{c+a} \approx \dfrac{b^2}{2c}$.