Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a method to approximate exp(x) = e x by using the Taylor's series expansion. The Taylor's series expansion formula is e x = 1

Write a method to approximate exp(x) = ex by using the Taylor's series expansion. The Taylor's series expansion formula is

ex = 1 + x1/1! + x2/2! + x3/3! + x4/4! + . . .

so for example: e = e1 = 1 + 1 + 1/2! + 1/3! + 1/4! + . . .

(Remember that n! = n * (n-1) * (n-2) * ... * 1.)

Consider how to terminate the loop. A good way to terminate is checking that the recently added term is small enough, smaller than some threshold you have set.

Steps to use:

1. Create a Java file TaylorSeriesForE.java and appropriate class within it.

2. Give your class a method approxmiateE()

This method should have two double parameters x and threshold, in that order.

It should return the double approximation to ex using the Taylor's series expansion above.

Use a do while loop, exiting the loop when the most recently added term is smaller than threshold

3. The Main.java code will instantiate an object from your class, call it with some threshold, and print the output.

4. Do not use Math.E or Math.exp().

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

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago