-
Notifications
You must be signed in to change notification settings - Fork 0
/
2.9
42 lines (29 loc) · 1.15 KB
/
2.9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//2.9
//The width of interval: half the difference of the lower and upper bounds
//The width of the result combining two intervals is a function only of the widths of the argument intervals
//Show that the width of the sum of 2 intervals is a function only of the widths of the intervals being added
//add two intervals
//get the width of combined intervals
//demonstrate that the width of the indivdual intervals effects the combined result of the combined interval
function upper_bound(interval){
return Math.max(interval);
}
function lower_bound(interval){
return Math.min(interval);
}
function width_interval(x) {
return (upper_bound(x) - lower_bound(x)) * .5;
}
function add_interval(x,y) {
return make_interval(lower_bound(x) + lower_bound(y),
upper_bound(x) + upper_bound(y));
}
function sub_interval(x,y) {
return make_interval(lower_bound(x) - upper_bound(y),
lower_bound(x) - upper_bound(y));
}
function make_interval(a,b) {
return pair(a,b);
}
width_interval(add_interval(make_interval(1,2),make_interval(3,5)));
width_interval(sub_interval(make_interval(1,2),make_interval(3,5)));