How to express two variables in two other variables

95 Views Asked by At

If:

$A=R\cos x$ and $B=R\sin x$

Then how can I express $R$ and $x$ in terms of $A$ and $B$ in a rigorous way? Meaning that I take the domain and range in account?

I tried: $$\cos x=\frac{A}{R}$$ $$x=\arccos\frac{A}{R}$$ Filling it in in the second equation gives: $$B=R\sin\arccos\frac{A}{R}$$ $$B=R\sqrt{1-\frac{A^2}{R^2}}=\sqrt{R^2-A^2}$$ $$R=\sqrt{A^2+B^2}$$ Furthermore: $$\frac{B}{A}=\frac{R\sin x}{R\cos x}=\tan x$$ Therefore: $$x=\arctan\frac{B}{A}$$ However, I feel maybe this could be done in a more simple way, and also I am not sure whether this is rigorous when it comes to range and domains. Any help is appreciated!

2

There are 2 best solutions below

1
On BEST ANSWER

You have a problem that $x$ and $R$ are not uniquely defined by $A$ and $B$. If you have a given $A$ and $B$, then for any valid $x$ and $R$ you also have

$$A=R\cos(x+2k\pi), \quad B=R\sin(x+2k\pi)$$ and $$A=(-R)\cos(x+(2k+1)\pi), \quad B=(-R)\sin(x+(2k+1)\pi)$$ for $k\in\Bbb Z$.

So to get unique values of $x$ and $R$ you will need to set limits, such as

$$R\ge 0, \quad -\pi < x \le \pi$$

Even then, the pair $A=0,\ B=0$ will have infinitely many values of $x$. But other than that special case, with those restrictions each $A$ and $B$ will defined a unique $x$ and $R$.

Here is a simpler way to get the value of $x$. If $A\ne 0$ then $R \ne 0$, and

$$\begin{align} \tan x &= \frac{\sin x}{\cos x} \\[2ex] &= \frac{R\sin x}{R\cos x} \\[2ex] &= \frac BA \end{align}$$

But note that this does not work for $A=0$. Also note that this does not uniquely define $x$: for any such $x$ the values $x\pm\pi$ also satisfy the equation, so you get two such values of $x$. If one such $x$ is in the first quadrant then another valid $x$ is in the third quadrant, and if one such $x$ is in the second quadrant then another valid $x$ is in the fourth quadrant, and vice versa.

The usual solution to those problems is to avoid the arctangent function but to rather use the atan2 function. You can then uniquely define $x$ by

$$x=\operatorname{atan2}(B,A)$$

Note that some computer systems use $\operatorname{atan2}(A,B)$ instead.

You get the appropriate unique value of $R$ by

$$\begin{align} \sqrt{A^2+B^2} &= \sqrt{(R\cos x)^2 + (R\sin x)^2} \\[2ex] &= \sqrt{R^2(\cos^2 x + \sin^2 x)} \\[2ex] &= \sqrt{R^2\cdot 1} \\[2ex] &= R \end{align}$$

remembering that we restricted $R\ge 0$.

So the final answer is

$$x=\operatorname{atan2}(B,A)$$ $$R=\sqrt{A^2+B^2}$$

This gives the unique $x,R$ that satisfy $-\pi<x\le\pi,\ R\ge 0$, with the sole exception of $A=0,\ B=0$ which would allow any value of $x$. But that solution always works.

If you do not like the atan2 function, the Wikipedia article on atan2 gives some other ways to express the same result, but those other ways are much more verbose.

0
On

Draw a right angle triangle with angle $x$ and hypotenuse of length 1. You will immediately see that $B^2 + A^2 = R^2$. Any number of trigonometric identities may then be used to express $x$.