• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

The Origins Of Triginometry

Status
Not open for further replies.

trennonix

New Member
hello,
i've been thinking about this for a while now, and here it goes:
How does a calculator or any computer for that matter calculate trig functions
(lookup table; perhaps? and a linear approx in-between or Square function approx??) :rolleyes:

My research lead to somehting called the Taylor series, but that gives an approximation.
Is there's a formula that can give a precise value like Sqrt(whatever)??
 

jasonbe

New Member
hello,
i've been thinking about this for a while now, and here it goes:
How does a calculator or any computer for that matter calculate trig functions
(lookup table; perhaps? and a linear approx in-between or Square function approx??) :rolleyes:

My research lead to somehting called the Taylor series, but that gives an approximation.
Is there's a formula that can give a precise value like Sqrt(whatever)??
I'm not sure what your questions might be - whether you are interested in what was involved when people first conceived of trigonometric definitions - or how much is known about this; how a calculator - which I have recently learned at Calculator - Wikipedia, the free encyclopedia is different from a computer, processes trigonometric functions; and/or how computers can process trigonometric functions.

If you would like to learn how to do a Taylor series - if you haven't already, I would recommend preparing yourself to take some algebra, then trigonometry, first.

I am not sure what you mean by precision. Suppose I wanted to communicate how much of this page I have read. Suppose that the font type on my computer had a maximum height of so many pixels (the smallest units that make up words and graphics on a electronic screen). Let's say that it was 9 pixels. It is more, but I'll just say nine because I need a number that fits into one place value. 1 has one place value. 11 has two place values. 111 has three place values. 1111 has four place values. If I wanted to tell you where on the computer screen I was looking at, I could say that I was looking at the bottom of the first line. By line, I mean line of text - not a line of pixels. However, if I told you that I was looking 9 pixels down the screen, that would be more precise. I am looking at the same place on the screen, but nine describes it in more detail than lines of text. This is because if I was looking 8 pixels down the screen, I couldn't describe this precisely using the nuber of lines of text. I couldn't use a number of lines of text to precisely describe 8 pixels down the screen. The number of lines of text would either be 0 or 1. This number of lines of text can't be used to describe 8 pixels. This number of pixels, 8, has to be rounded up to 1 line of text or down to 0 lines of text - which is not as precise.

This example doesn't use a standardized number system, so it may not be the best example. However, I do think that it describes precision. I think that it describes precision as long as the height of the font in pixels is understood. Also, it doesn't consider the number of pixels between the lines.

There are also other ways of describing numbers besides how precise they are.
 
Last edited:

Torben

Well-Known Member
hello,
i've been thinking about this for a while now, and here it goes:
How does a calculator or any computer for that matter calculate trig functions
(lookup table; perhaps? and a linear approx in-between or Square function approx??) :rolleyes:

My research lead to somehting called the Taylor series, but that gives an approximation.
Is there's a formula that can give a precise value like Sqrt(whatever)??
Yes, there is such a formula. However, it is complex enough that running it in real-time is often not feasible, so it's common to compute the values in advance of actually running the program and store the results in a lookup table. Lookups are very fast compared to computing trig functions at runtime.


Regards,

Torben
 

hantto

Member
A calculator approximates more complex functions, as you say, with taylor series. Many of the numbers, for example the squareroot of two, is an irrational number. That is to say, it cannot be writen out exactly as a fraction. However, with taylor approximations one can get a result as arbitrary close to the real one, just by running the approximation a little longer. When to result is good enough one can stop. This is what calculator do.
 

trennonix

New Member
by precise i mean cos60 = 0.5 or cos 30 = sqrt(3)/2
pi is precise, but 3.14 is an approximation

cos x = +/- Sqrt(1 - (sin x)^2 ) is precise

is there a formula that gives me an expression of this form for any number, from which i can then find any approximation that i want
if so, please, enlighten me

Thanks
 

dknguyen

Well-Known Member
Most Helpful Member
by precise i mean cos60 = 0.5 or cos 30 = sqrt(3)/2
pi is precise, but 3.14 is an approximation

cos x = +/- Sqrt(1 - (sin x)^2 ) is precise

is there a formula that gives me an expression of this form for any number, from which i can then find any approximation that i want
if so, please, enlighten me

Thanks
If you are asking what I think you are asking, probably not because that form is pretty limiting and "any number" is unlimited. There may be a big massive obscure equation out there that can handle any cosine though. If it exists, I doubt it's general is anywhere near the simplicty of the one one you posted.

I was told that a function does exist though that was described to me as "the mother of all functions". From it came tangent, sine, cosine, taylor, a bunch whose name I now forget but would remember if I heard it. Obviously that means it was complicated and difficult to work with so it wasn't practical most of the time. I have no idea what it looks like.

EDIT: I found this...is this what you mean?
http://en.wikipedia.org/wiki/Exact_trigonometric_constants
The impression I got from a moment's glance at it looked like making a regular polygon out of triangles based on your desired trig angle and then use that to find the exact trig ratio. So it would be an algorithm, not an equation. Makes sense though...an equation would be too easy for something like this.
 
Last edited:

MrAl

Well-Known Member
Most Helpful Member
Hi,


You seem to be asking how a calculator or computer computes trig functions like
sin(x) or cos(x).

Humans like to use Taylor series because they are quite well known, probably the
most taught in schools, and have a relatively simple form and are relatively easy
to calculate. Most calculators and computers however use what are called
Chebychev polynomials to approximate various functions like sin(x) and the like
because they converge faster than Taylor. This is often accompanied by a look
up table where there are many low accuracy values stored, and the approximating
formula starts with the low accuracy value and works on it until it meets a certain
criterion that makes it accurate to the required number of digits.

I once had a computer that only did single precision trig but the other math would
do double precision, so i used a Taylor series to get the single precision numbers
more accurate. It was fairly easy to program in so i used that instead of Chebychev
(note variant spelling of Chebychev).
 

jasonbe

New Member
by precise i mean cos60 = 0.5 or cos 30 = sqrt(3)/2
pi is precise, but 3.14 is an approximation

cos x = +/- Sqrt(1 - (sin x)^2 ) is precise

is there a formula that gives me an expression of this form for any number, from which i can then find any approximation that i want
if so, please, enlighten me

Thanks
First of all, I don’t know if precision can be used to describe formulas, functions, and equations – because I think that these may be different from each other.

In most - if not all, of the examples that I have seen, the 60 in cos of 60 is a counted - not measured. I think that all things that are counted have a 100% precision, though I am not sure about this. Measuring things is different. When you count something, you are counting whole numbers - integers I think. When you are measuring something, you are making an approximation. You are not counting whole things but also parts of things. So, if it is assumed that that the 60 in cos60 is counted, then, yes, the answer is .5. It is not .51. It is not .501. It is not .5001. However, .5 could be rounded down from .51. It could also be rounded up from .49. To show that .5 is exact - If I am using the right word, we can say that it is really .5 with an infinite number of zeros after it, .50000000000... This shows that .5 has not been rounded up or down from other numbers, say, .51, .501, .5001, .50001, and so on. .50 and .51 are more precise than .5, .500 and .501 are more precise than .50 and .51. .5000 and .5001 are more precise than .500 and .501. They differ in the number of significant figures (http://en.wikipedia.org/wiki/Significant_digits) that they have, and that is how precision is measured.

Actual, I think that how the number has been measured is important too. For example, I said that .50 is more precise than .5. However, this may not be right if .50 is a measured in miles and .5 is measured in feet. .50 feet is also a more precise measurement than .5 miles. It describes the measurement in more detail. But .000000000000000000000000005 miles is probably more precise than .05 feet. Earlier I implied that something precise describes something in more detail. However, a more detailed measurement does not mean that what is being measured has any more detail. In this case, talking about locations, it just describes the location more.

If we couldn't assume that 60 was counted, then 60 might be a measurement - and not be a very precise measurement. Was 60 rounded up from 59 or down from 61? The way 60 is written, it could have been rounded. It could have also been rounded up from 59.9 or down from 60.1. If it was important to communicate that 60 was rounded from 59.9 or from 60.1, then we could include a decimal point and write 60.. The . in 60. gives the 0 - if I am saying this correctly, place value. If it was important to signify that the 0 did not hold place value, then one might write 6 * 10...(* means times). In this way, larger numbers can be written such as 600 in the form of 6 * 10^2, (^Proxy-Connection: keep-alive
Cache-Control: max-age=0

eans to the power Proxy-Connection: keep-alive
Cache-Control: max-age=0

)...6000 in the form of 6 * 10^3, 60,000 in the form of 6 * 10^4. All of these numbers, 6, 60, 600, 6000, 60,000 have one significant digit. However, 60. has two significant digits, 600. has three significant digits, 6,000. has four significant digits, 60,000. has five significant digits. Also, 6. has one significant digit, 6.0 has two significant digits, 6.00 has three significant digits, 6.000 has four significant digits, and 6.0000 has five significant digits. So, cos(60) would not be as precise as cos(60.), cos(60.) would not be as precise as cos(60.0), cos(60.0) would not be as precise as cos(60.00), and cos(60.00) would not be as precise as cos(60.000). This is describing the precision of the formula.

Let's generalize cos(60) = 0.5 into a formula, cos(x) = y. Then the precision of the answer y would depend on the precision of the variable x. So, the precision of an answer to a formula depends on values substituted into the variables of the formula - in this case there is only one variable x.

Let's say that cos(x) equals y was really 1.0*cos(x) = y. If this were the case, the 1.0 in the formula would be a coefficient (http://en.wikipedia.org/wiki/Coefficient). Let's suppose that the x in the formula was equal to 60.00000000000000000 - which is really precise - unless perhaps we were measuring millions of miles. However, if we were measuring the distance between celestial bodies then 60.00000000000000000 might be really precise. I don't know what types of measurements astronomers use – probably meters and not miles. Even if 60.00000000000000000 were measured in fractions of a meter, a person who was studying subatomic particles might not consider it very precise - even though it could be used to describe something that many people might consider small. So, we would have 1.0*cos(60.00000000000000000). Even though the value of x was really precise, let's say; the value of 1.0 isn't comparatively. The 1.0 effects the outcome of this formula - so the answer to the formula cannot be more precise than the least precise variable or coefficient. In this case 1.0 is less precise than 60.00000000000000000 - so the coefficient 1.0 makes the answer less precise. This makes the formula limited to the precision of 1.0.

If the formula was 1.00*cos(60.00000000000000000), then the formula would be more precise. And 1.000*cos(60.00000000000000000) would be even more precise. Actually, I am not sure if this generalization is correct. It may be that certain variables substituted into certain parts of an formula - such as trigonometric parts of an formula, effect the precision differently from variables substituted into different parts of an formula. In this case, this might have something to do with trigonometric formulas. However, in this example, 60.00000000000000000 is so precise - compared to 1.0, that I think that 1.0 is the factor limiting the precision.

The coefficient - 1.0 in this case, is part of the formula. So, in this case the coefficient is limiting the formula. The formula might not be able to be more precise than this coefficient. If the value substituted for x in 1.0*cos(x) = y was less precise than 1.0, then it would be the variable that might be limiting the precision of the answer - not the coefficient that was limiting. There may be different rules for addition and subtraction, powers, and different formulas - about precision. So, coefficients limit the precision of a formula. A formula can not be as precise if its coefficients are not more precise. And, coefficients and variables limit the answer to formulas. So, a variable substituted into an formula could make the answer less precise than a measure of the precision of any coefficients in the formula. However, the variables substituted into the formula cannot make it more. In formulas in which coefficients limit precision, measurements intended to be substituted into variables may not make solutions to formula more precise or precise enough if the formula in this way is limited by the precision of coefficients.
 
Last edited:

j.friend

New Member
just wanted to point out that he got his equation from
(sin(x))^2 + (cos(x))^2 =1
 

jasonbe

New Member
just wanted to point out that he got his equation from
(sin(x))^2 + (cos(x))^2 =1
Given the equation (sin(x))^2 + (cos(x))^2 = y, is there a most precise value that can be substituted for x that will result in y being equal to 0 because of precision?

Also, the examples that I gave about astronomy and subatomic particles in my last post may have been misleading.
 

jasonbe

New Member
The question may have been a lot more involved then I had at first thought. Out of curiosity, was it answered?
 

MrAl

Well-Known Member
Most Helpful Member
Given the equation (sin(x))^2 + (cos(x))^2 = y, is there a most precise value that can be substituted for x that will result in y being equal to 0 because of precision?

Also, the examples that I gave about astronomy and subatomic particles in my last post may have been misleading.

The equation:

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

is not just some general equation, it is an identity.
Identities show a relationship between different things that happens to
be universal.

This particular one is a trigonometric identity, and results from looking
at an angle 'a' and the unit circle (radius=1). Thus,
sin(a) is the X coordinate, and cos(a) is the Y coordinate,
and X^2+Y^2=R^2=1.

This means that the '1' can never change to anything else.

It's also interesting that this relationship holds for complex numbers too.
I guess the geometrical interpretation then would be a surface 1 unit
up from the x,j*y plane.
 

trennonix

New Member
The question may have been a lot more involved then I had at first thought. Out of curiosity, was it answered?
No :( ; i know what relative precision is, i wanted something of an abosolute precision (such as pie or sqrt(2))
i wanted a way to get the trigonometric lines of any angle in a nice clean formula such as: f(x)= x^2 but for cos or sin
 

MrAl

Well-Known Member
Most Helpful Member
Hi,


Here is a Taylor series for the sine of the angle x:

Code:
SIN(x)=x-x^3/6+x^5/120-x^7/5040+x^9/362880-x^11/39916800+x^13/6227020800-x^15/1307674368000+x^17/355687428096000-x^19/121645100408832000+x^21/51090942171709440000-x^23/25852016738884976640000+x^25/15511210043330985984000000-x^27/10888869450418352160768000000+x^29/8841761993739701954543616000000
Although this formula is valid for any angle x, you should first reduce x to it's principle angle for more accuracy.

You can use less terms for less accuracy.

There are other ways of calculating this too such as with the use of recursive functions, or you could use a
generator function to generate the coefficients in that formula above.
 
Last edited:

jasonbe

New Member
The equation:

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

is not just some general equation, it is an identity.
Identities show a relationship between different things that happens to
be universal.

This particular one is a trigonometric identity, and results from looking
at an angle 'a' and the unit circle (radius=1). Thus,
sin(a) is the X coordinate, and cos(a) is the Y coordinate,
and X^2+Y^2=R^2=1.

This means that the '1' can never change to anything else.

It's also interesting that this relationship holds for complex numbers too.
I guess the geometrical interpretation then would be a surface 1 unit
up from the x,j*y plane.
(sin(a))^2+(cos(a))^2=1 is an identity. But is it different from (sin(a))^2+(cos(a))^2=y? My question - perhaps asked a little better in this post, is if the precision of a could be different from the precision of y when values for either one of these variables are substituted into the equation. I think that there are different ways of determining precision when adding and multiplying, and I was wondering if there might be still more different ways for sine and cosine functions. If so, is the precision of cos(a) different from the precision of sin(a) - except at pi/4, and (5/4)*pi? What about at (3/4)*pi and (7/4)*pi?
 

jasonbe

New Member
No :( ; i know what relative precision is, i wanted something of an abosolute precision (such as pie or sqrt(2))
i wanted a way to get the trigonometric lines of any angle in a nice clean formula such as: f(x)= x^2 but for cos or sin
sin(x) = 2t/(1+t^2) and cos(x) = (1 - t^2)/(1 + t^2) are at the bottom of List of trigonometric identities - Wikipedia, the free encyclopedia. I don’t know if they are accurate, but the Wikipedia article shows how to derive them from the half-angle formula – which is shown on the same page. I suppose one could confirm them by looking up the half-angle formula and making an algebraic substitution using t = tan(x/2). I've seen θ used instead of x for angles.
 
Last edited:

MrAl

Well-Known Member
Most Helpful Member
(sin(a))^2+(cos(a))^2=1 is an identity. But is it different from (sin(a))^2+(cos(a))^2=y? My question - perhaps asked a little better in this post, is if the precision of a could be different from the precision of y when values for either one of these variables are substituted into the equation. I think that there are different ways of determining precision when adding and multiplying, and I was wondering if there might be still more different ways for sine and cosine functions. If so, is the precision of cos(a) different from the precision of sin(a) - except at pi/4, and (5/4)*pi? What about at (3/4)*pi and (7/4)*pi?
Hi,

For sin(x)^2+cos(x)^2=y, y can only be equal to 1. It's not a general
equation for y like y=2*x+1 or something like that.

If you make the precision of sin(a) different than cos(a) then you
no longer have sin and cos, you have something else.

What is your purpose for making the precision different?

BTW, if we want to prove those identities for t=tan(x/2)
instead of tan(x/2) we would substitute cos(x/2)/sin(x/2) and
reduce the result. The result would be sin(x) or cos(x) depending
on which of those two equations in t were chosen.
 

Tesla23

Member
No :( ; i know what relative precision is, i wanted something of an abosolute precision (such as pie or sqrt(2))
i wanted a way to get the trigonometric lines of any angle in a nice clean formula such as: f(x)= x^2 but for cos or sin
There are many approximation formulae out there, here are some classics:
Handbook of mathematical functions. Note that you can't get absolute precision, but you can get precision as good as the floating point number you are using to represent the answer.
 

jasonbe

New Member
Hi,

For sin(x)^2+cos(x)^2=y, y can only be equal to 1. It's not a general
equation for y like y=2*x+1 or something like that.

If you make the precision of sin(a) different than cos(a) then you
no longer have sin and cos, you have something else.

What is your purpose for making the precision different?

BTW, if we want to prove those identities for t=tan(x/2)
instead of tan(x/2) we would substitute cos(x/2)/sin(x/2) and
reduce the result. The result would be sin(x) or cos(x) depending
on which of those two equations in t were chosen.
I became interested in precision because of what trennonix wrote.

I'm not sure what you meant when you said that there would be something else besides what I was expecting to be sin(a) and cos(a).

Am I correct in thinking that there are different ways that precision is determined for answers after adding, multiplying, and raising a number to a power? I thought that there was, and thought that the ways for cosine of x and sine of x might be the same as those for multiplication - because from what I understand multiplication has a lot in common with division. Sine and cosine are the result of dividing - a side of a triangle by the hypotenuse of the triangle. However, I was guessing that this wouldn't apply when calculating a derivative or an integral of a sine or cosine function because I think that the sides of a triangle that are used to calculate the quotient change at different rates according to the angle in the function. For example, I think that the rate that a sine function changes near zero degrees is at its maximum - measured to be one, and the rate that a sine function changes after a quarter turn is zero.
 
Last edited:
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top