Re: Incompatible units?

*To*: mathgroup at smc.vnet.net*Subject*: [mg97750] Re: Incompatible units?*From*: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>*Date*: Fri, 20 Mar 2009 02:41:40 -0500 (EST)*References*: <gpt6i8$qr7$1@smc.vnet.net>

Hi Mathias, Your example is a bit incomplete, or so it seems. What are the definitions of Tau p and l case? And what is the slash in \Convert doing? And why are you using Convert for this particular conversion? The division of the two variables is dimensionless, so no need for Convert. Anyways, your problem is not the Units package, but the use of Dynamic. Dynamic is a wrapper, much like InputForm or TableForm. It's used for display in the FrontEnd, but not for calculations in the kernel. Try for instance this definition: g[x_Numeric] := x^2 Now enter g[Dynamic[p]]. It displays as g[p]. Now set p to 5 (p=5). You see the old g[p] change to g[5] and not to 25. This is because the function doesn't see the number 5, but the object Dynamic[p] which only displays as 5 in the FrontEnd. It does not represent the value 5 to the kernel. The same happens with your conversion. Because the units are hidden within the Dynamic wrapper they can't be simplified by the kernel. The error message is displayed by the FrontEnd and this exposes the units, but (it should be clear) this is not what the kernel sees! Read more about this in the section "Where Should Dynamic Be Placed in an Expression?" in the tutorial tutorial/IntroductionToDynamic. Cheers -- Sjoerd On Mar 19, 12:25 pm, Mathias Lindner <mathias.lind... at web.de> wrote: > Hi > > Today I struggled with the units package - again... > > Let me show you what I did: > > Dynamic[Subscript[\[Tau], p]] > Subscript[l, case] > \[Lambda] = \Convert[Subscript[l, case]/Dynamic[Subscri= pt[\[Tau], p]], 1] > > This input results in: > > 27.4889 Meter Milli > 281 Meter Milli > > Convert::incomp : Incompatible units in (281 Meter Milli)= /(27.4889 > Meter Milli) and 1. > (281 Meter Milli)/(27.4889 Meter Milli) > > If I don't use dynamic but constant tau_p everything is fine... > So Mathematica isn't able to to reduce this fraction? What's the reason > for this behaviour and what can I do about it? > > Thanks for your help! > > Mathias