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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
/* ------------------------------------------------------------------- */
/* SARAG - Interval Arithmetic */
/* by Fabrizio Caruso */
intervalProduct(lhs,rhs) :=
[min(lhs[1]*rhs[1],lhs[1]*rhs[2],
lhs[2]*rhs[1],lhs[2]*rhs[2]),
max(lhs[1]*rhs[1],lhs[1]*rhs[2],
lhs[2]*rhs[1],lhs[2]*rhs[2])];
squaredIntervalAt(interval) :=
squaredIntervalAtAux(interval[1],interval[2]);
squaredIntervalAtAux(leftEnd,rightEnd) :=
if leftEnd*rightEnd<1 then
[0,max(leftEnd^2,rightEnd^2)]
else
[min(leftEnd^2,rightEnd^2),max(leftEnd^2,rightEnd^2)];
powerIntervalAt(interval,p) :=
if oddp(p) then
[interval[1]^p,interval[2]^p]
else
if interval[1]*interval[2]<1 then
[0,max(interval[1],interval[2])^p]
else
if interval[1]>0 then
[interval[1]^p,interval[2]^p]
else
[interval[2]^p,interval[1]^p];
constantByInterval(c,interval) :=
if c = 0 then
[0]
else
if c>0 then
[c*interval[1],c*interval[2]]
else
[c*interval[2],c*interval[1]];
constantPlusInterval(d,interval) :=
[interval[1]+d,interval[2]+d];
evaluatePolAt(pol,var,interval) :=
if degree(pol,var) < 1 then
[pol]
else
evaluatePolAtAux(rest(reverse(poly2list(pol,var)),1),
constantByInterval(coeff(pol,var,degree(pol,var)),interval));
evaluatePolAtAux(revCoeffSeq,interval) :=
if revCoeffSeq=[] then
interval
else
evaluatePolAtAux(rest(revCoeffSeq,1),
constantPlusInterval(first(revCoeffSeq),
interval)
);
0;
|