Numerical Approximation Involving Trig

219 Views Asked by At

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?

3

There are 3 best solutions below

2
On BEST ANSWER

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

1
On

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.

0
On

As @lhf suggested, tzking the tangent on both sides, you end with $$\tan(\alpha )-\frac{x \sec (\alpha ) (z \cos (\alpha )-k)}{y z}=0$$ Using the tangent half-angle substitution $\alpha=2 \tan ^{-1}(t)$, this becomes $$\frac{x (k-z)+2 y zt+ x (k+z)t^2 } {yz(1-t^2) }=0$$ If nothing cancels the denominator, solving the quadratic gives $$t=\frac{\sqrt{z^2 \left(x^2+y^2\right)-k^2 x^2}-y z}{x (k+z)}$$