Skip to content

Over the complex numbers an exponential equation is answered with its principal root only #2319

Closed

Description

@Rafael-SOWNet

Over the complex numbers, the default codomain, Solve answers an exponential equation with its principal root only:

Solve("x") answer the roots
e^x = 2 { ln(2) } ln(2) + 2 pi i n for every whole n
e^x = -1 { ln(-1) } (2n + 1) pi i
e^(2x) - 3e^x + 2 = 0 { 0, ln(2) } 2 pi i n and ln(2) + 2 pi i n
2^x = 5 { log(2, 5) } log(2, 5) + 2 pi i n / ln(2)

The other periodic and multivalued routes already answer the whole family with an integer parameter: sin(x) = 0 is { 2 * pi * n_1, pi + 2 * pi * n_1 }, and x e^x = 2 is { lambertw(n_1, 2) }. A finite set says these are all the roots, so the exponential answers are incomplete. Powf's inversion carries a TODO for it: "determine how we should return periodic roots".

A cross-check of random exponential equations against a Newton search finds every root it reaches, and these answers lack them. Over the reals the principal root is the only one, and nothing there changes.

Two ways:

  1. Answer the family over the complex numbers, ln(c) + 2 pi i n_1, as the trigonometric equations and the Lambert W route do, keeping ln(c) over the reals. That changes the answer to every exponential equation in the default codomain, and whatever reads those answers (substitutions, systems) has to take a parameter.
  2. Keep the principal root and say so where Solve is documented, as a known incompleteness.

I'd go with 1, since it's what the rest of the solver already does. Which do you prefer?

Activity

  1. added this to the 2.8 milestone on Nov 1, 2026
  2. added
    Opinions wanted
    on Nov 1, 2026
  3. Rafael-SOWNet commented on Nov 1, 2026

    @Rafael-SOWNet
    MemberAuthor

    The same holds for a trigonometric equation solved through e^(ix), as a polynomial in it with x = ln(root) / i. Those lose their families too:

    Solve("x") answer the roots
    cos(x) = 3 sin(x) { ln(sqrt(4/5 + 3/5 i)) / i, ln(-sqrt(4/5 + 3/5 i)) / i } arctan(1/3) + pi n
    sin(2x) = sin(x) { ln(-1) / i, 0, … } 2 pi n, pi + 2 pi n, ±pi/3 + 2 pi n
    tan(x) = 1/3 { arctan(1/3) + pi * n_1 } the family

    So with option 1 the families would come back for these as well, from the same place.

  4. Happypig375 commented on Nov 2, 2026

    @Happypig375
    Member

    need to indicate that n is integer as well, maybe provided n in ZZ?

  5. Happypig375 commented on Nov 2, 2026

    @Happypig375
    Member

    solve is supposed to do for all solutions; the "principal" solution is probably the one when n is 0?

  6. Rafael-SOWNet commented on Nov 2, 2026

    @Rafael-SOWNet
    MemberAuthor

    Yes, n = 0 is the principal root, ln(c).

    For marking n as whole, I measured two spellings on master:

    { 2 pi n provided n in ZZ } union({ 2 pi n }, n in ZZ)
    4 pi in undecided yes
    3 pi in undecided undecided
    n free, so it can clash with an n elsewhere bound

    union(A_n, n in ZZ) is the indexed union from #1409. It already exists and answers membership through exists n in ZZ. I'd use it for every family, so the trigonometric and Lambert W answers read the same as the new exponential ones. The cost is that a periodic answer stops being a finite set, so whatever takes an answer apart (systems, substituting roots back) has to read the union. I'll measure that on the branch.

    Is the union OK, or do you prefer provided n in ZZ?

  7. Rafael-SOWNet commented on Nov 15, 2026

    @Rafael-SOWNet
    MemberAuthor

    A recommendation: the whole family, written as an indexed union, union({ln(2) + 2*pi*i*n}, n in ZZ).

    Today (master 3abd4d9be), over the complex numbers: e^x = 2 is { ln(2) }, 2^x = 5 is { log(2, 5) }, and sin(e^x) = 0 is { ln(2*pi*n_1), ln(pi + 2*pi*n_1) }, which loses the inner family too. A finite set claims to be every root, so these are incomplete rather than partial.

    • Union, not provided. The union binds n and decides membership: 4*pi in union({2*pi*n}, n in ZZ) is decided as yes, while with provided n in ZZ, or today's free n_1, it is undecided. The union is SymPy's ImageSet over Integers (solveset) in the library's notation; Wolfram writes C[1] ∈ Integers as a ConditionalExpression (Solve).
    • Consistency: move the trigonometric and Lambert W families (2*pi*n_1, lambertw(n_1, 2)) to the union in the same change, and keep a free n_1 only in system rows, where a matrix entry cannot bind it. Support parametric solutions #212's option 1 then names it (n_1, ZZ), so the two decisions fit together.
    • Over the reals, keep ln(c) through the codomain.

    What it needs, in order:

    1. The exponential's period under forall. A family is checked by substituting it back, as forall n in ZZ : residual = 0. The trigonometric families pass: forall n in ZZ : sin(x + 2*pi*n) = sin(x) is True. These would not: forall n in ZZ : e^(2*pi*i*n) = 1, forall n in ZZ : e^(x + 2*pi*i*n) = e^x and forall n in ZZ : 2^(log(2, 5) + 2*pi*i*n/ln(2)) = 5 are all left undecided. A whole number of periods has to come out of an exponential as it does out of a sine.
    2. A second index, and an index set without 0. sin(e^x) = 0 is e^x = pi*k for a whole k other than 0, since e^x is never 0. Its roots are union(union({ln(pi*k) + 2*pi*i*m}, m in ZZ), k in ZZ \ {0}). That parses today, and ln(3*pi) + 4*pi*i in it is decided as yes. Today's answer has ln(0) at n_1 = 0.
    3. Readers of a root set. Everything that takes a root set apart (systems, substituting roots back, the root-completeness harnesses) has to read a union.

    #2458, FreeVariables reporting the union's index as free, is fixed (#2464).

    That is medium to large, and it changes every complex exponential and trigonometric answer, so it needs a breaking-change entry. It fits 2.8 as a fix for incomplete answers. If the trigonometric re-spelling is judged a change of representation rather than a fix, it can split off to v3.

    Edited 2026-11-16: re-measured on 3abd4d9be. #2458 was listed as the first step and is fixed; steps 1 and 2 are new.

  8. moved this from Todo to In Progress in AngouriMathon Nov 16, 2026
  9. moved this from In Progress to Done in AngouriMathon Nov 16, 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

    Opinions wanted

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions