Skip to content

Conversation

smichr
Copy link
Member

@smichr smichr commented Oct 1, 2023

References to other Issues or PRs

Brief description of what is fixed or changed

master:

>>> expand_log(log(2*10)/log(10))
log(20)/log(10)
>>> _.expand(log=True)
log(20)/log(10)
>>> expand(_, factor=True)
2*log(2)/(log(2) + log(5)) + log(5)/(log(2) + log(5))

now

>>> (log(2*10)/log(10)).expand(log=True)
log(20)/log(10)
>>> expand_log(log(2*10)/log(10))
1 + log(2)/log(10)

Other comments

While factoring a single logs argument might be avoided because of the size of a number, when there is a ratio of logs, the lower arg gives a hint of what to check for in the upper. This would be easier to detect if log(a,b) did not auto evaluate to log(a)/log(b).

I don't really like that expand(..., log=True) does nothing. Maybe the action of this PR should be done if factor is false but log is true.

I would prefer to have log(x, i) remain unevaluated instead of rewriting to log(x)/log(i).

Release Notes

  • core
    • expand_log now detects the ratio log(a)/log(b) and will simplify if a == c*b**m

@sympy-bot
Copy link

sympy-bot commented Oct 1, 2023

Hi, I am the SymPy bot. I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

  • core
    • expand_log now detects the ratio log(a)/log(b) and will simplify if a == c*b**m (#25751 by @smichr)

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.13.

Click here to see the pull request description that was parsed.
<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234" (see
https://tinyurl.com/auto-closing for more information). Also, please
write a comment on that issue linking back to this pull request once it is
open. -->


#### Brief description of what is fixed or changed

master:
```python
>>> expand_log(log(2*10)/log(10))
log(20)/log(10)
>>> _.expand(log=True)
log(20)/log(10)
>>> expand(_, factor=True)
2*log(2)/(log(2) + log(5)) + log(5)/(log(2) + log(5))
```
now
```python
>>> (log(2*10)/log(10)).expand(log=True)
log(20)/log(10)
>>> expand_log(log(2*10)/log(10))
1 + log(2)/log(10)
```
#### Other comments
While factoring a single logs argument might be avoided because of the size of a number, when there is a ratio of logs, the lower arg gives a hint of what to check for in the upper. This would be easier to detect if log(a,b) did not auto evaluate to log(a)/log(b).

I don't really like that `expand(..., log=True)` does nothing. Maybe the action of this PR should be done if factor is false but log is true.

I would prefer to have `log(x, i)` remain unevaluated instead of rewriting to `log(x)/log(i)`.

#### Release Notes

<!-- Write the release notes for this release below between the BEGIN and END
statements. The basic format is a bulleted list with the name of the subpackage
and the release note for this PR. For example:

* solvers
  * Added a new solver for logarithmic equations.

* functions
  * Fixed a bug with log of integers. Formerly, `log(-x)` incorrectly gave `-log(x)`.

* physics.units
  * Corrected a semantical error in the conversion between volt and statvolt which
    reported the volt as being larger than the statvolt.

or if no release note(s) should be included use:

NO ENTRY

See https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more
information on how to write release notes. The bot will check your release
notes automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
* core
  * `expand_log` now detects the ratio `log(a)/log(b)` and will simplify if `a == c*b**m`
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@github-actions
Copy link

github-actions bot commented Oct 1, 2023

Benchmark results from GitHub Actions

Lower numbers are good, higher numbers are bad. A ratio less than 1
means a speed up and greater than 1 means a slowdown. Green lines
beginning with + are slowdowns (the PR is slower then master or
master is slower than the previous release). Red lines beginning
with - are speedups.

Significantly changed benchmark results (PR vs master)

Significantly changed benchmark results (master vs previous release)

| Change   | Before [8059df73] <sympy-1.12^0>   | After [6e347f05]    |   Ratio | Benchmark (Parameter)                                                |
|----------|------------------------------------|---------------------|---------|----------------------------------------------------------------------|
| -        | 83.5±0.5ms                         | 55.1±0.3ms          |    0.66 | integrate.TimeIntegrationRisch02.time_doit(10)                       |
| -        | 82.0±0.2ms                         | 54.5±0.3ms          |    0.66 | integrate.TimeIntegrationRisch02.time_doit_risch(10)                 |
| +        | 20.0±0.2μs                         | 40.1±0.2μs          |    2    | integrate.TimeIntegrationRisch03.time_doit(1)                        |
| -        | 6.89±0.02ms                        | 3.67±0.01ms         |    0.53 | logic.LogicSuite.time_load_file                                      |
| -        | 2.11±0ms                           | 624±6μs             |    0.3  | polys.TimePREM_LinearDenseQuadraticGCD.time_op(3, 'sparse')          |
| -        | 10.4±0.03ms                        | 1.88±0ms            |    0.18 | polys.TimePREM_LinearDenseQuadraticGCD.time_op(5, 'sparse')          |
| -        | 368±2μs                            | 79.3±0.1μs          |    0.22 | polys.TimePREM_QuadraticNonMonicGCD.time_op(1, 'sparse')             |
| -        | 4.73±0.01ms                        | 349±2μs             |    0.07 | polys.TimePREM_QuadraticNonMonicGCD.time_op(3, 'sparse')             |
| -        | 10.6±0.03ms                        | 1.05±0.01ms         |    0.1  | polys.TimePREM_QuadraticNonMonicGCD.time_op(5, 'sparse')             |
| -        | 6.30±0.02ms                        | 3.81±0.01ms         |    0.6  | polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(2, 'sparse') |
| -        | 27.7±0.06ms                        | 11.6±0.01ms         |    0.42 | polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(3, 'sparse') |
| -        | 6.81±0.05ms                        | 1.12±0ms            |    0.17 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(1, 'sparse')    |
| -        | 16.0±0.09ms                        | 9.01±0.05ms         |    0.56 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(2, 'sparse')    |
| -        | 206±0.2ms                          | 68.6±0.09ms         |    0.33 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(3, 'sparse')    |
| -        | 6.37±0.01ms                        | 508±0.7μs           |    0.08 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(3, 'sparse')     |
| -        | 27.3±0.05ms                        | 809±2μs             |    0.03 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(5, 'sparse')     |
| -        | 594±1μs                            | 201±0.3μs           |    0.34 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(1, 'sparse') |
| -        | 6.34±0.02ms                        | 205±0.5μs           |    0.03 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(3, 'sparse') |
| -        | 16.5±0.04ms                        | 208±1μs             |    0.01 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(5, 'sparse') |
| -        | 162±0.5μs                          | 90.9±0.3μs          |    0.56 | solve.TimeMatrixOperations.time_rref(3, 0)                           |
| -        | 304±0.5μs                          | 108±0.5μs           |    0.35 | solve.TimeMatrixOperations.time_rref(4, 0)                           |
| -        | 30.0±0.08ms                        | 12.7±0.02ms         |    0.42 | solve.TimeSolveLinSys189x49.time_solve_lin_sys                       |

Full benchmark results can be found as artifacts in GitHub Actions
(click on checks at the top of the PR).

@smichr smichr marked this pull request as ready for review October 1, 2023 15:31
@smichr
Copy link
Member Author

smichr commented Oct 5, 2023

@asmeurer , what do you think about removing autoevaluation of log(x,i) as log(x)/log(i)?

@smichr smichr merged commit f327f0b into sympy:master Oct 11, 2023
@smichr smichr deleted the log branch October 11, 2023 20:51
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.

2 participants