Ask Your Question

Revision history [back]

It seems that the units end up in sqrt() expressions. Even if you have something like sqrt(second^2), Sage does not simplify this automatically. This is a bug caused by the fact that second is a symbolic variable and unless you explicitly state the domain for a variable it is assumed to be complex. For a complex variable x, we can't say that sqrt(x^2) = x. But if x > 0, we can:

sage: var('y', domain='positive')
sage: sqrt(y^2)
sage: sqrt(x^2)

There is also the fact that sqrt() only performs trivial simplifications automatically. This is not simplified for instance:

sage: sqrt(y^2/(x+1))
sqrt(y^2/(x + 1))

Because of another bug, even though we already declared y > 0, we need to state this to Maxima before we can simplify further:

sage: t = sqrt(y^2/(x+1))
sage: t.simplify_radical()
abs(y)/sqrt(x + 1)
sage: assume(y > 0)
sage: t.simplify_radical()
y/sqrt(x + 1)

You might be able to work around your problems by combining some of the tricks above. It would be great if someone files a ticket to declare units as positive.