Question: I am having trouble with this problem. Can someone show me their code and JavaDoc it to help me understand better. I am using Eclipse
I am having trouble with this problem. Can someone show me their code and JavaDoc it to help me understand better. I am using Eclipse (Java) to code. Thnaks!
1st Part: Write a program, TaylorSeries, that implements two methods one for calculating sin(x) and one for calculating cos(x) using the Taylor series expansion. The method signatures should be:
public static double sin(double x)
public static double cos(double x)
For this problem use only while loops. Terminate calculation when the term, (-1)nx2n+1(2n+1)! and (-1)nx2n(2n)!respectively, reaches 0.
The Taylor series for sin(x) and cos(x) can be found here: Commonly Used Taylor Series. Hint: You can compare your results against the methods Math.cos(x) and Math.sin(x) from the Math library.
2nd Part: Add two additional methods to the program TaylorSeries:
public static double sin(double x, int numIterations)
public static double cos(double x, int numIterations)
That calculate the sin and cos of x up to a given number of iterations specified as input parameter. For this methods use only for loops.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
