3 ms·
A C program computes sine by linking to a program, sin(), that computes it. Usually the program works by examining the argument provided and using various equi
by drallison 11y ago
A C program computes sine by linking to a program, sin(), that computes it. Usually the program works by examining the argument provided and using various equivalence formulas to reduce the range to an interval for which there is a good Tchebysheff polynomial or Pade rational approximation to sine. All this is done keeping an eye on the representation and the potential for rounding errors. Some of the computation may be done with integers, some the mantissa and exponent independently, and so forth. A good knowledge of machine arithmetic, arithmetic error propagation, and machine performance is needed to make a universally acceptable sine function for C.