Question: We want to evaluate sin(x) using a power series. We know that sin(x) = x - x 3 /3! + x 5 /5! - x

We want to evaluate sin(x) using a power series. We know that

sin(x) = x - x3/3! + x5/5! - x7/7! +...

Here x is measured in radians. We know that this series converges for all x. However, it will take much longer to converge when x=1000 than when x=1. We know the following facts about sin(x).

sin(-x) = -sin(x), so, if x < 0, we can replace it with an x > 0

sin(x + 2) = sin(x), so, if x >= 2, we can replace it with an x < 2

sin(x + ) = -sin(x), so, if x >= , we can replace it with an x <

sin(/2 + x) = sin(/2 - x), so, if x >= /2, we can replace it with an x < /2

Therefore we can always reduce x to the range 0 x < /2. We can reduce it further by noticing that

sin(/4 + x) = cos(/4 - x), so, if x >= /4, we can replace it with an x < /4

Write a program using double precision numbers to calculate sin(x), for arbitrary x. First find an equivalent x in the range 0 x < /2. If x <= /4, use the power series for sin(x) to calcluate sin(x). If x /4, then reduce it to /2 - x, which will be < /4, and use the power series for cos(x). In each case, sum the series until | tn | 1.0E-12. Take =3.14159265358979, or use a built-in value for . Print the value of sin(x) you computed, the value of sin(x) returned by the built-in function, and number of terms you summed. Do this for

x = 0.1, .2, 0.3, ..., 1.6, 10.0, 15.7, 31.4, 47.1, 62.8, 78.5, 94.2.

by using java.. Than you so much

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!