Skip to content

Commit

Permalink
sagemathgh-36260: MPowerSeries: Don't go through symbolics to compu…
Browse files Browse the repository at this point in the history
…te exp(0), log(1)

    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
- Part of: sagemath#29705
- Cherry-picked from: sagemath#35095
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [ ] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->
- Depends on sagemath#36240 (merged here)
- Depends on sagemath#36263 (merged here)

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36260
Reported by: Matthias Köppe
Reviewer(s): Matthias Köppe, Michael Orlitzky
  • Loading branch information
Release Manager committed Sep 15, 2023
2 parents cac16e2 + e2a76d2 commit c95bd14
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/sage/rings/multi_power_series_ring_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -1910,7 +1910,7 @@ def exp(self, prec=infinity):
are not yet implemented and therefore such cases raise an error::
sage: g = 2 + f
sage: exp(g)
sage: exp(g) # needs sage.symbolic
Traceback (most recent call last):
...
TypeError: unsupported operand parent(s) for *: 'Symbolic Ring' and
Expand Down Expand Up @@ -1944,9 +1944,12 @@ def exp(self, prec=infinity):
R = self.parent()
Rbg = R._bg_power_series_ring

from sage.functions.log import exp
c = self.constant_coefficient()
exp_c = exp(c)
if not c:
exp_c = self.base_ring().one()
else:
from sage.functions.log import exp
exp_c = exp(c)
x = self._bg_value - c
if x.is_zero():
return exp_c
Expand Down Expand Up @@ -2000,7 +2003,7 @@ def log(self, prec=infinity):
are not yet implemented and therefore such cases raise an error::
sage: g = 2 + f
sage: log(g)
sage: log(g) # needs sage.symbolic
Traceback (most recent call last):
...
TypeError: unsupported operand parent(s) for -: 'Symbolic Ring' and 'Power
Expand Down Expand Up @@ -2036,11 +2039,14 @@ def log(self, prec=infinity):
R = self.parent()
Rbg = R._bg_power_series_ring

from sage.functions.log import log
c = self.constant_coefficient()
if c.is_zero():
raise ValueError('Can only take formal power series for non-zero constant term.')
log_c = log(c)
if c.is_one():
log_c = self.base_ring().zero()
else:
from sage.functions.log import log
log_c = log(c)
x = 1 - self._bg_value/c
if x.is_zero():
return log_c
Expand Down

0 comments on commit c95bd14

Please sign in to comment.