3
$\begingroup$

I have a graphics problem that reduces to this:

(Computer equation)

alpha = arctan(X / ((Y / (Z * cos(alpha) - k)) * Z * cos(alpha))) 

(LaTeX)
$\alpha = \arctan \left( \displaystyle \frac{x}{\displaystyle \left( \frac{yz\cos(\alpha)}{z\cos(\alpha)-k} \right)} \right)$

I need to solve for $\alpha$. Obviously, there's no closed form. I know $\alpha$ is around $13.5^{\circ}$. Is it "wimpy" of me just to use $13.5$ on the right hand side to get an approximation? Or would "a real man" use Newton-Raphson, or bisection, or something?

2 Answers 2

5

Take $\tan$ on both sides and you get an algebraic equation in $\cos \alpha$, once you replace $\tan \alpha = \sin \alpha/ \cos \alpha$ and use $\sin^2 \alpha + \cos^2 \alpha=1$.

  • 0
    I just implemented the Wolfram Alpha solution in my Java program, and yes, it really works. :-) Thanks so much; I'll think twice before ever saying "Obviously, there's no closed form" again. :-)2011-06-02
3

If you have an approximate solution, iteration can be a good way to get a numeric answer. If you think of your iteration as $\alpha_{i+1}=f(\alpha_i)$, it will converge as long as $\left|\frac{d\alpha_{i+1}}{d\alpha_i}\right|\lt 1$ and will converge quickly if it is much less than $1$. It saves you the work of taking the derivative for Newton-Raphson and converges faster than bisection if the absolute value of the derivative is less than 0.5. You lose the bracketing property of bisection, so want to make sure your function is well-behaved.

  • 3
    +1 If the iteration in this form does not converge , you can also try "inverting" it, isolating the cosine, and getting a similar iteration with $\alpha = arccos(...)$2011-06-01