SICP 1.6-1.8

Source: Internet
Author: User

1.6
Because of the nature of the scheme's application order evaluation, the function will fall into the loop (improve guess x has been calculated)

1.7

The value is too small, 0.001 this precision is far from enough ...

Value is too large, due to the limited accuracy of floating point numbers, (such as the use of IEEE754 floating-point standard, 32-bit floating point number indicates that 123456789 such numbers will have a serious loss of precision), it is not possible to obtain the correct two large number of the difference.

1 (define (ABS x)2(if(>= x0)3 x4(-x )))5 6 (define (average a B)7(/(+ a B)2))8 9 (define (Improve guess X)Ten (Average guess One(/x guess) ) A  -(Define (Good-enough?)guess x) -(< (/(ABS (-(Improve guess x) the guess)) - guess) -      0.01)) -  +(Define (sqrt-iter guess x) -(Cond (Good-enough?guess x) guess) +(Else(sqrt-iter (Improve guess x) x)) A         )) at  -  - (define (sqrt x) -(Sqrt-iter1.0x))



---> In principle can, but in fact the accuracy of the loss is certain ...

1.8

1 (define (improve2 guess x)2(/ (+ (/x3(*guess guess))4(*2guess))5      3))6 7(Define (GOOD-ENOUGH2?)guess x)8(< (/(ABS (-(Improve2 guess x)9 guess))Ten guess) One      0.01)) A  -(Define (cbrt-iter guess x) -(Cond (GOOD-ENOUGH2?guess x) guess) the(Else(cbrt-iter (Improve2 guess x) - x ))) -  - (define (CBRT x) +(Cbrt-iter1.0x))

SICP 1.6-1.8

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.