The function Q_sin_table rounds its argument to the nearest degree and then returns the sine stored in

Question:

The function Q_sin_table rounds its argument to the nearest degree and then returns the sine stored in the precomputed table for that degree. This can be made more accurate by linearly interpolating between the degrees that bound the input angle. For example, if the input value, as a fixed-point number in some \(Q m . n\) representation, is equivalent to 45.4 degrees then \(Q_{-}\)sin_table will round down to 45 degrees and return 0.70710678 as the sine. The actual sine of 45.4 degrees is 0.71202605 so the returned value underestimates the true value.

In linear interpolation the values that bound the input, in this case \(45<45.4<\) 46 degrees, are used to determine the line between the values, \(y=m x+b\), with \(m=\left(y_{2}-y_{1}\right) /\left(x_{2}-x_{1}\right)\) and \(b=y_{1}-m x_{1}\) where \(x_{1}=45, x_{2}=46, y_{1}=\sin \left(x_{1}\right)\) and \(y_{2}=\sin \left(x_{2}\right)\). Then, \(\sin (45.4)\) is equal to \(m(45.4)+b\).

In this case, then, the improved answer is \(\sin (45.4)=m(45.4)+b=0.71199999\) with \(m=0.01223302\) and \(b=0.15662088\) for a difference on the order of \(2.6 \times\) \(10^{-5}\) when compared to the true result. This is better than the difference of \(4.9 \times\) \(10^{-3}\) by simply rounding to the nearest degree. Add linear interpolation to Q_sin_table.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Numbers And Computers

ISBN: 9783319172606

1st Edition

Authors: Ronald T Kneusel

Question Posted: