SICP Exercises (2.14) problem solving: Problems caused by interval errors

Source: Internet
Author: User

SICP Exercise 2.14 The title of the problem is not fully reflected in the dry, the problem is related to the content in front of the book.


In the book, Alyssa finished the interval calculation module we discussed before and released it, however, after some time she received a complaint from an engineer called Lem, the man named Lem should be a circuit, and he used the Alyssa program to calculate the shunt resistance value of two resistors, The Alyssa design interval is used to represent the resistance value of a resistor. In accordance with the laws of physics, the equation for parallel resistors is (R1*R2)/(R1 + R2), or using 1/(1/R1 + 1/r2), these two formulas are equivalent mathematically or physically. But.... If the calculation is done using the interval of Alyssa, the result of the above two formulas is very different.


The topic asked us to confirm that Lem is right, this is easy to do, we take a few samples of the above formula to do a few more tests, you can confirm that Lem is right, Alyssa design program some problems, resulting in two mathematically equivalent formulas to calculate the different results.


The key question is where did the program go wrong?


According to the tips in the book, we calculate the a/a there are some clues, in mathematics, a/a should be equal to 1, but in Alyssa program, a/a is not equal to 1, but equal to a value of nearly 1.

The key is that the two interval division is actually the inverse of the divisor, and then take the dividend, we take a look at the interval a (100 200), then a/a is

= (100 200)/(100 200)


+ (100 200) * (1/100 1/200)


+ (100/200 200/100)


+ (0.5 2)


It can be seen that the same two interval division, the result is a range from 0.5 to 2.


In addition, the book also specifically reminds us to pay attention to the percentage of errors, such as we can look at Interval B (1001), b/b is:


(1000 1001) * (1/1000 1/1001)


(1000/1001 1001/1000)


(0.999 1.001)


As can be seen, the results here are closer to 1, that is, if the error percentage is relatively small, the interval is divided when the deviation is relatively small.


This is probably the point of the topic, which is to pay attention to the problems that may arise during the complex data calculation.



SICP Exercises (2.14) problem solving: Problems caused by interval errors

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.