Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Write a single program containing several methods that will compute the sum of the first n terms of the series in the specific
1. Write a single program containing several methods that will compute the sum of the first n terms of the series in the specific manners outlined below. (Let n = 100,000 to start and if you have time, try a million terms.) a) Sum the series forwards (first term first), using type double variables and literals. b) Sum the series backwards (last term first), using type double variables and literals. sum the series forwards in two halves by computing the sum of the positive terms separately from the negative terms and then combining the results at the end. Use type double variables and literals. c) d) Sum the series backwards in two halves, computing the sum of the positive and negative terms separately, using type double variables and literals. e) Sum the series forwards (first term first), using type float variables and literals. f) Sum the series backwards (last term first), using type float variables and literals. 2. Have your program display the results from each of these methods in a table-like format, clearly labeling the output. Use 15 decimal places in your output. In a separate paragraph speculate about which result you consider the most accurate (including your calculator), and what accounts for any discrepancies, if there are any. You may also want to compare your result against the math library method log(). When you write the literal value 3.1415 Java assumes the data type is double. When you write 3.1415f you force the data type of the literal to be a float. The suffix 'f' is important when you need a literal to be a float type. I would expect the signature of each method to be of the following form: private static float sumForwards (int numberOfTerms) {...} This one satisfies le from above; each of the other methods will be similar. 1. Write a single program containing several methods that will compute the sum of the first n terms of the series in the specific manners outlined below. (Let n = 100,000 to start and if you have time, try a million terms.) a) Sum the series forwards (first term first), using type double variables and literals. b) Sum the series backwards (last term first), using type double variables and literals. sum the series forwards in two halves by computing the sum of the positive terms separately from the negative terms and then combining the results at the end. Use type double variables and literals. c) d) Sum the series backwards in two halves, computing the sum of the positive and negative terms separately, using type double variables and literals. e) Sum the series forwards (first term first), using type float variables and literals. f) Sum the series backwards (last term first), using type float variables and literals. 2. Have your program display the results from each of these methods in a table-like format, clearly labeling the output. Use 15 decimal places in your output. In a separate paragraph speculate about which result you consider the most accurate (including your calculator), and what accounts for any discrepancies, if there are any. You may also want to compare your result against the math library method log(). When you write the literal value 3.1415 Java assumes the data type is double. When you write 3.1415f you force the data type of the literal to be a float. The suffix 'f' is important when you need a literal to be a float type. I would expect the signature of each method to be of the following form: private static float sumForwards (int numberOfTerms) {...} This one satisfies le from above; each of the other methods will be similar.
Step by Step Solution
★★★★★
3.40 Rating (147 Votes )
There are 3 Steps involved in it
Step: 1
Heres an example in Java that computes the sum of the series using the specified methods java public ...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