Saturday, May 22, 2010

Interval arithmetic python program.?

The goal of this project is to develop a class to perform elementary interval arithmetic. Interval


arithmetic was developed as an approach to put bounds on rounding errors in mathematical


computations as a way to obtain reliable results.


For two intervals [a; b] and [c; d], the basic arithmetical operations are de¯ned as


[a; b] + [c; d] = [a + c; b + d]


[a; b] ¡ [c; d] = [a ¡ d; b ¡ c]


[a; b] £ [c; d] = [min(ac; ad; bc; bd); max(ac; ad; bc; bd)]


[a; b] = [c; d] = [min(a=c; a=d; b=c; b=d); max(a=c; a=d; b=c; b=d)]


In this project you will de¯ne a class Interval and use operator overloading to implement the


four basic arithmetical operations on intervals.


If we store the class de¯nition in the ¯le interval.py, then an interactive session might run as:


%26gt;%26gt;%26gt; from interval import *


%26gt;%26gt;%26gt; x = Interval(3)


%26gt;%26gt;%26gt; x


[3.000000,3.000000]


%26gt;%26gt;%26gt; y = Interval(2,4)


%26gt;%26gt;%26gt; y


[2.000000,4.000000]


%26gt;%26gt;%26gt; x + y


[5.000000,7.000000]


%26gt;%26gt;%26gt; x - y


[-1.000000,1.000000]


%26gt;%26gt;%26gt; x * y


[6.000000,12.000000]


%26gt;%26gt;%26gt; x / y


[0.750000,1.50000

Interval arithmetic python program.?
So what is the question?





Many standard numeric algorithms, by the way, are unstable and divergent under interval arithmetic. That does not mean they are useless or bad algorithms... it only means that interval arithmetic is not a good measure of algorithmic stability because it often grossly overestimates errors. And this is probably just one of the reasons why it is not used much.


No comments:

Post a Comment