mkulesh / microMathematics

microMathematics Plus - Extended visual calculator
GNU General Public License v3.0
561 stars 68 forks source link

Calculation of the definite integral does not respect measure units #99

Closed mmaxs closed 3 years ago

mmaxs commented 3 years ago

Here is the example: Screenshot_2020-11-18-02-14-11

mkulesh commented 3 years ago

Hi @mmaxs, thank you for this bug report. It is now fixed. If you like to test it, please install: https://github.com/mkulesh/microMathematics/raw/autobuild/autobuild/microMathematics-v2.20.1-debug.apk

integ_units

mmaxs commented 3 years ago

Thanks a lot, Mikhail. I use microMath+ to write down solutions to the problems from school physics course, and there dealing with units and units themselves are of the same importance as numeric values.

I noticed that after the second patch there is no need to specify the unit for the variable of integration. I don't understand what is for and what exactly such a construction is meaning. I have written down some test cases for that:

IMG_20201121_213857 According to the numeric results at line 4 toMin is seemed to be handled as x * 1 min (and respectively, toSec(x) := x * 1 s. But if it is so, then toMin(1 s) should be = 1 s 1 min = 1 s 60 s = 60 s^2 toMin(1 min) = 1 min 1 min = 60 s 60 s = 3600 s^2 toMin(1/s) = 1/(1 s) 1 min = 1/(1 s) 60 s = 60 (dimensionless) toMin(1/min) = 1/(1 min) * 1 min = 1 (dimensionless) The results on the screen look like if the unit of the function argument is discarded i.e. 1 min = 60 s and 60 is involved in calculations but the unit s is discarded.

mkulesh commented 3 years ago

Hi @mmaxs Unfortunately I have never designed units to be used in such a way. The idea behind units is that all input parameters (that may be given in derived units like min, hour atc) will be automatically converted to the base CI unit (i.e seconds) before calculation and the calculation will be done with this base units. The result will be given also using base CI unit: example1

If you like to show the result in derived units (like minutes instead of seconds), you shall select the resulting equation, long tab on it, open result properties dialog and put the desired derived units: example2

After it, the result will be converted to the given units: example3

Such a conversion like in your examples is not designed and therefore have an undefined behavior. Of course it is possible to expand the syntax, for example add a build-in function like toUnits(x, u) where x is any variable with some base or derived unit and u is the target unit to which x shall be converted. If you like this solution please create a new issue and I will implement it asap. If you have any other idea please write me on mikhail.kulesh@gmail.com and we can discuss it.

The initial problem (measure units within a definite integral) is now fixed and released in v2.20.1 and, therefore, I would like to close this issue.