Re: Problem with Interval Calculations?
- To: mathgroup at smc.vnet.net
- Subject: [mg30894] Re: [mg30868] Problem with Interval Calculations?
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Sun, 23 Sep 2001 02:16:35 -0400 (EDT)
- References: <200109210804.EAA18930@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Greg Arnold wrote: > > Mathematica 4.1 gives me the following: > > In[1]:= expr=a*(1-a) > Out[1]= (1-a) a > > In[2]:= expr /. a->Interval[{1,2}] > Out[2]= Interval[{-2,0}] > > In[3]:= Expand[expr] > Out[3]= a - a^2 > > In[4]:= Expand[expr] /. a->Interval[{1,2}] > Out[4]= Interval[{-3,1}] > > What gives? Each interval is independent of the others. Interval[{1,2}] - Interval[{1,2}]^2 --> Interval[{1,2}] - Interval[{1,4}] --> Interval[{-3,1}] This last step is because the smallest value comes from taking the smallest value of the first interval and subtracting the largest value of the second, and similarly we deduce the largest possible value. Similarly for the unexpanded case we have Interval[{1,2}]*(1-Interval[{1,2}]) --> Interval[{1,2}]*Interval[{-1,0}] --> Interval[{-2,0}] Here we simple deductions explain why we get the result we get. >Should the answer be the same? Generally not. > I believe the expanded answer, > but I'm not sure expanding every problem before assigning the interval is > practical. > > Thanks for any advice/insight, > > Greg What you should do depends largely on whether or not you want all occurences of 'a' to represent the same value in a particular interval. In other words, do you regard all these values as dependent or independent of one another? If you want them to be independent then your expressions (expanded and not) are simply inequivalent, and you would need to decide which is correct for your needs. Typical use of interval substitutions, however, is to regard them as the same (otherwise you would use different variables to denote the different values). In this case it is to your advantage to have the smallest interval result you can reasonably attain. Frequently the Horner form of an expression (a particular "nested" form), as opposed to expanded or other forms, will help to keep the interval reasonably small; note that your original input is already in that form. If that is not adequate you can use e.g. Experimental`Minimize to deduce the correct minimum and maximum values attained on the interval in question, as is indicated below for your example. In[1]:= ??Experimental`Minimize Minimize[expr, cons, {x1, x2, ... }] minimizes expr with respect to the real variables xi subject to the constraints cons. Attributes[Experimental`Minimize] = {Protected} Options[Experimental`Minimize] = {Experimental`WeakSolutions -> False, WorkingPrecision -> Infinity} In[2]:= expr = a(1-a); In[3]:= Experimental`Minimize[expr, {a>=1,a<=2}, a] Out[3]= {-2, {a -> 2}} In[4]:= -Experimental`Minimize[-expr, {a>=1,a<=2}, a] Out[4]= {0, {-(a -> 1)}} We see that the correct interval is in fact {-2,0}. More commonly the Horner form will give an interval that is larger but tighter than what might be attained by other forms of the expression. Note that Minimize will work only for polynomial expressions and close cousins (e.g. things with radicals), so for other functions you need something like a Taylor series or other approximation. To obtain Horner forms for polynomial and related expressions you may do as below. In[5]:= <<Algebra` In[6]:= ?Horner Horner[p] gives the polynomial or rational function of polynomials p in Horner or nested form with respect to the default variables Variables[p]. Horner[p, v] gives p in Horner form with respect to the variable or variable list v. Horner[p1/p2, v1, v2] gives the rational function of polynomials p1/p2 in Horner form using the variables or variable lists v1 and v2 for p1 and p2 respectively. We check that our expression in this case is already in Horner form. In[7]:= Horner[Expand[expr]] == expr Out[7]= True Daniel Lichtblau Wolfram Research
- References:
- Problem with Interval Calculations?
- From: "Greg Arnold" <garnold@mbvlab.wpafb.af.mil>
- Problem with Interval Calculations?