Answered step by step
Verified Expert Solution
Question
1 Approved Answer
def interval(a, b): Construct an interval from a to b. return [a, b] def lower_bound(x): return x0] def upper_bound(x): return x[1] def str_interval(x): Return the
def interval(a, b): """Construct an interval from a to b.""" return [a, b] def lower_bound(x): return x0] def upper_bound(x): return x[1] def str_interval(x): """Return the lower bound of interval x.""" """Return the upper bound of interval x.""" """Return a string representation of interval x >>>strinterval(interval(-1, 2)) '-1 to 2" return 't0} to [1}'".format(lower_bound(x), upper_bound(x)) def add_interval(x, y): " " "Return an interval that contains the sum of any value in interval x and any value in interval y >>str_interval (add_interval(interval(-1, 2), interval(4, 8))) 3 to 10' lower lower_bound(x) + lower_bound(y) upper upper_bound(x) + upper_bound(y) return interval(lower, upper) def mul_interval(x, y): ""Return the interval that contains the product of any value in x and any value in y >>>str_interval(mul_interval(interval(-1, 2), interval(4, 8))) -8 to 16 p1 - lower_bound(x) * lower_bound(y) p2lower_bound(x) * upper_bound(y) p3-upper_bound(x) * lower_bound(y) p4upper_bound(x) * upper_bound(y) return interval(min(pl, p2, p3, p4), max(p1, p2, p3, p4)) def div_interval(x, y): u"Return the interval that contains the quotient of any value in x divided by any value in y. Division is implemented as the multiplication of x by the reciprocal of y str_interval(div_interval(interval(-1, 2), interval(4, 8))) -0.25 to 0.5' >>div interval(interval(4, 8), interval(-1, 2)) False "YOUR CODE HERE reciprocal y- interval (1/upper_bound (y, 1/lower_bound (y)) return mul_interval(x, reciprocal_y)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started