Google Answers Logo
View Question
 
Q: trigonometry ( Answered 2 out of 5 stars,   6 Comments )
Question  
Subject: trigonometry
Category: Science > Math
Asked by: re3579-ga
List Price: $99.50
Posted: 10 Aug 2002 07:40 PDT
Expires: 09 Sep 2002 07:40 PDT
Question ID: 52957
I want a method (however laborious it might be) for creating a
trigonometric table of sine functions from scratch.  That means no
already existing tables of any kind can be used.  That also means that
no tables built into calculators or software packages can be used
either.  Also, physical measurement is not allowed.  The entries in
the resulting table must be accurate to at least 6 decimal places. 
The table that I build will be used to find the sine of an angle.  For
example, sin(43).
Answer  
Subject: Re: trigonometry
Answered By: websearcher-ga on 10 Aug 2002 09:03 PDT
Rated:2 out of 5 stars
 
Hi re3579-ga:

There are different methods for finding values of the sine function
without using existing tables (either physical or in
software/calculators) or making physical measurements. The one that I
would recommend for you is the Taylor Series approximation.

The Taylor Series approximation for the sine function states that:

sin(x) = x - x^3/3! + x^5/5! - x^7/7! + x^9/9! - ... +
(-1)^(n-1)*x^(2n-1)/(2n-1)! + ....

For more information on the derivation of this series (if you're
interested) see:

http://www.efunda.com/math/taylor_series/taylor_series.cfm

All the calculations here require only addition (+), subtraction (-),
exponentiation (^), and the factorial operator (!). These calculations
can be done by hand, on most calculators (without using sine tables)
or using a spreadsheet (like Excel).

When using this approximation, you need to keep in mind that the angle
"x" needs to be in *radians* and must also be between -180 degrees and
+180 degrees (or pi and +pi radians).

**********THE PROCESS*************
STEP 1: If your angle is not between -180 and +180 degrees, just add
or subtract 360 degrees (as appropriate) to the value until it does
fall in that range.

STEP 2: To compute radians from degrees (which you appear to be
working with), simply multiply the degrees value times pi/180. So, if
the angle in degrees is "d", then:

x = d * pi/180

Of course, you are going to have to use an approximation for the value
of pi (which is an irrational number - that is, its decimal
representation goes on forever without repeating). I will provide you
with the first 100 decimals of pi:

pi=3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068

To get 6-digit accuracy, I suggest that you use seven digits for pi.
(It's typically a good idea to use more digits in your calculations
than are in your desired accuracy.) The more digits you use, the more
accurate your answer will be with fewer terms in the series. (However,
the more digits you use, the more complicated your exponentiations
become!)

pi=3.141592 (approximately)

If you use 7-digit accuracy for pi, you need to continue using 7-digit
accuracy for all your other calculations, including for x and sin(x).

STEP 3: Plug in your approximation for x (found in Step 2) and
calculate the Taylor series for the first four terms in the series.
That is:

sin(x) = x - x^3/3! + x^5/5! - x^7/7!  (approximately)
sin(x) = x - x^3/6 + x^5/120 - x^7/5040  (approximately)

Step 4: Round off the value you get in Step 3 at the number of
decimals accuracy that you want (in your case, 6 digits).
**************************************

Let's try the process for your sample value of sin(43)....

Step 1: 43 is in the desired range, so no changes are needed.

Step 2: x = 43 * 3.14159/180
          = .7504909445
          = .7504909     (to seven digits)

Step 3: sin(x) = .7504909 - (.7504909)^3/6 + (.7504909)^5/120 -
(.7504909)^7/5040
               = .7504909 - .07045066 + .001984019 - .00002660648
               = .6819976525 

Step 4: sin(x) = .681998 (to six digits)

For purposes of this demonstration, we can check this value using
Maple, a math software tool with infinite precision. sin(43 degrees)
to 100 digits accuracy is:

sin(43)=.6819983600624985004422257847111255803404338027619434028783078530675368818749557216140022386820037506

As you can see, the value is accurate to six digits.

If you want the value to be accurate to more than six digits, simply
repeat the process from the beginning using more digits of pi and more
digits throughout the calculations. If you go beyond 7-digit accuracy,
then it would be a good idea to add another term to the Taylor Series.
In fact, make the exponent of your last term in the series equal to or
greater than the number of digits accuracy you want and you should be
safe. For example, if you wanted 8 digits of accuracy, then use 9
digits of pi and the series:

sin(x) = x - x^3/3! + x^5/5! - x^7/7! + x^9/9!

There are many excellent pages on this method on the web, including:

http://www-math.mit.edu/~djk/18_013a/chapter10/section02.html
http://www.marypat.org/stuff/nylife/010206.html
http://faculty.rmwc.edu/tmichalik/sine.htm

I hope this answers your question. If you need clarification of
anything before you rate this answer, please ask - I'm happy to help.

Search Strategy: personal knowledge

On Google, you can try: calculating sine values "by hand"

websearcher-ga

Request for Answer Clarification by re3579-ga on 10 Aug 2002 11:18 PDT
This answer seems to be close.  But I can find PI in a table of
constants and magic numbers.  No already existing tables of any kind,
please.

Clarification of Answer by websearcher-ga on 10 Aug 2002 13:35 PDT
Hi re3579-ga:

Hmmmmmmmm......Let's see if we can work this out.....

First a few provisos.....

In the Taylor Series method I outlined above, the value of pi isn't
really used in the formula

sin(x) = x - x^3/3! + x^5/5! - x^7/7! + x^9/9! - ... +
(-1)^(n-1)*x^(2n-1)/(2n-1)! + ....
 
which is what is used to approximate the sine. Pi is merely used to
get the angle value in the "proper" unit system - radians.
Calculations of any difficulty in trigonometry are computed in
radians, not degrees.

As well, "tables" of values that you are trying to avoid typically
list values of a function, f, at different values of a variable, x -
giving f(x). Pi is not a function, but a known value, just like 1, 2,
3, 7, etc. I'm pretty sure you are not going to find a formula for
estimating sin(x) that doesn't involve pi (or other known constants)
in one way or another - especially not if you are working from a value
in degrees. The Taylor Series approximation is optimal in that pi is
not used in the calculation itself, but in the setup alone (when you
are working from degrees).

However, if you are still concerned with using the value of pi as
found in the table you cite, then the following page has many formulas
for approximating pi to various numbers of digits accuracy:

http://mathworld.wolfram.com/PiApproximations.html

Some of the ones with fewer "complicated" operations (like square and
cube roots) include:

(355/113) * (1 - 0.0003/3533)            (good to 15 digits)

(553/(311+1))^2                          (good to 7 digits)

(1700^3+ 82^3-10^3-9^3-6^3-3^3)/69^5     (good to 12 digits)  

So, you could, if you wanted, rewrite the Taylor Series approximation
of sin(x) to four terms, *leaving x in degrees*, as:

sin(x) = (x*(355/113)*(1-0.0003/3533))/180 - 
         ((x*(355/113)*(1-0.0003/3533))/180)^3/6 + 
         ((x*(355/113)*(1-0.0003/3533))/180)^5/120 - 
         ((x*(355/113)*(1-0.0003/3533))/180)^7/5040  

Making, 

sin(43) = (43*(355/113)*(1-0.0003/3533))/180 - 
         ((43*(355/113)*(1-0.0003/3533))/180)^3/6 + 
         ((43*(355/113)*(1-0.0003/3533))/180)^5/120 - 
         ((43*(355/113)*(1-0.0003/3533))/180)^7/5040 
 
This would still give you six digits accuracy. 

Does that solve your concerns? :-)

Thanks. 

websearcher-ga

Request for Answer Clarification by re3579-ga on 10 Aug 2002 19:51 PDT
No.  You see, I want to be able to do this "from scratch".  That means
that I start with no magic numbers.

You are right that some tables are functions, but some tables are just
tables of formulas, or special constants or special numbers, like e. 
For example, a table of special constants would have one column for
description, another column for symbol and another column for a value.
 There would be several entries.  PI, e, golen mean, etc.

After all, if I am given one magic number, why not give me all the
magic numbers that comprise the table of sines?  Where do we draw the
line?  So starting truely from scratch won't leave me wondering where
some intially supplied magic number came from.

Even though I am not asking for this, such a method would allow me to
find to any accuracy I want.  Any "non-table" method that works with 6
places will automatically work with more than 6 places, I think.   It
would be well worth it if a method was found starting with no magic
numbers, and yet at the same time it's good to only 6 decimal places,
although I doubt that's possible.  In any case, something good to more
than 6 decimal places is also a good answer.

Addition, multiplication, division, subtraction, square roots are all
fine.  Methods involving series, successive approximations are also
fine.  In short, any method that doesn't require an initial special
number whose accuracy affects the accuracy of the final results is
good.  So for exsample, a series that uses some whole number
multiplier would be just fine.

Clarification of Answer by websearcher-ga on 10 Aug 2002 21:23 PDT
[I accidentally also posted this clarification as a comment....] 

Hi re3579-ga: 
 
Well, I think I understand what you're asking for a little bit better
now.
 
I'm afraid, however, that what you are asking for doesn't already
exist in mathematical parlance - and is beyond the scope of me (and I
believe anyone else) to create from scratch. I have a university
degree in Mathematics and have been writing math texts for about 10
years and have never run across an approximation method for sin(x)
that doesn't require at least one of the following:
 
* physical measurement  
* some sort of "initial special number" whose accuracy affects the
accuracy of the final number
* use of radians instead of degrees.  
 
If you were willing to list your values of x in radians instead of
degrees (which is the "mathematical" way of expressing angles), then
the Taylor Series expansion
 
sin(x) = x - x^3/3! + x^5/5! - x^7/7! + x^9/9! - ... +  
(-1)^(n-1)*x^(2n-1)/(2n-1)! + ....  
 
would be *exactly* what you're looking for - a series of whole number
multipliers with no measurement, no special numbers, and infinite
precision (as long as your willing to compute more and more terms).
 
I'm truly sorry that I can't help you more than this.  
 
If you feel that this answer is unsatisfactory, please feel free to
rate it accordingly or ask for a refund.
 
Thank you.  
 
websearcher-ga
re3579-ga rated this answer:2 out of 5 stars

Comments  
Subject: Re: trigonometry
From: rbnn-ga on 11 Aug 2002 00:46 PDT
 
Perhaps it would be possible to compute pi, e, etc. from taylor
series, or use one of the many fast series expansions for these
constants.
Subject: Re: trigonometry
From: maniac-ga on 11 Aug 2002 09:09 PDT
 
Hello re3579,

Perhaps I can provide some insight into a "different way" to first
calculate pi using some more primitive methods and then calculate sine
and cosine using geometry. To give you an idea of why I know this, I
had a freshman computing problem similar to this one to compute Pi in
college. This may be closer to what you were originally requesting.

Consider a circle with radius one centered at the origin of the plane
(area is Pi). Place a unit square with its lower left corner at the
origin of a plane (area is one, covers 1/4 of the circle). Divide the
range of zero to one along the X and Y axis into a number of equally
spaced divisions. For the example, I will go up in powers of two since
you can divide a line in half precisely with geometric methods and
could (with care) continue to do so to arbitrary accuracy. You may
want to draw this out on graph paper to follow along.

The initial square has four sub-squares, one completely enclosed by
the circle and four (wholly or) partially enclosed by the circle. So
the initial estimate of Pi is between one and four. Divide the four
squares into sixteen. The lower bound for Pi is now 4*8/16 (2.0) and
upper bound is now 3.75. With 64 squares, the lower bound is 4*43/64
(2.730158) and the upper bound is now 4*58/64 (3.625). You can
continue in this way to get better and better accuracy.

This doesn't converge very quickly and I forget how many million
squares you need to get 7 digit accuracy. To program the computer to
do this, you can determine if the square is "wholly inside" or
"partially inside" the square by using (x*x + y*y) for the upper right
and lower left vertex of each small square and comparing with one. As
you noticed, I only did the calculations for 1/4 of the circle and
multiplied by four to get the answer. When you do each bisection,
optimize the algorithm by remembering the squares you last found the
answer on each row / column.

Now, we have a value for Pi to the desired accuracy. You "know" the
values of sine and cosine for a few points - zero degrees, 90 degrees,
180 degrees, and 270 degrees from the relationship that sine is the Y
coordinate of the point on the unit circle and cosine is the X
coordinate of the point on the unit circle. In this way, we get ...

    Sine   Cosine
  0  0.0     1.0
 90  1.0     0.0
180  0.0    -1.0
270 -1.0     0.0

Divide the zero to 90 degree angle in half to get 45 degrees. We know
that x*x+y*y = 1.0 and x=y, so x = y = sqrt(2)/2 or about .707....
From the squares we generated to compute Pi, we can generate the
square root value if you don't want to use another method for that
purpose. That will likely require more squares however :-) to get your
six digit accuracy. Using symmetry, we now have values for 45, 135,
225, and 315 degrees.

Continue to bisect the angles until you get angles "close enough" to
the requested values for angles and get the required accuracy of the
sine and cosine values. To give you an ideal of the number of angles
needed, two raised to the 10th power is 1024, two to the 20th is
1,048,576.

In this way, you can compute both Pi and the sine and cosine values
without using any of the taylor series approximations and "could" do
the calcuations without anything more complicated than a ruler,
compass, a large flat area, a marker, and a lot of patience.

  --Maniac
Subject: Re: trigonometry
From: tne-ga on 11 Aug 2002 20:42 PDT
 
Method by Euler
This method uses a very simple equation but requires a very large
number of terms to be calculated to get an fairly accurate value of
pi.

Formula: 
pi^2/6 = sigma i=1...infinity 1/i^2

you can approximate pi using this with no tables and then use Taylor's
series.
No tables :)
Subject: Re: trigonometry
From: nando-ga on 19 Aug 2002 20:46 PDT
 
I'm not sure why this hasn't been brought up yet, but Pi was
traditionally calculated from the arctangent Taylor series:

arctan(x) = x - x^3/3 + x^5/5 - x^7/7 ...

We know (from a simple geometric argument) that the tangent of a 45
degree angle is 1.  A 45 degree angle is equivalent to a Pi/4 radian
angle (recall that a full circle is 360 degrees or 2 radians).
Because we know that tan(Pi/4) = 1 we also know that Pi = arctan(1)*4

So...
Pi = 4*(1 - 1/3 + 1/5 - 1/7 + 1/9 .....)

The primary drawback to this method is that you need to include a LOT
of terms if you expect any degree of precision.
For example using the first 1000 terms only gets you the first 3
digits of Pi!
This isn't the most efficient way to estimate Pi (in fact it's a
pretty inefficient method), but it only requires a basic understanding
of trigonometry and Taylor series expansions to see why it works.
Subject: Re: trigonometry
From: alpertron-ga on 20 Aug 2002 11:04 PDT
 
This a copy of a message I posted to sci.math usenet newsgroup on Nov
11, 1997. I think it answers re3579-ga question (the post below is
about cosines, but you can use the identity sin x = cos(90°-x)

=========================================================================
Hello,

It is not necessary to convert from degrees to radians (or to know the
value of Pi) to compute the sine or a cosine of an angle expressed in
degrees.

For example, using the relation:

(cos a)^2 = (1+cos 2a)/2

I wrote the following program in QBASIC to compute the cosine of an
angle between 0 and 90 degrees:

INPUT A
DIM C(20)
FOR I = 1 TO 20
  A = A * 2
  IF A > 90 THEN
    C(I) = 1
    A = 180 - A
  ELSE
    C(I) = 0
  END IF
NEXT I
Z = SQR(.5)
FOR I = 20 TO 1 STEP -1
  IF C(I) = 1 THEN Z = -Z
  Z = SQR(.5 * (1 + Z))
NEXT I
PRINT Z

Of course it does not converge very fast, but it does not use the
number
Pi.

=========================================================================
Subject: Re: trigonometry
From: eldog-ga on 14 Dec 2002 20:55 PST
 
hi re3579,

I have a simple solution that should be 
routine to implement, if extremely tedious.

First restrict yourself to the first quadrant.

Now approximate the angle you want by 

90 p/q

i.e.  is the angle is greater than 90/2 or less than 90/2
etc. etc.

Observe DeMoivre's formula gives

cos(90 p/q) + i sin(90 p/q) = (cos(90/q) + i sin(90/q))^p

All we need is p < q for the first quadrant.

So we can say 

cos (90 p/q) = Re ((cos(90/q) + i sin(90/q))^p)

and 

sin(90 p/q) = Im ((cos(90/q) + i sin(90/q))^p)

Recursive expressions for these quantites are then

cos (90 p/q) = Re ((cos(90/q) + i sin(90/q))^p)
             = Re ((cos(90/q)+i sin(90/q))(cos(90/q)+ i sin(90/q)^(p-1)))
             = Re ((cos(90/q)+i sin(90/q))(cos(90(p-1)/q)+ i sin(90(p-1)/q)))
             = cos(90/q)cos(90(p-1)/q) - sin(90/q)sin(90(p-1)/q)
similarly

sin(90 p/q) = sin(90/q)cos(90(p-1)/q) + cos(90/q)sin(90(p-1)/q)

It seems like some closed form could be found.

In any case the quantites can be expanded into a 2-variable polynomial in 

cos(90/q) and sin(90/q)

Now if we require that q is a power of 2 i.e.

q = 2^n  

(this is probably what you would do anyway when you were taking the 
intial approximation)

Then we can use the usual half angle formulas to give

cos(90/(2^n))= sqrt((1+cos(90/2^(n-1)))/2)

sin(90/(2^n))= sqrt((1-cos(90/2^(n-1)))/2)

which are positive as we are in the first quadrant.

Now we can express all of our

cos(90/(2^n))'s and sin(90/(2^n))'s into these massive, ugly
nested radicals until all we see are rational numbers, nested roots and
cos(90)'s and sin(90)'s.

cos(90) = 0 and sin(90) = 1, so plug in and we are done.

The better the initial approximation the closer the end 
result will be since these functions are continuous.  In fact
the error in the result is bounded by the error 
in your initial approx. by the simple observation 

|cos(x) - cos(y)| less than or equal to |x-y| and
|sin(x) - sin(y)| less than or equal to |x-y|


Hope that this is closer to what you were looking for!!

Everything is recursive, so it should be pretty straight
forward to program.

No tables, just 3 formulas.  Proofs for these formulas should be
pretty easy to find on the web.  good luck!

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy