I have an adjacent and opposite. I think I can use: tan(x) = opposite / adjacent but how do I get the tangent inverse? Please help! <<snipped email>>
This is a discussion on tan inverse within the C Programming forums, part of the General Programming Boards category; I have an adjacent and opposite. I think I can use: tan(x) = opposite / adjacent but how do I ...
I have an adjacent and opposite. I think I can use: tan(x) = opposite / adjacent but how do I get the tangent inverse? Please help! <<snipped email>>
Welcome to the forum, dwelliott!
We don't email replies, however. The forum policy is YOU need to post up your attempt at a program code, and THEN we will attempt to answer your specific questions about the problem.
Right here.
I suspect if you Google for "inverse of a tangent", you'll have your answer in short order.
The easiest way, I suppose, is to expand the inverse tangent function into a series.
Just using wolfram alpha, you can re-write atan(x) into x - (x^3)/3 + (x^5)/5 - (x^7)/7 + ...
So what you wanna do is, take your opposite over adjacent value and then plug it into that formula I just posted. The more terms the more accurate it is. Also, write an exponent routine because Idt C has one built into it. I think this gives you the answer in radians as well.
The inverse tangent is directly computed by atan() in math.h.
Asking for the inverse tangent of x just means that you want a measure (in radians, in C) whose tangent is x. Arc tangent is just another name for this.
https://www.khanacademy.org/math/tri...ctions--arctan
Hmm... I'm pretty sure math.h's routine would use the expansion, wouldn't it? You easily decide the number of terms to keep based on data type, couldn't you?
Otherwise, don't you have to have a look-up table of values?
C99 and POSIX.1-2001 and later provide atan2(y,x), which yields the angle between the positive axis and (x,y), including the quadrant. If x>0, atan2(y,x) = atan(y/x).
Many architectures do have an arctangent function built-in. Using the polynomial is quite rare; something like CORDIC atan2() is very simple and quite efficient, especially if you need to use software emulation for the result type. (If you need the full precision of the result type, you need extended precision for the temporaries, or some other way to correct the least significant bit(s) of the result.)
Good catch. Even the man page I linked to mentions that (for atan2(), for double argument and result); I should have checked and not relied on my memory!
Right. They are also available on some very limited architectures, like GCC with emulated floating-point on ARM, where there is very little available RAM or ROM. The CORDIC implementations of sin, cos, atan and atan2 are simple enough and only need a table of about 64 values for full double support. As only substraction, addition, and bit shifts are needed, it's very easy to implement even for software-emulated numeric types.
CORDIC itself is OLD; the first academic paper is from 1959 (Jack E. Volder, "The CORDIC Trigonometric Computing Technique," IRE Transactions on Electronic Computers, Vol. EC-8, pp.330-334, 1959.
one nice feature about programing in Linux is the use of man pages. If you are not programming in Linux, then hit up google and do a search for "man math.h" you will find your answer there.
I add this for the simple reason that you can perform this task on many features in C then when you have done so and have some code, post the code here for further detailed help.
There are some great folks in these forums that are very skilled at programming.
No need to search; the Linux man-pages project lives at kernel org. There is even a nice list of all library function man pages. Even if the man pages are Linux-oriented, they do mention which standards define the functions, and whether the functions are part of C89 or C99, in the Conforming to section in each man page.