subject
Computers and Technology, 24.04.2020 20:40 hjfcjds

Given a double variable named x that has been declared and given a value , let's use a binary search technique to assign an estimate of its square root to another double variable , root that has also been declared . let's assume that x's value is greater than 1.0 -- that will simplify things a bit . here's the general idea: since x> 1, we know its square root must be between 1 and x itself. so declare two other variables of type double (a and b say) and initialize them to 1 and x respectively. so we know the square root must be between a and b. our strategy is to change a and b and make them closer and closer to each other but alway make sure that the root we're looking for is between them. (such a condition that must always hold is called an invariant.)to do this we will have a loop that at each step finds the midpoint of a and b. it then squares this midpoint value and if the square of the midpoint is less than x we know that the root of x must be bigger than this midpoint: so we assign the midpoint to a (making a bigger and shrinking our a and b interval by and we still can be sure that the root is between a and b. of course if the midpoint's square is greater than x we do the opposite: we assign b the value of midpoint. but when to stop the loop? in this exercise, just stop when the interval between a and b is less than 0.1 and assign root the midpoint of a and b then. we call this a binary search also because at each stage we cut the interval under consideration in half. efficient as this method is, old isaac newton discovered an algorithm that is even more efficient and that's what the library function sqrt uses

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 04:31
Type the correct answer in the box. spell all words correctly. the managing director of a company sends a christmas greeting to all his employees through the company email. which type of network does he use? he uses an
Answers: 1
question
Computers and Technology, 24.06.2019 02:00
Write an expression that will cause the following code to print "equal" if the value of sensorreading is "close enough" to targetvalue. otherwise, print "not equal". ex: if targetvalue is 0.3333 and sensorreading is (1.0/3.0), output is:
Answers: 1
question
Computers and Technology, 24.06.2019 10:00
When writing a business letter, how many times can you use the same merge field in a document? once once, unless using the address block feature unlimited it will depend on the type of document you choose
Answers: 1
question
Computers and Technology, 24.06.2019 16:30
You may see the term faq on websites which stands for frequently asked questions this is an example of which type of mnemonic? a) poem b) acronym c) acrostic d) abbreviation ken has dipped many dark chocolate marshmallows (which you remember the metric system distance units in decreasing order: kilometers, hectometer, decameter, centimeter, millimeter) is an example of which type of mnemonic? a) poem b) acronym c) acrostic d) abbreviation !
Answers: 1
You know the right answer?
Given a double variable named x that has been declared and given a value , let's use a binary search...
Questions
question
Mathematics, 25.10.2019 06:43
question
Mathematics, 25.10.2019 06:43
question
Mathematics, 25.10.2019 06:43
Questions on the website: 13722361