4

I asked a similar question in high school and people started laughing as they thought like it's trivial.

We only learn to memories the values cosine function but not even in college we're we taught how exactly it works.

Trig functions as far as I was taught in college were defined as infinite series. But if I plugged pi in that infinite series I see no reason why it would converge to - 1 for the cosine function trig series or why that series definition would be equivalent to the geometric one.

The relation to the geometric definition is not the central point but if you will talk about it I would appreciate AVOIDING COORDINATES IN YOUR ANSWERS AND COMMENTS, I find them extremely detrimental to conceptual reasoning.

I think it probably the easisent explanation lies in complex numbers, but I don't know if that would be satisfactory.

Matko
  • 171
  • 1
    CORDIC is a common algorithm –  Feb 29 '20 at 13:23
  • See this question on StackOverflow – MPW Feb 29 '20 at 13:23
  • I changed the title a bit. It's not so much about code and computers. It's about a mathematical computation. – Matko Feb 29 '20 at 13:25
  • You mean how the Taylor series for sine/cosine work? – Toby Mak Feb 29 '20 at 13:26
  • Why was this closed? – Matko Feb 29 '20 at 13:30
  • 1
    Not sure why it was closed. The linked question doesn't seem similar to your question. The question you're asking is really non-trivial and in fact one should assert first how $\pi$ is defined. Some define $\pi$ exactly as a root of trigonometric functions. Others define it via the complex exponential function. See maybe this question for some reference. – blat Feb 29 '20 at 13:39
  • @blat yea this is the question that is basically a duplicate. But looking now through the answers of it I don't think they are good enough. – Matko Feb 29 '20 at 13:56

2 Answers2

1

An early way to do it was to start with a small angle with known values, and repeatedly using the formulas for half angles until getting a small one, and then complete a table using sum formulas.

Euler derived power series for the triginometric functions, and also found rapidly converging series for $\ln \sin x$ and so on, which were arguably more useful (trigonometric functions are often used in products).

Both the above were used to compile tables fir calculation.

Today CORDIC is popular, another option is to use a Padé approximation (a ratio of polynomials, that can be tuned to give almost uniform absolute error).

vonbrand
  • 27,812
  • I think I maybe wast too clear. I just wanted to know how theoretically (mathematically) does one compute trig functions. I mean you just plug it in the Calc and like magic it plugs out. But I don't even mathematically know why those series would compute those values. – Matko Feb 29 '20 at 14:07
  • 1
    @Marko, check the derivation of e.g. the series for $\sin x$ in your nearest calculus/analysis textbook. – vonbrand Feb 29 '20 at 19:09
1
  • If the needed precision is known in advance, then best approximations polynomials or rational functions (w.r.t maximum norm) are a way to go. They are pre-computed, e. g. using Remez' algorithm) stored and evaluated as needed.

  • CORDIC might be a way on systems with limited resources. Whether it performs better depends on many factors: you need small absolute error or relative error (like with IEEE), instruction set,...

  • If precision is not known in advance, Taylor series is a good candidate.

  • Some computers have FPU, but that just shifts the problem.

  • On very limited hardware like 8-bit micro controllers, lookup tables are a consideration for low precision.

  • In any case, one wants to apply functional equations like $\sin x=\sin (x+2\pi)$ for argument reduction so that the very approximation need only consider a range of input values known in advance.

  • If the approximation shall minimize relative error like for IEEE floating point, then zeros are an issue and you approximate different functions. For example, instead of approximating sin in 0...π/2 by a best polynomial, you'll instead approximate $f(x) =\sin(\sqrt x)/\sqrt x$ for $x$ in 0...π2/4 and use $\sin x=xf(x^2)$.Notice that $f(x) \neq0$ for the values in question and ƒ is smooth.

emacs drives me nuts
  • 10,390
  • 2
  • 12
  • 31
  • I think I maybe wast too clear. I just wanted to know how theoretically (mathematically) does one compute trig functions. I mean you just plug it in the Calc and like magic it plugs out. But I don't even mathematically know why those series would compute those values. – Matko Feb 29 '20 at 13:53
  • So you question is supposed to ask why sin has that specific Taylor series? – emacs drives me nuts Feb 29 '20 at 14:08
  • And why that series converges to zero when you plug in pi – Matko Feb 29 '20 at 14:09