Dear FriCas Developers & Users,

I wonder what the opinion of the FriCAS experts is on the question if the F# approach (units are parts of types) or the "traditional" approach (units are part of the value) approach looks more suitable for FriCAS.

IMHO it is conceptually better to treat units as part of the type, so that one can check dimensionality of equations without inserting actual values.

The question is if the symbolic mathematics engine of FriCAS could handle number types extended with a unit.

In either case the unit system should support

- rational exponents for dimensions

- logarithms of units

Otherwise perfectly valid equations would not type check or compute. In general it doesn't make a lot of sense to have fractional units in end results (square roots happen) but it is quite frequent that intermediate results have fractional units and then cancel out in the end.

The code in https://wiki.fricas.org/SandBoxPhysicalUnitSystem will only work in rather simple cases (it supports neither of the above). The extension to rational units should be easy, but the support for log units might be tricky.

If one puts units in types, one needs a fairly flexible unit system to avoid that e.g. results of an integration don't type check. If one puts units into values things are more relaxed because one can do some simplifications before one substitutes values with units into a term. E.g. what I do frequently in Mathematica is to fully expand and then ReplaceAll (/.) with

a_^e_*b_^f_ /; ! IntegerQ[e] && ! IntegerQ[f] && IntegerQ[Simplify[e + f]] -> (a/b)^e*b^(Simplify[e + f])

Here the (a/b)^e part always ends up to have unit 1 because in final results fractional units don't make sense (and I did expand before). The b^(e+f) part can have arbitrary units because the exponent is known to be an integer. I use similar simplifications for logarithms and exponentials.

Note that in a programming language like F# fractional units and log units are not required, because one would generally use reasonably "unit nice" simplified forms of terms. But a CAS has to be able to handle intermediate results and simplifications - unless one wants to delegate this to the user in a "units in values" concept as e.g. Mathematica and Maxima do.

Best regards,

Michael

--
You received this message because you are subscribed to the Google Groups "FriCAS - 
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/4027bf63-80e2-4dc8-a665-c375c619d909%40michael-soegtrop.de.

Reply via email to