I am interested in seeing how math.h functions such as sin(),cos(), pow(,), log(),... are carried out. The math.h files within my Cygwin and MinGw folders seem only have function declarations {such as extern double cos _PARAMS((double));}. Where are the actual function definitions located?
Asked
Active
Viewed 1,877 times
1
-
2After some quick googling, take a look at [this](http://www.nongnu.org/avr-libc/user-manual/math_8h_source.html) – scohe001 Jul 29 '14 at 19:05
-
http://stackoverflow.com/questions/6208488/implementation-of-math-functions and http://stackoverflow.com/questions/4541130/definitions-of-sqrt-sin-cos-pow-etc-in-cmath – Cory Kramer Jul 29 '14 at 19:08
-
I'm not asking how use the functions from math.h. Rather, I am interested in knowing how they are made (such as with Taylor series) – philn Jul 29 '14 at 19:15
-
Err, the question which this is marked as duplicate of doesn't seem to have anything to do with this question. Instead this seems to be duplicate of the questions linked by Cyber. – eerorika Jul 29 '14 at 19:36
2 Answers
1
I think what you are looking for is that sine and cosine are implemented in microcode inside microprocessors
You may also check this

Rahul Tripathi
- 168,305
- 31
- 280
- 331
-
My company is looking for new processors. Can you list some processors that have instructions (assembly) that calculate since and cosine? – Thomas Matthews Jul 29 '14 at 19:10
-
@ThomasMatthews:- The version for Intel x86 processors is written in assembly. It simply uses the FPU's built-in fsin instruction. – Rahul Tripathi Jul 29 '14 at 19:10
0
Math functions may be in the compiler's executable, so there may be no code to show.
There are Free Software examples of compiler code. I suggest you take a look at the GNU compiler source code for some examples.
Processor manufacturers may also have some implementations, that are platform specific to maximum use of their processor.

Thomas Matthews
- 56,849
- 17
- 98
- 154