RE: PlusMinus Operator Question
- To: mathgroup at smc.vnet.net
- Subject: [mg38380] RE: [mg38356] PlusMinus Operator Question
- From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
- Date: Fri, 13 Dec 2002 04:09:47 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
>-----Original Message----- >From: TerryH [mailto:tharter at attglobal.net] To: mathgroup at smc.vnet.net >Sent: Thursday, December 12, 2002 7:38 AM >To: mathgroup at smc.vnet.net >Subject: [mg38380] [mg38356] PlusMinus Operator Question > > >Hi All: > How can I get Mathematica 4.2 to do simple multipliction thru >PlusMinus operators? >For example, suppose I have a 3-dimensional vector with component >tolerances specified: > > In[4]:= va = {{4.10 ± 0.057}, {-3.16 ± 0.796}, {5.09 ± .250}} > Out[4]:= >{{4.1\[PlusMinus]0.057},{-3.16\[PlusMinus]0.796},{5.09\[PlusMin >us]0.25}} > > > > In[5]:= FullForm[va] > Out[5]://FullForm= > >List[List[PlusMinus[4.1`,0.057`]],List[PlusMinus[-3.16`,0.796`]], > >List[PlusMinus[5.09`,0.25`]]] > > In[6]:= 5.2*va > Out[6]:= {{5.2 (4.1\[PlusMinus]0.057)},{5.2 >(-3.16\[PlusMinus]0.796)},{5.2 (5.09\ > \[PlusMinus]0.25)}} > >However, what I want is (for the first component of the vector, va) is > 5.2*4.1 ± (5.2*0.057) >or, equivalently > 21.32 ± 0.2964 > >Is there a standard package to do this? I wasn't able to find anything >of help in >Section 1.10 or 3.10 of the Wolfram Reference. How does one assign >meaning to the >PlusMinus operator to do simple arithmetic calculations as shown above? > >Many thanks to all who may respond! >....Terry H > > > Terry, I'd recommend to use interval arithmetic as built in Mathematica: In[1]:= va = {{4.10 ± 0.057}, {-3.16 ± 0.796}, {5.09 ± .250}}; In[2]:= 5.2*va Out[2]= {{5.2 (4.1 ± 0.057)}, {5.2 (-3.16 ± 0.796)}, {5.2 (5.09 ± 0.25)}} Now define: PlusMinus[a_, b_?Negative] := PlusMinus[a, -b] PlusMinus[a_, b_] := Interval[{a - b, a + b}] Unprotect[Interval] Interval /: MakeBoxes[Interval[{a_, b_}], StandardForm] := With[{c = (a + b)/2, d = Abs[a - b]/2}, MakeBoxes[PlusMinus[c, d]]] Protect[Interval] Such In[8]:= va Out[8]= {{4.1 ± 0.057}, {-3.16 ± 0.796}, {5.09 ± 0.25}} In[9]:= 5.2*va Out[9]= {{21.32 ± 0.2964}, {-16.432 ± 4.1392}, {26.468 ± 1.3}} In[10]:= -5.2*va Out[10]= {{-21.32 ± 0.2964}, {16.432 ± 4.1392}, {-26.468 ± 1.3}} In[11]:= (va - 4.1)^2 Out[11]= {{0.0016245 ± 0.0016245}, {53.3412 ± 11.5579}, {1.0426 ± 0.495}} In[13]:= Sin[va] Out[13]= {{-0.816948 ± 0.0327472}, {0.0128765 ± 0.714442}, {-0.900651 ± 0.0912181}} In[14]:= Exp[va] Out[14]= {{60.4383 ± 3.44126}, {0.0565914 ± 0.0374519}, {167.491 ± 41.0217}} However, Interval in Mathematica has a broader meaning, and you have define your output if it contains disconnected pieces! -- Hartmut Wolf