EDIT: Nooo, I don't want a behaviour like in Wolfram Alpha. Check this
out:
http://www.wolframalpha.com/input/?i=%28calorie%2Fcentimeter^2%2F+minute%29%2F%281kelvin-2kelvin%29

By inserting numbers that lead to a negative denominator, suddenly I
got units of time^-3! Maybe it's trickier than I thought...

On Aug 3, 9:40 am, Stan Schymanski <schym...@gmail.com> wrote:
> Yes, this makes sense to me. Wolfram seems to treat the expression and
> the units separately, which makes sense. In your example, any omitted
> value is seen as 1, so the result is perfectly correct. The expression
> is evaluated and the units are added after it, but they don't cancel
> out by subtraction. I don't think it is sensible to treat units as
> variables if this leads to results like the one I encountered. Then
> nothing is gained by using the units package and I could just create
> my own variables called m, K, J, W etc. Is there an easy way to get a
> behaviour like in Mathematica?
>
> On Aug 2, 9:29 pm, Eviatar <eviatarb...@gmail.com> wrote:
>
>
>
>
>
>
>
> > It seems WolframAlpha evaluates the limit of the 
> > expression:http://www.wolframalpha.com/input/?i=%28calorie%2Fcentimeter%5E2%2F+m....
>
> > On Aug 2, 12:21 pm, Eviatar <eviatarb...@gmail.com> wrote:
>
> > > I don't really see this as a bug. Units are treated as variables, so
> > > it makes sense. Are you suggesting that 0 * kelvin should be left
> > > unevaluated, and then not give an error when it is the denominator?
>
> > > On Aug 2, 7:49 am, Stan Schymanski <schym...@gmail.com> wrote:
>
> > > > Dear all,
>
> > > > This is a bug-report or feature request for the units package, taken
> > > > from sage-support. Basically, the units package does not handle
> > > > addition and subtraction in a sensible way, as units cancel out when
> > > > variables with the same units are subtracted from each other. Sage
> > > > should give an error message when adding or subtracting variables with
> > > > different units, while leaving the units intact if the variables have
> > > > the same units. Does anyone have an idea how this could be
> > > > accomplished? Thanks already!
>
> > > >  Below is an example of the problem posted 
> > > > athttp://groups.google.com/group/sage-support/browse_thread/thread/a60c...
>
> > > > sage: udict = {}
> > > > sage: udict[H_l] = units.energy.calorie/units.length.centimeter^2/
> > > > units.time.minute
> > > > sage: udict[T_a] = units.temperature.kelvin
> > > > sage: udict[T_l] = units.temperature.kelvin
> > > > sage: soln = solve(H_l == h_c*(T_a - T_l), h_c)[0]; soln
> > > > h_c == H_l/(T_a - T_l)
> > > > sage: soln.subs(udict)
> > > > Traceback (most recent call last):
> > > > ...
> > > > RuntimeError: power::eval(): division by zero
>
> > > > ---
> > > > This works:
> > > > sage: (H_l/T_a).subs(udict)
> > > > calorie/(centimeter^2*kelvin*minute)

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to