Skip to content

Commit eded0e7

Browse files
author
Matthias Koeppe
committed
MPowerSeries.log: Don't use symbolics to compute log(1)
1 parent ca94eb4 commit eded0e7

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/sage/rings/multi_power_series_ring_element.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,7 +1910,7 @@ def exp(self, prec=infinity):
19101910
are not yet implemented and therefore such cases raise an error::
19111911
19121912
sage: g = 2 + f
1913-
sage: exp(g)
1913+
sage: exp(g) # needs sage.symbolic
19141914
Traceback (most recent call last):
19151915
...
19161916
TypeError: unsupported operand parent(s) for *: 'Symbolic Ring' and
@@ -1920,7 +1920,7 @@ def exp(self, prec=infinity):
19201920
Another workaround for this limitation is to change base ring
19211921
to one which is closed under exponentiation, such as `\RR` or `\CC`::
19221922
1923-
sage: exp(g.change_ring(RDF))
1923+
sage: exp(g.change_ring(RDF)) # needs sage.symbolic
19241924
7.38905609... + 7.38905609...*a + 7.38905609...*b + 3.69452804...*a^2 +
19251925
14.7781121...*a*b + 3.69452804...*b^2 + O(a, b)^3
19261926
@@ -2003,7 +2003,7 @@ def log(self, prec=infinity):
20032003
are not yet implemented and therefore such cases raise an error::
20042004
20052005
sage: g = 2 + f
2006-
sage: log(g)
2006+
sage: log(g) # needs sage.symbolic
20072007
Traceback (most recent call last):
20082008
...
20092009
TypeError: unsupported operand parent(s) for -: 'Symbolic Ring' and 'Power
@@ -2012,7 +2012,7 @@ def log(self, prec=infinity):
20122012
Another workaround for this limitation is to change base ring
20132013
to one which is closed under exponentiation, such as `\RR` or `\CC`::
20142014
2015-
sage: log(g.change_ring(RDF))
2015+
sage: log(g.change_ring(RDF)) # needs sage.symbolic
20162016
1.09861228... + 0.333333333...*a + 0.333333333...*b - 0.0555555555...*a^2
20172017
+ 0.222222222...*a*b - 0.0555555555...*b^2 + 0.0123456790...*a^3
20182018
- 0.0740740740...*a^2*b - 0.0740740740...*a*b^2 + 0.0123456790...*b^3
@@ -2039,11 +2039,14 @@ def log(self, prec=infinity):
20392039
R = self.parent()
20402040
Rbg = R._bg_power_series_ring
20412041

2042-
from sage.functions.log import log
20432042
c = self.constant_coefficient()
20442043
if c.is_zero():
20452044
raise ValueError('Can only take formal power series for non-zero constant term.')
2046-
log_c = log(c)
2045+
if c.is_one():
2046+
log_c = self.base_ring().zero()
2047+
else:
2048+
from sage.functions.log import log
2049+
log_c = log(c)
20472050
x = 1 - self._bg_value/c
20482051
if x.is_zero():
20492052
return log_c

0 commit comments

Comments
 (0)