1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Pie
3 years ago
7

Given a double variable named x that has been declared and given a value, let's use a binary search technique to assign an estim

ate 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 half!)-- 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.00001 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.

I have this:

double a=1, b=x;
double mid;

while(a-b>0.00001){
mid=(a+b)/2;
mid=mid*mid;
if (mid a=mid;
else if(mid>x)
b=mid;
else
root=mid;
}
Computers and Technology
1 answer:
lord [1]3 years ago
5 0

Answer:now

Explanation:

That’s tough

You might be interested in
The activity spikes during black Friday sales in the holiday season but significant stress on a major retailers website what fea
Elza [17]

Answer:

My Nav is the right answer.

Explanation:

Net asset value (NAV) describes a fund's per part exchange value. NAV is calculated by separating the complete value of all the money and securities in a fund's responsibility, minus any mortgages, by the number of exceptional shares. The NAV estimation is necessary because it shows us how much one portion of the fund is worth.

4 0
3 years ago
You type. The word "weather" when you ment "whether" when will the writer or word flag this as a misspelling or a grammar proble
xxTIMURxx [149]
Most likely depends on the situation
8 0
3 years ago
What EFC number will enable a student to receive the full amount of a Pell<br> Grant?
Eddi Din [679]

Answer:

I'm pretty sure to get the absolute maximum amount the EFC has to be 0 or really close to it. The EFC, or Expected Family Contribution, is mainly determined by your family's income. If your family has multiple students who will be enrolled in college, the number may be lower. It's not really about what number a student "should" have though, because the only way for you to lower it yourself is to lie, and you really don't want to do that-if you are found to have lied on your FAFSA there can be some serious legal consequences.

5 0
3 years ago
Audio tools support reading fluency by
Artist 52 [7]

Answer:

The answer is "demonstrating how a text is read".

Explanation:

Audio tools like Text to Speech are commonplace in programs like Duolingo. They offer you a somewhat accurate example of how to properly pronounce a word or phrase.

4 0
4 years ago
Read 2 more answers
Need help with 3.2 lesson practice questions (edhesive)​
Vinvika [58]

Answer:

<h2>Doesn't have a question</h2>

Explanation:

<h2 /><h2>THANK YOUU</h2>
7 0
3 years ago
Other questions:
  • The different between a compiler and a translaror
    9·2 answers
  • Which commercial email provider is most closely associated with Apple devices?
    9·1 answer
  • Someone who participates online for social reasons usually has a:
    9·1 answer
  • I accidentally pressed the challenge button while I was scrolling through. I didn't mean to press that challenge, instead of the
    11·2 answers
  • How do you use a iPad when it has a password ?
    9·2 answers
  • We learned that an ideal multiple access protocol has FOUR desirable
    11·1 answer
  • To improve at keyboarding, it is a good idea to master frequently typed words.
    14·2 answers
  • True or false A job analysis weight the positives and negative of a given career
    13·1 answer
  • ????????????????????????????????
    5·1 answer
  • Wyjaśnij w jaki sposób wykonuje się nitowanie zakładkowe i nakładkowe, oraz wyjaśnij na czym polega pasowanie mieszane.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!