To write a better function for arctangent, we will need to use the fact that
If you want to take this identity as given, you can skip to the next assignment where the formula is used. If you want some proof, read on.
In the triangle above, we can see that
This last equation further tells us that
Now we need the following half-angle formula:
There are a number of proofs of this formula that are readily available on the web. See, for example, Half Angle Formulas/Tangent.
Now we can finally derive the formula we need. Substituting our values of sin and cos into the half-angle formula gives us:
So now we know that
Taking the arctangent of both sides gives
which tells us that
But we have already seen above that
So
which is what we wanted to prove.