I have received a couple of helpful hints about functional existing
open source packages that treat units in the desired way (ezunits in
maxima and DesignerUnits.com), but I am still after the quick and
dirty way for using the existing units package in sage. The only thing
that really stops me right now is that I don't know how to get it to
return:
units.x.y + units.x.y = units.x.y
units.x.y - units.x.y = units.x.y
Is there an easy way to write a function that would do that while
keeping the rest (multiplication, division, exponents etc.) the way it
is?
Thanks again for your help!
On Aug 3, 1:55 pm, Stan Schymanski <
schym...@gmail.com> wrote:
> The division by zero is not the issue here, but the disappearance of
> theunitswhen two variables with the sameunitsare subtracted from
> Sage would simply give 0 without anyunits, so that multiplication
> with the term (kelvin-kelvin) would give 0, too. Nounits.
>
> The function for a dimensional analysis without coefficients sounds
> like a great idea. If you could post something quick and dirty, I
> could see a bit better what you mean. Thanks for thinking about it,
> anyway!
>
> Stan
>
> On Aug 3, 12:21 pm, Eviatar <
eviatarb...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I don't think there is an easy way.
>
> > It seems that in Mathematica division by zero does not return an
> > error, simply evaluates to infinity (
http://www.wolframalpha.com/
> > input/?i=1%2F0), which only makes sense if you are using the limit
> > definition of equality.
>
> > So essentially, the way to fix this in Sage would be to haveunitsbe
> > "special" symbolic variables when evaluating limits, so that
>
> > sage: limit(1 / x, x=units.length.meter.mul(0, hold=True))
> > Infinity
>
> > would return Infinity*meter instead. I think this would be quite hard
> > to do.
>
> > The other option would be to operator overload the UnitExpression
> > class or modify the behaviour of symbolic variables when they are
> > detected to beunits. In any case, dividing by zero would still return
> > an error.
>
> > Maybe it would be useful to have a function that just does dimensional
> > analysis and ignores coefficients? This wouldn't be hard to write.
>
> > On Aug 3, 12:40 am, Stan Schymanski <
schym...@gmail.com> wrote:
>
> > > Yes, this makes sense to me. Wolfram seems to treat the expression and
> > > theunitsseparately, which makes sense. In your example, any omitted
> > > value is seen as 1, so the result is perfectly correct. The expression
> > > is evaluated and theunitsare added after it, but they don't cancel
> > > out by subtraction. I don't think it is sensible to treatunitsas
> > > variables if this leads to results like the one I encountered. Then
> > > nothing is gained by using theunitspackage and I could just create
> > > > > I don't really see this as a bug.Unitsare 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 theunitspackage, taken
> > > > > > from sage-support. Basically, theunitspackage does not handle
> > > > > > addition and subtraction in a sensible way, asunitscancel out when
> > > > > > variables with the sameunitsare subtracted from each other. Sage
> > > > > > should give an error message when adding or subtracting variables with
> > > > > > differentunits, while leaving theunitsintact if the variables have
> > > > > > the sameunits. Does anyone have an idea how this could be