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?

$\endgroup$
5
$\begingroup$

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$.

$\endgroup$
  • 1
    $\begingroup$ See a solution by Wolfram Alpha. $\endgroup$ – lhf Jun 1 '11 at 16:25
  • $\begingroup$ 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. :-) $\endgroup$ – George Freeman Jun 2 '11 at 2:33
3
$\begingroup$

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.

$\endgroup$
  • 3
    $\begingroup$ +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(...)$ $\endgroup$ – leonbloy Jun 1 '11 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.