ezunits and solve



Thorsten Bonow <thorsten.bonow at withouthat.org> writes:

>>>>>> "Robert" == Robert Dodier <robert.dodier at gmail.com> writes:
>
> Hi all,
>
> thx for all your answers and sorry for the late reply---I was away.
>
> My knowledge of Maxima is too limited to respond to all propositions, but I
> will try to explain what I'm trying to achieve by commenting on the quotes
> below.
>    
>     Robert> 'solve' can solve variants of the problem you posed if "`" is
>     Robert> replaced by a function or operator. I haven't figured out why it
>     Robert> can't solve the original. In the interest of getting to a solution,
>     Robert> my advice is to solve it symbolically first, then substitute
>     Robert> specific values into the solution:
>
>     [...]
>
>     Robert> I don't know what you have in mind, but ezunits is supposed to be a
>     Robert> way to handle units symbolically. So if you have some such problems
>     Robert> to solve, I would be interested to hear about it. Take a look at
>     Robert> the examples shown by demo(ezunits), especially the one about the
>     Robert> speed of sound toward the end.
>
> I'm a high school teacher and I have a hard time convincing my students to do
> their problem solving with units---e.g. when they have to calculate a length
> and get the dimension of a velocity, they know that they must have made a
> mistake.
>
> In this situation it's counterproductive to tell them to forget about the units
> when solving problems with Maxima.
>
> ezunits looked like a good solution, but after running a few tests I realized
> that Maxima's problem solving capabilities are limited when doing calculations
> with units.
>
> Therefor solving it symbolically first and inserting the units afterwards is
> exactly what the students shouldn't be doing.
>
> Other proposed solutions for specifying numbers with units add an additional
> layer of abstraction onto the problem, which is not helpful to my students
> while they struggle with the physical problem and how to solve it with Maxima.

Thorsten, I have not followed this thread, so the following may be well
wide of the mark. I think that you have a relatively simple problem for
which ezunits is perhaps overkill. A dimensionful quantity is just an
ordered pair [quantity, dimension]. Maxima knows how to deal with these
sorts of things, so this would work:

dimsolve(l,r,var) := [solve(first(l)=first(r),var), subst(var='units,solve(second(l)=second(r),var))];

dimsolve can be used like so:

dimsolve([8,m]*v, [10,s], v);

=> [[v = 5/4],[units = s/m]]

You can play with the display of the output, so for example

dimsolve(l,r,var) := [var = subst(flatten([solve(first(l)=first(r),var),subst(var='units,solve(second(l)=second(r),var))]),[var,units])];

dimsolve([8,m]*v, [10,s], v);

=> [v = [5/4,s/m]]

which preserves the form of the input equation.

And yes, I did intentionally make a 'mistake' that v (velocity) is in
s/m not m/s.

Note that this will work with ezunits, too, but this form is more awkward:

dimsolve((8`m)*(v`v), 10`s, v);

=> [v = [5/4,s/m]]

A little work would return the output in the form of the input.

-- 
Leo Butler                <l_butler at users.sourceforge.net>
SDF Public Access UNIX System -   http://sdf.lonestar.org