"Release" the variable on the left side of equation I have a particular formula (source) for solar azimuth angle, which I would like to derive in a way, that on the left side I have teta only(that's the solar azimuth angle) and on the left side everything else.
The initial formula goes like this:
cos(180 - teta) = - (sin(lat)*cos(phi) - sin(decl)) / (cos(lat)*sin(phi))

What I tried is to "release" the teta on the left, like so:
cos(180)*cos(teta) + sin(180)*sin(teta) = - (sin(lat)*cos(phi) - sin(decl)) / (cos(lat)*sin(phi))

-1*cos(teta) + 0*sin(teta) = - (sin(lat)*cos(phi) - sin(decl)) / (cos(lat)*sin(phi))

- cos(teta) = - (sin(lat)*cos(phi) - sin(decl)) / (cos(lat)*sin(phi))

cos(teta) = (sin(lat)*cos(phi) - sin(decl)) / (cos(lat)*sin(phi))

teta = arccos((sin(lat)*cos(phi) - sin(decl)) / (cos(lat)*sin(phi)))

Is this correct?
The problem is that when using this last formula with certain variables, the result does not look correct.
Thank you for the help.
 A: The problem is this: suppose I tell you that $\cos \theta = 0.7071$. You may say "OK, so $\theta$ is 45 degrees." But it's also possible that $\theta = 315$ degrees. Just knowing the cosine doesn't tell you the angle. 
Arccos is a great function...but it doesn't fix the problem I've described. "$\arccos(s)$" will give you the angle, $r$, between 0 and 180, whose cosine is the number $s$. But there's always another such number as well, namely $-r$ (or $360-r$, if you prefer). So you cannot, from the information you've got so far, hope to actually recover the angle "teta". 
A: You have solved the first equation for $\theta$ correctly, you could have used the shortcut $\cos(180^\circ-\theta)=-\cos\theta$ though.


*

*According to the source your $\theta$ is measured clockwise from north, where it is  $\theta=0$, but in the trigonometric circle the angles are measure from $(1,0)$ anticlockwise.

*The range of the inverse trigonometric function $\theta=\arccos x$ is $0^\circ\le \theta\le 180^\circ$, but in the full trigonometric circle ($[0^\circ,360^\circ]$) there are two angles $\theta$ with the same $\cos \theta=x$. Let $\theta_1,\theta_2$ be those angles and $\cos \theta_1=\cos \theta_2=x$. If $0^\circ\le \theta_1\le 180^\circ$, then $\theta_2$ is such that $\theta_1+\theta_2=360^\circ$, which mean that both $\theta_1,\theta_2$ lie on the right or the left half-plane containing the trigonometric circle. So $180^\circ\le \theta_2\le 360^\circ$. Hence only knowing if $\theta$ is on the upper half-plane or on lower-upper plane, you can decide for $\theta_1$ or $\theta_2$. 


Example: If $\theta_1=60^\circ$, then $\theta_2=360^\circ-60^\circ=300^\circ$, and $\cos 60^\circ=\cos 300^\circ=1/2$, while $\theta=\arccos 1/2=60^\circ$ only. If the solution of your equation is $\theta=300^\circ$, the formula teta = arccos((sin(lat)*cos(phi) - sin(decl)) / (cos(lat)*sin(phi))) will not give it.
