#1011255 mathomatic: "Simplify"ing powers can lead to "Complex" results and NaNs

Package:
mathomatic
Source:
mathomatic
Description:
portable Computer Algebra System (CAS)
Submitter:
"Kingsley G. Morse Jr."
Date:
2022-05-18 22:00:03 UTC
Severity:
normal
Tags:
#1011255#5
Date:
2022-05-18 21:48:52 UTC
From:
To:
Dear Tony,

Thank you very much for maintaining Debian's
mathomatic package.

It's colorful and easy to use.

The main reason I'm writing is to give a specific
example suggesting, at least to yours truly, that
ol' mathomatic might try to simplify math
expressions containing exponents/powers a little
too agressively.

When I type this at a linux bash shell command
line...

    $ mathomatic -e -- "(X^2)^0.50001"

mathomatic returns

    1-> (X^2)^0.50001

    #1: X^1.00002

As you can see, mathomatic automatically
simplifyed the

    "^2" and

    "^0.50001"

powers into just

    "^1.00002"

But, I'm worried that if the X variable contains a
*negative* number, mathomatic's automatic
"simplification" may lead to

    "complex" imaginary numbers and

    so called "Not a Number"s (ie: "NaN"s)

down stream.

To be fair, mathomatic's documentation admits

    "With Mathomatic, if x is imaginary, you may
    get an unwanted imaginary result"

at

https://fossies.org/linux/mathomatic/doc/manual.html

I humbly suggest

1.) Consider enhancing mathomatic to give its
    user more control over

        when and

        how aggressively

    it simplifies exponents.

    Three options are reviewed at

https://docs.sympy.org/latest/tutorial/simplification.html#powers

    Mathomatic's "simplify" command already has a
    "symbolic" option that approaches a fix.

    You can see this is so at

https://fossies.org/linux/mathomatic/doc/am.html#simplify


2.) Use python's sympy module instead.

    But it's not quite as

        easy or

        colorful.

Thanks again,
Kingsley