The babylonian algorithm for square root approximation

Assignment Help JAVA Programming
Reference no: EM131449931

Lab Project: The Babylonian Algorithm (Java Loops)

The Babylonian Algorithm for Square Root Approximation

Perhaps the first algorithm used for approximating the square root of S is known as the "Babylonian method", named after the Babylonians, or "Heron's method", named after the first-century Greek mathematician Heron of Alexandria who gave the first explicit description of the method. It can be derived from (but predates by 16 centuries) Newton's method.

The basic idea is that if x is an overestimate to the square root of a non-negative real number S then S/x will be an underestimate and so the average of these two numbers may reasonably be expected to provide a better approximation.

More precisely, assuming S is a positive number:

1. Make a guess at the answer (you can pick S/2 as your initial guess).
2. Compute r = S / guess.
3. Set new guess = (guess + r) / 2
4. Go back to step 2 until the last two guess values are within 1% of each other1.

To complete this lab project:

1. Create a new NetBeans project named CPS150_Lab19.

2. Delete the auto-generated CPS150_Lab19.java source file in the new project.

3. Download and import the replacement CPS150_Lab19.java source file into your project.

If needed, refer to the online instructions on importing a Java source file into a NetBeans project.

4. Add your section number in the top comment block:

/*
* CPS 150
* Algorithms & Programming I
*
* Section *** enter your section number here ***

* Spring 2017
*/

5. Add your name in the comment block after the @author tag:

/**
* Lab Project 19
* The Babylonian Algorithm
*
* @author
*/

6. Complete the method definitions for the following methods in CPS150_Lab19.java:

o static double getInput(double min)
o static double sqrt(double S)

Notes

1. See Section 5.8 (Floating-point comparison) in Chapter 5 (Java Branches) of the course zyBook.

Reference no: EM131449931

Questions Cloud

What is the operating cash flow or OCF : Hailey, Inc., has sales of $19,720, costs of $9,310, depreciation expense of $1,980, and interest expense of $1,470. What is the operating cash flow, or OCF?
Explain how you tell a story or paraphrase : Explain how you tell a story or paraphrase in your own words and keep its meaning.Explain how personal and cultural views on plagiarism might present challenges
What amount does this monthly withdrawal amount exceed : By what amount does this monthly withdrawal amount exceed $375?
Find the present values of these ordinary annuities : Find the present values of these ordinary annuities. Discounting occurs once a year.
The babylonian algorithm for square root approximation : The Babylonian Algorithm for Square Root Approximation. Delete the auto-generated CPS150_Lab19.java source file in the new project.
What is the full capacity level of sales : Wonder Women Cosmetics currently has $21,900 in sales and is operating at 45% of the firm's capacity. What is the full capacity level of sales?
Compounded biweekly assuming : What is the value of $100, rounded to the nearest whole dollar, in 9 years at 12% compounded biweekly assuming there are 52 weeks in a year?
Find the total present value of those costs : Calculate the cost (inflated at 6%) for each year of college and find the total present value of those costs,
Explain how the company will track sales and receipts : How the company will track sales and receipts, and the application will report in to a central server to collect all the sales data from all the locations.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Determine the purpose of using javascriptr on a website

write a 200- to 300-word short-answer response to the followingwhat is the purpose of using javascriptr on a website?

  Create a class that inherits from your pizzaorder class

Create a class that inherits from your PizzaOrder class called SeatedPizzaOrder. SeatedPizzaOrder has the three data values that any PizzaOrder has (size, toppings, and price) but also has a tablenumber.

  Micks wicks makes candles in various sizes create a class

micks wicks makes candles in various sizes. create a class for the business named candle that contains data fields for

  Java coding if-else while loop

Code a while loop that keeps printing "You are a DEDICATED student!" as long as the user enters an attendance rate of 90% or greater. Assume the loop-control variable, attendance, is already declared along with input for the Scanner class. The w..

  A program with main() would produce output below

A  program with main() would produce output below - Your code ...Calling getLargestUncommonDigit()

  Program that takes the amount a person has spent

Program that takes the amount a person has spent and determines the discount ($15 per $175 spent).

  Xml assignment help please follow instructions in the

please follow instructions in the attached assignment instructions. ltbrgtplease follow instructions in the attached

  Develop a java based gui application using swing that

develop a java based gui applicationusing swing that allows the user to enter charityfund informationwrite the

  Create an equals method for every physical class

Create an equals method for every physical class. Make attributes private Have get and set methods to access items in the shopping list Have defined class constructors

  Replace the submit button

Replace the submit button (type="submit")with a regular button (type="button").  Once the buttonis clicked, display the user inputs in an HTML table below the form, if validations are successful

  Write a java program

Create a "JApplet" that contains two parallel arrays with at least five friends' names and phone numbers. Allow the user to enter either a name or phone number and to click a "JButton" to display the other.

  Design and implement the class day

Design and implement the class Day that implements the day of the week in a program. The class Day should store the day, such as Sun for Sunday. The program should be able to perform the following operations on an object of type Day: Set the day

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd