Skip to content

🤖 Complex fixes - #1917

Open
KristofferC wants to merge 3 commits into
JuliaSymbolics:masterfrom
KristofferC:kc/complex-substitute-fixes
Open

🤖 Complex fixes#1917
KristofferC wants to merge 3 commits into
JuliaSymbolics:masterfrom
KristofferC:kc/complex-substitute-fixes

Conversation

@KristofferC

Copy link
Copy Markdown
Contributor

I saw a slack thread with some issues w.r.t complex numbers. This is what the robot identified.

KristofferC and others added 2 commits July 4, 2026 21:25
Raising a `Complex{Num}` (or any complex number) to a symbolic power went
through a method that still referenced `Symbolics.Pow`, which no longer
exists, so e.g. `(1 + im*sin(t))^0.5` threw an `UndefVarError`. Build the
power term through `term`/`wrap` instead.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Both helpers only built a term when `symtype(n) === Real` exactly, and
silently returned `nothing` otherwise. Any complex-symtype argument --
e.g. the Cardano-formula roots emitted by `symbolic_solve` for a cubic
with complex coefficients, or such a root after substituting a complex
value -- therefore produced errors like
`MethodError: no method matching *(::Int64, ::Nothing)`. Fall through to
`term(...)` unconditionally, as `slog` already did.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov-commenter

codecov-commenter commented Jul 4, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 0% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 23.90%. Comparing base (c2fc0d6) to head (9d79f73).
⚠️ Report is 147 commits behind head on master.

Files with missing lines Patch % Lines
src/solver/solve_helpers.jl 0.00% 8 Missing ⚠️
src/solver/univar.jl 0.00% 6 Missing ⚠️
src/solver/attract.jl 0.00% 1 Missing ⚠️
src/solver/main.jl 0.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

❗ There is a different number of reports uploaded between BASE (c2fc0d6) and HEAD (9d79f73). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (c2fc0d6) HEAD (9d79f73)
5 4
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #1917       +/-   ##
===========================================
- Coverage   80.83%   23.90%   -56.93%     
===========================================
  Files          59       59               
  Lines        5733     5701       -32     
===========================================
- Hits         4634     1363     -3271     
- Misses       1099     4338     +3239     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

SymbolicUtils restricts `//` to integer/rational symtypes, so the cubic
and quartic formulas in `get_roots_deg3`/`get_roots_deg4` (and the log
attract rule) threw a MethodError as soon as a coefficient was a float
or a symbolic expression, e.g.
`symbolic_solve(x^3 + x^2*cos(t) + x*sin(t) + 1, x)`.

For symbolic arguments `//` builds the same `Div` as `/` anyway, so add
an `sdiv` helper that uses `/` for symbolic arguments and keeps exact
rational division for plain numbers, and use it at those call sites.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@AayushSabharwal

Copy link
Copy Markdown
Member

Requires JuliaSymbolics/SymbolicUtils.jl#1003

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants