Skip to content

Inverting ln or arctan, and simplifying sqrt(e^(2x)), ignore the principal range off the real line #2713

In review

Description

@Rafael-SOWNet

On master (409d688), a few inversions and one simplification ignore the range of ln, arctan and the principal root off the real line. Every real answer in these is right; the wrong members are complex.

input master what is wrong
solve(e^(ln(x)^2) = 1) e^(±sqrt(2 pi i n)) at n = 5, sqrt(10 pi i) has imaginary part 3.96 > pi, so it is not ln of anything; e^(ln(x)^2) - 1 there is 27337 + 13573i (mpmath). The same happens for sin, cos and tan(ln(x)^2) = c (36 rows)
solve(abs(arctan(x)) = 2) tan(2 e^(i r_1)) arctan's real part is in (-pi/2, pi/2); at r = 0.3, abs(arctan(x)) is 1.365
simplify(sqrt(e^(2x))) e^x wrong where abs(Im(2x)) > pi, e.g. x = 2.1 - 1.7i
simplify((e^(2x))^(1/4)) e^(x/2) same

Found by a solve sweep after #2705.

Activity

  1. added this to the 2.11 milestone on Dec 5, 2026
  2. added theissue type on Dec 5, 2026
  3. Rafael-SOWNet commented on Dec 5, 2026

    @Rafael-SOWNet
    MemberAuthor

    Three additions to the two simplification rows, measured on the package 2.10.0 and on master 409d688.

    A counterexample that needs no numerics. sqrt(e^x) simplifies to e ^ (x / 2), and at x = 2πi the first is 1 and the second is −1:

    Entity root = "sqrt(e^x)";
    Console.WriteLine(root.Simplify());                                        // e ^ (x / 2)
    Console.WriteLine(root.Substitute("x", "2 * pi * i").Evaled);              // 1
    Console.WriteLine(root.Simplify().Substitute("x", "2 * pi * i").Evaled);   // -1

    It is any positive numeric base and any outer exponent that is not whole, not only e and a root of e^(2x):

    Input Simplify
    (e^x)^(1/3) e ^ (x / 3): at 2πi the input is 1, this is −1/2 + 0.866 i
    (e^x)^(-1/2) e ^ (-1/2 * x)
    (2^x)^(1/2) 2 ^ (x / 2)
    (e^(3 y))^y e ^ (3 * y ^ 2)
    (e^x)^(1/2) - e^(x/2) 0

    With a letter for the base it is left alone: (a^x)^(1/2) stays sqrt(a ^ x) and (x^2)^(1/2) stays sqrt(x ^ 2).

    Where to look, and one place that is not enough. The ({} ^ {}) ^ {} = {} ^ ({} * {}) arm of Patterns.PowerRules fires when any3 is Integer || any1.Evaled is Real { IsPositive: true }, and its comment, from #752, says the identity is "true for a positive base whatever the exponents". That holds where the inner exponent is real; with a complex one a^b is anywhere on the plane and the outer power takes a branch. But that arm is not the only route. With its condition narrowed to any3 is Integer in a scratch build of master, sqrt(e^x), the cube root, the −1/2 power, base 2 and the difference above all came back exactly as before. I did not find the second place.

    Found by fuzzing: of 39,500 random expressions compared with their Simplify at three complex points, 24 changed value, and all 24 are this rewrite.

  4. moved this from Todo to In Progress in AngouriMathon Dec 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions