ezunits and solve



On 2012-10-31, Stavros Macrakis <macrakis at alum.mit.edu> wrote:

> especially when Maxima+ezunits doesn't know that the unit is a constant
> symbol, not a variable: ev(m`m,m=2) => 4.

Yeah -- I considered suppressing evaluation of units, but then stuff like

  cow : 5 * goat;
  x ` cow;
   => 5*x ` goat

wouldn't work. But on the other-other hand, one could still define the
cow-goat conversion via declare_unit_conversion, so there's no
necessity for cow:5*goat.

> For example, how can I solve the following equation for x?:
>
>           eq: x`m = 5`ft

That's an interesting problem. As an incidental aspect, it makes sense
for "``" to distribute over "=".

>        solve(map(lambda([ex],qty(ex `` fundamental_units(lhs(eq)) )), eq), x)
>
> I would claim that this is too complicated for a simple use case.

Yeah.

> * It takes 0.6 sec to calculate dimensions(2`ft), even when calculation is
> repeated (so it's not a warm-up effect)

Hmm. It's 0.06 s for Clisp but 1.something for SBCL. dimensions is only
doing some simple operations so I guess there must be something that's
much more expensive for SBCL (and whatever you're using).

> * test: 1`kg+1`ft$ dimensions(test) => mass+length (OK, I guess), but
> fundamental_units(test) => kg * m (!)
> * qty(1`kg + 1`lb) => 2  -- shouldn't this be an error?  or use consistent
> (even if arbitrary) units?
> * qty(test) => 2 -- shouldn't this also be an error?

Yeah -- these are all bugs. Thanks for pointing them out.

best

Robert Dodier