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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started