Skip to content

Commit e17a93a

Browse files
author
Release Manager
committed
sagemathgh-36773: Raise a power series to a power series <!-- ^^^^^ 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 --> This adds the functionality to compute the power series `f^g` when it is well defined. <!-- Why is this change required? What problem does it solve? --> This adds functionality that is useful for generating function computations. <!-- If this PR resolves an open issue, please link to it here. For example "Fixes sagemath#12345". --> Fixes sagemath#36772. <!-- 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. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] 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: ... --> N/A <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#36773 Reported by: trevorkarn Reviewer(s): Frédéric Chapoton, Pietro-D, Travis Scrimshaw
2 parents 4cdd703 + 39d648d commit e17a93a

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/sage/rings/power_series_ring_element.pyx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
104104
import sage.misc.misc
105105
import sage.arith.all as arith
106106
import sage.misc.latex
107+
from sage.structure.element import parent
107108
from sage.rings.integer import Integer
108109
from sage.rings.finite_rings.integer_mod_ring import IntegerModRing
109110

@@ -1135,11 +1136,34 @@ cdef class PowerSeries(AlgebraElement):
11351136
x + x^3
11361137
sage: O(x^4)^(1/2)
11371138
O(x^2)
1139+
1140+
sage: R.<x,t> = QQ[[]]
1141+
sage: f = (1+x)^(1+t)
1142+
sage: f.O(5)
1143+
1 + x + x*t + 1/2*x^2*t - 1/6*x^3*t + 1/2*x^2*t^2 + O(x, t)^5
1144+
1145+
sage: R.<x> = QQ[[]]
1146+
sage: (e^(e^x - 1)).O(5)
1147+
1 + x + x^2 + 5/6*x^3 + 5/8*x^4 + O(x^5)
1148+
sage: e^e^x
1149+
Traceback (most recent call last):
1150+
...
1151+
ArithmeticError: constant term of power series does not support exponentiation
1152+
1153+
sage: R.<x> = QQ[[]]
1154+
sage: S.<t> = QQ[] # a polynomial ring
1155+
sage: (1+x)^(1+t)
1156+
Traceback (most recent call last):
1157+
...
1158+
ValueError: exponent must be a rational number or power series
11381159
"""
11391160
try:
11401161
right = QQ.coerce(r)
1141-
except TypeError:
1142-
raise ValueError("exponent must be a rational number")
1162+
except (TypeError, ValueError):
1163+
if r.parent() is self.parent():
1164+
return (r * self.log()).exp()
1165+
else:
1166+
raise ValueError("exponent must be a rational number or power series")
11431167

11441168
if right.denominator() == 1:
11451169
right = right.numerator()

0 commit comments

Comments
 (0)