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

You are not logged in.

## Post a reply

Write your message and submit
|
Options

## Topic review (newest first)

Polly
2005-09-08 00:49:55

hi peeps not bin on 4 ages and stsrted bak at school today

John E. Franklin
2005-09-08 00:49:38

Those are two very nice calculators!  I'm impressed.  I started writing my large digit calculation program yesterday, so I'll continue with that.  Plus, I'm not very good at examining programs written by others, and I like writing things from scratch.

MathsIsFun
2005-09-07 22:34:42

#### John E. Franklin wrote:

You could with perhaps 20 times more programming, teach the program how to multiply, divide, add, and
subtract out to a large number of decimal places stored in an array.  I might try that some day...

Or ...

... you might like to improve *this* !

mikau
2005-09-07 13:15:53

Well I wrote a perfectly working function for sine but my compiler is screwing up. :-( Its a pretty cool function though.

John E. Franklin
2005-09-07 07:17:57

The following web page says you can use any value of x in the cosine summation and the sine too.
Your recommendation is a good one to get the angle within the four quadrants.  You might even
be more accurate if you stay with the first quadrant and alter the signs as needed.

http://euclideanspace.com/maths/algebra … /index.htm

mikau
2005-09-06 22:37:08

Might be a good idea to first automaticly reduce the arguement. I don't know this languagel but, as the first step of the function, in C++ you could just say

float sine(float x)
{
while ( x >= 360)
{
x = (x - 360);
}

/* insert formula for sine here*/

}

since adding 360 degree's to an angle has no effect on its sine, cosine or tangent, the value returned will be correct, and more accurate.

John E. Franklin
2005-09-06 09:07:21

It works in all four quadrants, but the floating point math isn't that precise in this language I used
so when you try angles like 3600 degrees (ten times around a circle), you get really inaccurate answers.
You could with perhaps 20 times more programming, teach the program how to multiply, divide, add, and
subtract out to a large number of decimal places stored in an array.  I might try that some day...

MathsIsFun
2005-09-06 08:39:47

Code looks right to me. Does it work in all quadrants (90° to 360°) ?

John E. Franklin
2005-09-06 07:52:15

I wrote this in Just BASIC v1.0.
It computes the cosine of angles 0, 5, 10, 15, 20, 25, 30, ... to 90 degrees.
The computation of cosine of 90 degrees comes out about 10^-15, not exactly zero though.

#### Code:

```'Note: dangle is angle in degrees and rangle is angle in radians
for dangle = 0 to 90 step 5
pi = 3.141592653589793238462643383279502884197169399375105820974944
rangle=(pi*dangle)/180
'Note:  cos(x) = 1 - x^2/2! + x^4/4! - x^6/6! + ...
rangleSqrd=rangle * rangle
diver = 0
nextTerm = 1
cosineNow = 1

for iter=1 to 10
for d1 = 1 to 2
diver = diver + 1
nextTerm = nextTerm / diver
next d1
nextTerm = 0 - nextTerm
nextTerm = nextTerm * rangleSqrd
cosineNow = cosineNow + nextTerm
next iter
print "Cosine( ";dangle;" ) = ";cosineNow
next dangle```
ryos
2005-09-06 05:35:47

"^" means to raise to a power. It's necessary on plain text documents that don't support superscripts. It's also an operator in many programming languages, including, I think, C/++, so you can use it in your programs to raise things to a power.

mikau
2005-09-06 03:30:08

Hmm...what does "^" mean? Is that something used in calculus or something? Never enountered it in my math book.

ahgua
2005-09-05 22:03:06

It is better to remember "TOA CAH SOH". It means "fat old woman" in hokkien (If I remember correctly ).

ryos
2005-09-05 16:14:13

This may help.

If it doesn't, I'll have a go at translating it for you.

Of course, if your program is such that you know the lengths of at least two of the sides of your triangle, you can compute the trig functions using SOH CAH TOA.

mikau
2005-09-04 09:48:11

I would like to right some simple C++ programs to do some vector calculations and stuff but I need a way to calculate sine, cosine and tangent. I take it most computers have the formula's built in somewhere but I think it might be educational (mathematicly) and good programming practice to write my own algorithm. I've seen a few differant formulas for more or less accurate calculations on the internet but the explanations are often quite confusing. Using words to express yourself is not what mathematicians do best.

Basicly I wan't to define the following functions: float sin( float x); float cos(float x); float tan(float x);

So I can just call sin(x) cos (x) or tan(x) anytime I need them.