ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 31 Oct 2013 08:38:23 +0100polynomial and interval arithmetichttps://ask.sagemath.org/question/9964/polynomial-and-interval-arithmetic/Hi,
I would like to evaluate a polynomial on a real interval (an element of RIF). My problem is the following. I take the polynomial x(1-x) which is increasing on (0,1/2). Hence, if I have an interval (l,u) in (0,1/2) and I apply this polynomial, I would like to get an answer close to (l(1-l), u(1-u)) up to rounding error. But what I get is (l(1-u), u(1-l)) which is twice bigger! The following code illustrates the behavior:
sage: l = 3/17
sage: u = 5/17
sage: x0 = RIF((l,u))
sage: print x0.absolute_diameter()
0.117647058823529
sage: print (x0 * (1-x0)).absolute_diameter()
0.117647058823529
sage: P = PolynomialRing(RIF, 'x')('x - x^2')
sage: P(x0).absolute_diameter()
0.117647058823529
And we can check that this diameter is (l(1-u), u(1-l)):
sage: x1_l = l * (1-u)
sage: x1_u = u * (1-l)
sage: print (x1_u - x1_l).n()
0.117647058823529
which is much bigger than (l(1-l), u(1-u)):
sage: x2_l = l * (1-l)
sage: x2_u = u * (1-u)
sage: print (x2_u - x2_l).n()
0.0622837370242214
Is there a cleaner way to evaluate a polynomial on an element of RIF ?
VincentSun, 31 Mar 2013 16:41:35 +0200https://ask.sagemath.org/question/9964/polynomial-and-interval-arithmetic/Answer by Richard Fateman for <p>Hi,</p>
<p>I would like to evaluate a polynomial on a real interval (an element of RIF). My problem is the following. I take the polynomial x(1-x) which is increasing on (0,1/2). Hence, if I have an interval (l,u) in (0,1/2) and I apply this polynomial, I would like to get an answer close to (l(1-l), u(1-u)) up to rounding error. But what I get is (l(1-u), u(1-l)) which is twice bigger! The following code illustrates the behavior:</p>
<pre><code>sage: l = 3/17
sage: u = 5/17
sage: x0 = RIF((l,u))
sage: print x0.absolute_diameter()
0.117647058823529
sage: print (x0 * (1-x0)).absolute_diameter()
0.117647058823529
sage: P = PolynomialRing(RIF, 'x')('x - x^2')
sage: P(x0).absolute_diameter()
0.117647058823529
</code></pre>
<p>And we can check that this diameter is (l(1-u), u(1-l)):</p>
<pre><code>sage: x1_l = l * (1-u)
sage: x1_u = u * (1-l)
sage: print (x1_u - x1_l).n()
0.117647058823529
</code></pre>
<p>which is much bigger than (l(1-l), u(1-u)):</p>
<pre><code>sage: x2_l = l * (1-l)
sage: x2_u = u * (1-u)
sage: print (x2_u - x2_l).n()
0.0622837370242214
</code></pre>
<p>Is there a cleaner way to evaluate a polynomial on an element of RIF ?</p>
<p>Vincent</p>
https://ask.sagemath.org/question/9964/polynomial-and-interval-arithmetic/?answer=15631#post-id-15631Quadratic polynomials like yours can be rephrased as Single Use Expressions by
completing the square. General polynomials not so easy unless you can factor.
Use google to search for terms in this answer that might not be familiar.
Richard Fateman
Thu, 31 Oct 2013 08:38:23 +0100https://ask.sagemath.org/question/9964/polynomial-and-interval-arithmetic/?answer=15631#post-id-15631