Completing sine implementation
No. 122
Transforming arguments.
Q: |
We've reached an implementation offering good results for if . The following rules may be used to retain precision for arbitrary argument values:
The above rules allow for computation of arbitrary values by means of power series expansion limited to the interval thereby gaining high precision results. Extend your current implementation by mapping arbitrary arguments to this interval appropriately. Hint: The standard function |
A: |
For convenience reasons we start defining PI within our class:
Now we need two steps mapping our argument:
This yet sows only the result from applying the first two rules. You may also view the Javadoc and the implementation of double Math.sin(double). |