Skip to content

An equation linear in logarithms is solved by exponentiating - #2316

Merged
Rafael-SOWNet merged 2 commits into
masterfrom
an-equation-linear-in-logarithms-is-solved-by-exponentiating
Nov 1, 2026
Merged

Rafael-SOWNet merged 2 commits into
masterfrom
an-equation-linear-in-logarithms-is-solved-by-exponentiating

Conversation

@Rafael-SOWNet

@Rafael-SOWNet Rafael-SOWNet commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

An equation in two or more logarithms of x had no route of its own. It came to Newton's method, which answered in decimals and left out any root it didn't reach.

k_1 log_b(P_1) + … + k_n log_b(P_n) = c, for polynomials P_i, rational k_i and one base, holds only where P_1^(k_1 L) … P_n^(k_n L) = b^(c L), with L the common denominator of the k_i. That is a polynomial equation, and its roots are found exactly. Each one is put back into the equation as written, under the principal logarithm, and kept only where it holds, since over the complex numbers ln(u) + ln(v) is ln(u v) only up to 2 pi i. Over the reals each argument must also be positive.

Solve("x") 2.6.0 and master now
ln(x) + ln(x + 1) = 0 { 0.6180339887498947… } { (-1 + sqrt(5)) / 2 }
ln(1 + 3x^2) - ln(4x) = 1 { 3.529945609977906… } both roots, (4e ± sqrt(16e^2 - 12)) / 6
ln(-1 - 3x^2) - ln(4x) = 1 { -3.529945609977908… }, and on master … - 1.3E-15i both roots, negated, whose i pi cancel
ln(x^2 + 1) - ln(x) = 1 two decimals (e ± sqrt(e^2 - 4)) / 2
ln(x) + ln(x - 1) = ln(6) { 3 } { 3 }; at -2 the sum is ln(6) + 2 pi i
  • Measured on 400 random equations of this kind against a Newton search under the principal logarithm. Master answers 292, leaves 108 unsolved and misses 25 roots across 22 of its answers. This answers all 400, none unsound and none missing a root. The slowest takes 251 ms.
  • It declines where it can't be sure, leaving the equation to the routes after: a residual too small to tell from rounding, or a candidate that isn't a root of the polynomial it solved. 3x^3 + 9x^2 + 9x + 1 is one, since the polynomial solver answers it with a non-root until A cube shifted is solved #2315.
  • Six of the ten new cases fail on master. The other four have rational roots, which Newton's search plus rounding lands on exactly. The suite, the trio, F#, AOT and the eight harnesses pass. BREAKING-CHANGES.md has an entry.

No issue was filed.

🤖 Generated with Claude Code

An equation in two or more logarithms of x had no route of its own, and came to Newton's
method, which answered it in decimals and left out the roots it did not reach:
ln(x) + ln(x + 1) = 0 was { 0.618... } and ln(1 + 3x^2) - ln(4x) = 1 was { 3.53 }, without
0.0944.

k_1 log_b(P_1) + ... + k_n log_b(P_n) = c, for polynomials P_i, rational k_i and one base,
holds only where P_1^(k_1 L) ... P_n^(k_n L) = b^(c L), L being the common denominator of
the k_i: a polynomial equation, whose roots are found exactly. Each is put back into the
equation as written under the principal logarithm and kept only where it holds, since over
the complex numbers ln(u) + ln(v) is ln(u v) only up to 2 pi i: at (-1 - sqrt(5))/2 both
logarithms of ln(x) + ln(x + 1) carry i pi, and the sum is 2 pi i. Over the reals each
argument is to be positive as well. A residual too small to tell from rounding, or a candidate that is not a root of the
polynomial, leaves the equation to the routes after, since the roots the polynomial solver
missed would be left out: 3x^3 + 9x^2 + 9x + 1, a shifted cube, comes back as -1 three
times until #2315.

On 400 random equations of this kind, checked against a Newton search under the principal
logarithm, master answers 292, leaves 108 unsolved and misses 25 roots in 22 of its
answers; this answers all 400, none unsound and none missing a root.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Rafael-SOWNet Rafael-SOWNet added this to the 2.7.0 milestone Nov 1, 2026
@Rafael-SOWNet Rafael-SOWNet moved this from Todo to In review in AngouriMath Nov 1, 2026
@codecov

codecov Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.79487% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.75%. Comparing base (9880e18) to head (095f734).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ntinuous/Solvers/EquationSolver/LogarithmSolver.cs 71.05% 11 Missing and 11 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2316      +/-   ##
==========================================
- Coverage   86.78%   86.75%   -0.03%     
==========================================
  Files         311      312       +1     
  Lines       68221    68299      +78     
  Branches    19828    19857      +29     
==========================================
+ Hits        59203    59255      +52     
- Misses       4877     4890      +13     
- Partials     4141     4154      +13     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.30% <71.79%> (-0.03%) ⬇️
fsharp 32.97% <ø> (ø)
interactive 40.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...Solvers/EquationSolver/AnalyticalEquationSolver.cs 96.45% <100.00%> (+0.05%) ⬆️
...ntinuous/Solvers/EquationSolver/LogarithmSolver.cs 71.05% <71.05%> (ø)

... and 6 files with indirect coverage changes

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

…entiating

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Rafael-SOWNet
Rafael-SOWNet merged commit 9cd0c64 into master Nov 1, 2026
35 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in AngouriMath Nov 1, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the an-equation-linear-in-logarithms-is-solved-by-exponentiating branch November 1, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant