One of the things I find most frustrating about programming languages is the way they use “type” checking rather than dimensional commensurability as the foundation. I mean relation tables have columns that, properly treated, can be seen as dimensions of measurements that implicitly resolves the “object relational impedance mismatch”. So I was really happy to see Mathematica provided facilities for dimensional commensurability with units as a kind of “I/O format” for quantification.
But when I tried to use these essential features in a rigorous manner, I ran into a brick wall with FindRoot and found I had to not only convert everything to SI units but I had to strip off just the units with QuantityMagnitude everywhere, thereby exposing my notebook to the same old errors that arise when there is no checking.
It seems I must be doing something wrong here since such an essentially attractive feature of Mathematica in any real world application can’t be disabled by a function so basic as FindRoot. So what am I doing wrong?
FindRoot does work with Quantity, but you have to provide the appropriate units for the variables. You can read the tutorial on Numerical Calculations with Units, which also provides an example:
Then perhaps I’ve found a bug in Mathematica’s handling of Units with FindRoot because here’s the opaque error message (“Message text not found”) that appears when I don’t strip off the Units with QuantityMagnitude: