Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have a question Natural Logarithm The natural logarithm is a function that has many scientific applications and often shows up on your calculator as

I have a question

image text in transcribed
Natural Logarithm The natural logarithm is a function that has many scientific applications and often shows up on your calculator as the button . For this lab, we will focus simply on computing In(2), which is ~0.69. One way to compute In(2) is to compute the following infinite series: 1-12+ 1/3-/4+ /s.". Obviously, you and your computer don't have infinite time, so instead we will find an approximation by evaluating just the first n terms of the series. 1. Write 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 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. c) Sum the series forwards in two halves, computing the positive and negative terms separately, using type double variables and literals. d) Sum the series backwards in two halves, computing 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. Display the results from each of these methods in a table-like format, clearly labeling your 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(). Hints Use constants in your program where you can. . Make sure you document your programs properly, including name, student number, purpose, etc. 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 1e from above; each of the other methods will be similar

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions