Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I'm writing a program and I need to write a method that will give me the angle of a specific angle of a triangle when I know only the adjacent length and opposite length. I know that $\tan(A) = \frac{\text{opposite side}}{\text{adjacent side}}$ but how would I solve for $A$ in that equation?

share|cite|improve this question
Have you heard of inverse trigonometric functions. See here... – user21436 Jan 13 '12 at 18:53
Never have been taught that in school, thank you very much! – Steven Rogers Jan 13 '12 at 18:55

In terms of software, you have two options: you can search for a trig library that will make inverse tan available as a function/method or you can construct a look-up table. A look up table could be a two-dimensional array with angles from 0 to 180 in one column and corresponding inverse tan values in the other column.

share|cite|improve this answer
A look-up table will be cumbersome if the input angles are allowed to be non-integers. – Austin Mohr Jan 13 '12 at 21:16

Basically, as George Watts said, you're looking for the inverse tangent function. Depending on what programming language, that's probably a function called atan or arctan or some variant of that.

As you said you're working in a right triangle, the angle you're looking for is $0<\theta<\frac{\pi}{2}$ (it's most likely that the function in your programming language will give an answer in radians, not in degrees) and $$\tan\theta=\frac{\text{opposite leg}}{\text{adjacent leg}}\;\;\Leftrightarrow\;\;\theta=\arctan\left(\frac{\text{opposite leg}}{\text{adjacent leg}}\right).$$

Note that if you're not exactly trying to find an acute angle in a right triangle (e.g. if you're trying to find the angle of inclination of a line), you might be better off with the 2-argument arctan function (often atan2) or some other technique.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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