MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Incompatible units?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97846] Re: Incompatible units?
  • From: Mathias Lindner <mathias.lindner at web.de>
  • Date: Tue, 24 Mar 2009 05:27:24 -0500 (EST)
  • Organization: Chemnitz University of Technology
  • References: <gpt6i8$qr7$1@smc.vnet.net> <gpvhb8$gt5$1@smc.vnet.net>

Sjoerd C. de Vries schrieb:
> Hi Mathias,
> 
> Your example is a bit incomplete, or so it seems. What are the
> definitions of Tau p and l case?

Yes, I know. It wasn't the complete calculation. That is because the 
complete one is endless ;) You helped me anyway...

> 
> 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.

No idea about the slash. In StandardForm I typed Convert[]. Must have 
been input during the copy&paste into my newsreader.
I use Convert very often and it's annoying. As an example: The result of 
the multiplication of a frequency and a time has to be dimensionless. 
Anyway, the shown result is always in Hertz Second. Only with 
Convert[...,1] the units are avoided. The same applies for Watt/(Volt 
Amp), Kilo/Milli etc.
Any idea what goes wrong here?

> 
> 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.

Thanks for pointing me to this tutorial. After altering the position of 
Dynamic in this equation Mathematica works as expected.

> 
> Cheers -- Sjoerd

Also thanks to Bill Rowe! Avoiding subscripts didn't help in my 
situation but it's a good advice anyway. I will follow it.

Regards,
Mathias



> 
> 
> 
> 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
> 
> 


  • Prev by Date: Re: Online Graphic Output
  • Next by Date: Re: Recursive algorithm
  • Previous by thread: Re: Incompatible units?
  • Next by thread: Re: Incompatible units?