Exercise 2.13

Show that under the assumption of small percentage tolerances there is a simple formula for the approximate percentage tolerance of the product of two intervals in terms of the tolerances of the factors. You may simplify the problem by assumingthat all numbers are positive.

After considerable work, Alyssa P. Hacker delivers her finished system. Several years later, after she has forgotten all about it, she gets a frenzied call from an irate user, Lem E. Tweakit. It seems that Lem has noticed that the formula for parallel resistors can be written in two algebraically equivalent ways:



He has written the following two programs, each of which computes the parallel-resistors formula differently:

(define (par1 r1 r2)
(div-interval (mul-interval r1 r2)
(add-interval r1 r2))) (define (par2 r1 r2)
(let ((one (make-interval 1 1)))
(div-interval
one (add-interval (div-interval one r1)
(div-interval one r2)))))

Lem complains that Alyssa's program gives different answers for the two ways of computing. This is a serious complaint.


这道题一是要修改乘法函数,二是要演示两种计算并联电阻的方法计算的结果不一致。

(define (mul-interval x y)
(let ((cx (center x))
(cy (center y))
(px (/ (percent x) 100))
(py (/ (percent y) 100)))
(make-interval (* (- cx (* cx px)) (- cy (* cy py)))
(* (+ cx (* cx px)) (+ cy (* cy py)))))) (define r1 (make-interval 6.12 7.48))
(define r2 (make-interval 4.465 4.935)) (display-interval-tolerance (par1 r1 r2))
(display-interval-tolerance (par2 r1 r2)) ; 执行结果
2.844199964577264 ± 22.613352145193332%
2.777440701636504 ± 7.05260392723452%

Exercise 2.14

Demonstrate that Lem is right. Investigate the behavior of the system on a variety of arithmetic expressions. Make some intervals A and B, and use them in computing the expressions A/A and A/B. You will get the most insight by using intervals whose width is a small percentage of the center value. Examine the results of the computation in center-percent form (see Exercise 2.12).


(define r1 (make-interval 6.12 7.48))
(define r2 (make-interval 4.465 4.935)) (display-interval (div-interval r1 r1))
(display-interval (div-interval r1 r2))
(newline)
(display-interval-tolerance (div-interval r1 r1))
(display-interval-tolerance (div-interval r1 r2)) ; 执行结果
[0.8181818181818182, 1.222222222222222]
[1.2401215805471126, 1.6752519596864504] 1.02020202020202 ± 19.801980198019795%
1.4576867701167815 ± 14.925373134328357%

根据执行结果来看,Lem显然是对的,对于 A/A,答案显然应该是 1 才对,但是程序计算出来的却是一个相对很大的范围,这是因为计算区间除法时,我们并没有定义“相等”这个概念,所以计算 A/A 时,它也按照通用的方法去计算了。

Exercise 2.15

Eva Lu Ator, another user, has also noticed the different intervals computed by different but algebraically equivalent expressions. She says that a formula to compute with intervals using Alyssa's system will produce tighter error bounds if it can be written in such a form that no variable that represents an uncertain number is repeated. Thus, she says, par2 is a "better" program for parallel resistances than par1. Is she right? Why?


Eva 说的是对的,对于练习 2.13 计算出的两个答案,par2 更准确,跟书上给出的答案是一致的,至于原因我觉得应该是区间之间的运算每次都会增加不确定性,par2 其实只有相加那一步是两个区间进行运算,其他的都可以看作确定数字与区间的运算,没有增加额外的不确定性;而 par1 进行了3次区间之间的运算————乘法、加法和除法,乘法和除法都会使结果变得不确定。

Exercise 2.16

Explain, in general, why equivalent algebraic expressions may lead to different answers. Can you devise an interval-arithmetic package that does not have this shortcoming, or is this task impossible? (Warning: This problem is very difficult.)


(define a (make-interval 2 4))

(define b (make-interval -2 0))

(define c (make-interval 3 8))

(define x (mul-interval a (add-interval b c)))

(define y (add-interval (mul-interval a b)
(mul-interval a c))) (display-interval x)
(display-interval y) ; 执行结果
[2, 32]
[-2, 32]

根据上面的结果可以看到,区间运算连乘法分配律都无法保证。至于有没有无缺陷的区间运算规则,我大概想了一下,没有什么头绪,就没继续想了。。

sicp每日一题[2.13-2.16]的更多相关文章

  1. <每日一题>题目13:列表的简单问题

    ''' 分析: python赋值是通过指针来进行的. 很显然第一.三.四次调用都指向同一个列表,并未完成清空, 第二次调用只是指向了另一个列表,也未完成清空,很显然结果是累计的 结果: [0, 1] ...

  2. CISP/CISA 每日一题 16

    CISA 每日一题(答) 作业调度软件的优点: 1.作业信息仅需建立一次,减少错误发生概率: 2.可定义作业间的依赖关系,当某一项作业失败时,依赖于该作业的后续作业就不会被执行: 3.所有成功或失败的 ...

  3. CISP/CISA 每日一题 13

    监控信息系统人员所提供服务的效率和效果的工具: 1.例外报告:识别所有没有成功完成的或出了故障的应用 2.作业重运行报告:大多数异常终止作业都会导致重起 3.操作员问题报告:记录计算机运行问题及解决方 ...

  4. 老男孩IT教育-每日一题汇总

    老男孩IT教育-每日一题汇总 第几天 第几周 日期 快速访问链接 第123天 第二十五周 2017年8月25日 出现Swap file….already exists以下错误如何解决? 第122天 2 ...

  5. [每日一题]面试官问:谈谈你对ES6的proxy的理解?

    [每日一题]面试官问:谈谈你对ES6的proxy的理解? 关注「松宝写代码」,精选好文,每日一题 作者:saucxs | songEagle 一.前言 2020.12.23 日刚立的 flag,每日一 ...

  6. 【JavaScript】【dp】Leetcode每日一题-解码方法

    [JavaScript]Leetcode每日一题-解码方法 [题目描述] 一条包含字母 A-Z 的消息通过以下映射进行了 编码 : 'A' -> 1 'B' -> 2 ... 'Z' -& ...

  7. PL/SQL Challenge 每日一题:2014-3-14 11gR2中带RELIES_ON子句的RESULT_CACHE函数

    PL/SQL Challenge 每日一题:2014-3-14 11gR2中带RELIES_ON子句的RESULT_CACHE函数 最先答对且答案未经编辑的puber将获得纪念章一枚(答案不可编辑但可 ...

  8. CISP/CISA 每日一题 五

    CISA 每日一题(答) 信息系统审计师要确认系统变更程序中的: 1.变更需求应有授权.优先排序及跟踪机制: 2.日常工作手册中,明确指出紧急变更程序: 3.变更控制程序应同时为用户及项目开发组认可: ...

  9. 「每日一题」有人上次在dy面试,面试官问我:vue数据绑定的实现原理。你说我该如何回答?

    关注「松宝写代码」,精选好文,每日一题 ​时间永远是自己的 每分每秒也都是为自己的将来铺垫和增值 作者:saucxs | songEagle 来源:原创 一.前言 文章首发在「松宝写代码」 2020. ...

  10. 【JavaScript】Leetcode每日一题-二叉搜索树的范围和

    [JavaScript]Leetcode每日一题-二叉搜索树的范围和 [题目描述] 给定二叉搜索树的根结点 root,返回值位于范围 [low, high] 之间的所有结点的值的和. 示例1: 输入: ...

随机推荐

  1. PN转232网关模块接扫码枪与CPU通讯

    在现代物流.汽车生产线等领域,广泛使用条码扫码枪快速扫描产品条码,提高工作效率.为了保证条码扫码枪与CPU之间的准确通信,PN转232网关模块成为关键部件.本文将深入研究PN转232网关模块(BT-P ...

  2. oeasy教您玩转vim - 69 - # 折叠folding入门

    ​ 折叠入门 回忆上次 上次学习了一种新的容器 tabs选项卡 tabs选项卡 包含多个选项卡tab 可以列两个tab 一个编写文件 一个执行指令 互不影响 每个 tab选项卡 还可以对应多个wind ...

  3. C# WinForm遍历窗体控件的3种方法

    1.循环遍历 private void GetControls(Control fatherControl) { Control.ControlCollection sonControls = fat ...

  4. C#封装HttpClient工具类库(.NET4.5以上)

    1.Json字符串实体转换扩展方法,依赖Json.Net包 /// <summary> /// Json扩展方法 /// </summary> public static cl ...

  5. sed 进阶使用

    sed 进阶使用 工作原理 sed 维护两个数据缓冲区: 活动模式空间 和 辅助保持空间 两者最初都是空的 sed 通过对每一行输入执行以下循环进行操作 从输入流中读取一行,删除任何尾随的换行符,并将 ...

  6. 改善中国打开GitHub网站的速度

    您可以采取以下措施来改善您在中国打开GitHub网站的速度:1. 使用VPN:通过连接到VPN服务器,您可以避免中国政府对GitHub网站进行的封锁,从而获得更快的访问速度.2. 使用加速器:国内有很 ...

  7. 毕业设计&毕业项目:基于springboot+vue实现的在线音乐平台

    一.前言 在当今数字化时代,音乐已经成为人们生活中不可或缺的一部分.随着技术的飞速发展,构建一个用户友好.功能丰富的在线音乐平台成为了许多开发者和创业者的目标.本文将介绍如何使用SpringBoot作 ...

  8. ABC357

    A link 循环加每一个数,加到哪个数不能加了输出前一个数,注意如果加到最后还能加,记得输出\(n\). 点击查看代码 #include<bits/stdc++.h> using nam ...

  9. 如何查询MySQL存储的树形结构,层次结构

    表定义如下 如果我们需要在表中查询这个树状结构,通过SQL语句,有两种查询方法: 1.通过inner自连接查询,适用于简单的结构 SELECT * FROM course_category AS on ...

  10. ClickHouse的向量处理能力

    ClickHouse的向量处理能力 引言 在过去,非结构化数据(如文本.图片.音频.视频)通常被认为难以在数据库中直接使用,因为这些数据类型的多样性和复杂性.然而,随着技术的发展,嵌入技术可以将非结构 ...