Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫  π  -¹ ² ³ °

You are not logged in.

## #1 2005-09-30 15:14:25

mikau
Member
Registered: 2005-08-22
Posts: 1,504

### I need sine, cosine and tangent functions for C++ :-(

I'm writing some awsome programs using math but I really really really need access to sine, cosine and tangent functions, also I really could use arcsin, arccos, and arctan, but arctangent the most since I need to convert from rectangular form to polar form and back.

Someone gave me a link to the formulas for sine, cosine and tangent, which was great and they appear to work, but they call a lot of factorials and very large numbers "270^5" :-O

If anyone knows where I can get a copy of the source code for functions for sine, cosine, tangent, arcsine, etc. so I can just copy the definition into my program and call on it when I need it. It would be a MAJOR help!

A logarithm is just a misspelled algorithm.

Offline

## #2 2005-10-02 07:14:47

mikau
Member
Registered: 2005-08-22
Posts: 1,504

### Re: I need sine, cosine and tangent functions for C++ :-(

A logarithm is just a misspelled algorithm.

Offline

## #3 2005-10-02 10:42:31

MathsIsFun
Registered: 2005-01-21
Posts: 7,664

### Re: I need sine, cosine and tangent functions for C++ :-(

For performance I would use the standard include "math.h" - it has sin cos and tan.

Example:

#include <stdio.h>
#include <math.h>

#define PI 3.141592654

int main () {
double angle;
angle = 10;
double ans;
ans = sin (angle*PI/180);
printf ("Ans = %lf ", ans );
return 0;
}

Or did you need more accuracy or something?

"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

## #4 2005-10-04 12:56:58

mikau
Member
Registered: 2005-08-22
Posts: 1,504

### Re: I need sine, cosine and tangent functions for C++ :-(

Thats exactly what I'm looking for! :-D Thanks a yotta, Mathisfun!

A logarithm is just a misspelled algorithm.

Offline

## #5 2005-10-04 13:16:37

mikau
Member
Registered: 2005-08-22
Posts: 1,504

### Re: I need sine, cosine and tangent functions for C++ :-(

wow, sometimes please does work!

A logarithm is just a misspelled algorithm.

Offline

## #6 2005-10-04 13:23:55

mikau
Member
Registered: 2005-08-22
Posts: 1,504

### Re: I need sine, cosine and tangent functions for C++ :-(

Hey it works! Thanks again mathisfun! Are there functions for arcsin, arccos, and arctan?

A logarithm is just a misspelled algorithm.

Offline