1 /* ------------------------------------------------------------------- */
2 /* SARAG - Interval Arithmetic */
3 /* by Fabrizio Caruso */
6 intervalProduct(lhs,rhs) :=
7 [min(lhs[1]*rhs[1],lhs[1]*rhs[2],
8 lhs[2]*rhs[1],lhs[2]*rhs[2]),
9 max(lhs[1]*rhs[1],lhs[1]*rhs[2],
10 lhs[2]*rhs[1],lhs[2]*rhs[2])];
13 squaredIntervalAt(interval) :=
14 squaredIntervalAtAux(interval[1],interval[2]);
16 squaredIntervalAtAux(leftEnd,rightEnd) :=
17 if leftEnd*rightEnd<1 then
18 [0,max(leftEnd^2,rightEnd^2)]
20 [min(leftEnd^2,rightEnd^2),max(leftEnd^2,rightEnd^2)];
23 powerIntervalAt(interval,p) :=
25 [interval[1]^p,interval[2]^p]
27 if interval[1]*interval[2]<1 then
28 [0,max(interval[1],interval[2])^p]
31 [interval[1]^p,interval[2]^p]
33 [interval[2]^p,interval[1]^p];
36 constantByInterval(c,interval) :=
41 [c*interval[1],c*interval[2]]
43 [c*interval[2],c*interval[1]];
45 constantPlusInterval(d,interval) :=
46 [interval[1]+d,interval[2]+d];
48 evaluatePolAt(pol,var,interval) :=
49 if degree(pol,var) < 1 then
52 evaluatePolAtAux(rest(reverse(poly2list(pol,var)),1),
53 constantByInterval(coeff(pol,var,degree(pol,var)),interval));
55 evaluatePolAtAux(revCoeffSeq,interval) :=
56 if revCoeffSeq=[] then
59 evaluatePolAtAux(rest(revCoeffSeq,1),
60 constantPlusInterval(first(revCoeffSeq),