How are complex functions like trigonometric or hyperbolic calculated on computers or scientific calculators?

1.82K views

Computers either have an integer processing unit and/or a basic floating point unit. Using series expansions must take a lot of time if high accuracy is required. So how is say, tan(34.5) calculated so fast?

In: Engineering

2 Answers

Anonymous 0 Comments

Because most calculators of limited power don’t use the slow functions. They use specifically chosen approximations, Taylor series, etc. and optimise the algorithm towards whatever the processor does best – e.g. integer operation, fixed-point or floating-point, multiplications, additions, bitwise operations, etc.

If you choose the right algorithm it can converge to a calculator-number of digits very quickly, probably only a handful of iterations of maybe a few dozen operations each. Even at 1KHz, that means almost no time at all to converge to something you can display to 10 decimal places, even if you have to prep the numbers involved, use a weird algorithm, and then convert back from integer to float at the end.

You are viewing 1 out of 2 answers, click here to view all answers.