ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 23 Apr 2020 20:00:38 -0500How to base change from a PolynomialRing to that Ring with one variable evaluated, i.e., from Q[x,y] to Q[x,y]/(x=0) = Q[y]?https://ask.sagemath.org/question/50978/how-to-base-change-from-a-polynomialring-to-that-ring-with-one-variable-evaluated-ie-from-qxy-to-qxyx0-qy/I am trying to base change a Laurent series ring element from its base ring, Q[u1, u2, u3], to a quotient of its base ring, Q[u2, u3], but I am quite confused in forming this quotient. My setting is this:
S.<u1,u2,u3> = QQ[]
L.<z> = LaurentSeriesRing(S);
f = -4*z - 4/5*u1*z^5 + (-4/9*u1^2 - 8/9*u2)*z^9 + (-4/13*u1^3 - 24/13*u1*u2 - 12/13*u3)*z^13 + (-4/17*u1^4 - 48/17*u1^2*u2 - 24/17*u2^2 - 48/17*u1*u3 + 16/17*u1 + 16/17*u2 + 16/17*u3 + 16/17)*z^17 + O(z^20)
In other words, I wish to set u1 = 0, and look at f over that ring. I tried the following two things, which spit out f unchanged.
f.change_ring(S.quo(u1))
R = S.quotient(u1)
f.change_ring(R)
I also tried the following which gives an attribute error:
f.reduce(u1)
I am completely stuck and would deeply appreciate any help. I would also like to eventually set u2 = 0 and look at f over that ring, which I mention at the off chance that this changes the answer at all.masseygirlThu, 23 Apr 2020 20:00:38 -0500https://ask.sagemath.org/question/50978/Having trouble importing the lazy_laurent_series modulehttps://ask.sagemath.org/question/48608/having-trouble-importing-the-lazy_laurent_series-module/I am trying to import and use lazy Laurent series rings in sage, documented here: (http://doc.sagemath.org/html/en/reference/power_series/sage/rings/lazy_laurent_series_ring.html). I have the latest version of sage installed, and yet when I attempt to import/install the package it is nowhere to be found.
from sage.rings.lazy_laurent_series_ring import LazyLaurentSeriesRing
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-db0f55e1138b> in <module>()
----> 1 from sage.rings.lazy_laurent_series_ring import LazyLaurentSeriesRing
ImportError: No module named lazy_laurent_series_ring
I then tried to download it, perhaps I am not downloading the correct package? Where is it hiding?
sage -i lazy_laurent_series
Error: package 'lazy_laurent_series' not found
Note: if it is an old-style package, use -p instead of -i to install itmasseygirlMon, 04 Nov 2019 17:56:54 -0600https://ask.sagemath.org/question/48608/Puiseux series expansionhttps://ask.sagemath.org/question/32861/puiseux-series-expansion/Is there a function for a [Puiseux series](https://en.wikipedia.org/wiki/Puiseux_series) expansion? I found a posting ([here](https://groups.google.com/forum/#!topic/sage-devel/M0XDXGH_oXI)) that is from 2011, but it seems that the code has not found its way into the distribution. Can someone confirm this or please point me to the right function? Thanks!wrognWed, 23 Mar 2016 05:50:12 -0500https://ask.sagemath.org/question/32861/Symbolic sum/product of Laurent/power serieshttps://ask.sagemath.org/question/46367/symbolic-sumproduct-of-laurentpower-series/ How can I do something like this?
#f = some Laurent/power series in x e.g.
#a,b,w are symbolic such that e.g. 2*w**2 = 3
f = 1/x + w + a*x + b*x**2 + ((a+b)/w)**2*x**3 + O(x**7)
#g[i] = some power series in x derived from f, c[i], d[i], e.g.
g[i] = (x*f + c[i])/(d[i]*f + x**2)
#product of n first g[i]
#n is symbolic
G = product(g[i], i=1..n)
#extract coefficients of x in G
G.coeff(x,-1), G.coeff(x,0), G.coeff(x,1)
Thank you.RoadFri, 26 Apr 2019 12:44:06 -0500https://ask.sagemath.org/question/46367/Multivariate Laurent serieshttps://ask.sagemath.org/question/29669/multivariate-laurent-series/I'm trying to perform calculations with two variables $z, u$, one of which, $z$, should be invertible. Apparently Laurent series rings are not yet implemented for multivariate rings. I tried the following
R = QQ[['zed, you, zedi']]
R
Multivariate Power Series Ring in zed, you, zedi over Rational Field
x = R.gens()
x
(zed, you, zedi)
i = x[0]*x[2] - 1
i
-1 + zed*zedi
I = i*R
I
S = QuotientRing(R, I, names="z, u, xi")
S
Principal ideal (-1 + zed*zedi) of Multivariate Power Series Ring in zed, you, zedi over Rational Field
Quotient of Multivariate Power Series Ring in zed, you, zedi over Rational Field by the ideal (-1 + zed*zedi)
g = S.gens()
g
(zed, you, zedi)
g[0]*g[2]
zed*zedi
Apparently, in the quotient ring I still get that $z z^{-1}$ doesn't simplify to 1. Also, my assigned names aren't recognized. What am I doing wrong? Is this even the best way of dealing with multivariate Laurent polynomials?
Thank you. (This is my first day using sage and my first question here on ask.sagemath.org. Please let me know if I've done something wrong.)EarthlingThu, 01 Oct 2015 18:55:04 -0500https://ask.sagemath.org/question/29669/Valuation error when composing power serieshttps://ask.sagemath.org/question/43999/valuation-error-when-composing-power-series/ I'm trying to work with power series with coefficients in a ring consisting of elements $f/g$, where $f$ is a polynomial in several variables over the integers and g is a polynomial in one of those variables with unit constant coefficient. Ultimately, I'd like to be able to do all of the following:
- Compose power series over this ring
- Invert single-variable power series over this ring whose degree-1 coefficients are units
- Reduce the coefficients of a power series modulo some ideal of the ring
I thought I would do this by starting with the Laurent series over $\mathbf{Z}$ in the variable that occurs in the denominator, constructing a polynomial ring over this by adjoining the other variables, and letting my power series take coefficients in this ring. But I'm getting an error I don't understand when I try to compose series. The following example illustrates the problem:
M1.<b> = LaurentSeriesRing(ZZ)
M.<a,c> = PolynomialRing(M1)
R.<t1,t2> = PowerSeriesRing(M)
X = t1 + t2 + O(t1,t2)^3
R1.<t> = PowerSeriesRing(M)
f = X(t,t^2); f
This returns the type error `Substitution defined only for elements of positive valuation, unless self has infinite precision` despite the fact that replacing the last line by `t.valuation()` or `(t^2).valuation()` returns `1` or `2`, respectively.
The problem seems to result from a combination of factors. If I replace the second line with either
M.<a,c> = PolynomialRing(ZZ)
or
M.<a> = PolynomialRing(M1)
the error vanishes and the code returns the expected `t + t^2 + O(t)^3`. It also gives no error if I define `R` and `R1` to be polynomial rings, rather than power series rings, over `M` (and correspondingly delete the big-O notation).
Any ideas about what is triggering the error, or another way to construct these power series?Annie CarterFri, 19 Oct 2018 19:03:23 -0500https://ask.sagemath.org/question/43999/Laurent Expansion at Infinity / Root findinghttps://ask.sagemath.org/question/42317/laurent-expansion-at-infinity-root-finding/I'm new to sage, and I was trying to implement the following, to partial success:
I want to take the $p^{th}$ root of a polynomial (for a specified $p$), expand it as a Laurent series at infinity, and take the polynomial part of the expansion. I've written some code which seems to work with partial success, but it also fails in some very straightforward cases.
def poly_truncate(f):
g=f(1/x)
h = g.series(x==0,1).truncate()
return h(1/x)
It works, for instance, with $(x^2-3x+5)^{1/2}$ and $(x^3-5x^2+45x-713)^{1/3}$, but not (for example) with $(x^8-x^7+9x^6-7x^5+4x^4-x^3)^{1/2}$. I feel as though my method is kind of ad-hoc, and was hoping somebody could point me to a better way to do this. This is the error message it throws, for what it's worth:
poly_truncate((x^8-x^7+9*x^6-7*x^5+4*x^4-x^3)^(1/2))
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-6-d95c1391d7b5> in <module>()
----> 1 poly_truncate((x**Integer(8)-x**Integer(7)+Integer(9)*x**Integer(6)-Integer(7)*x**Integer(5)+Integer(4)*x**Integer(4)-x**Integer(3))**(Integer(1)/Integer(2)))
<string> in poly_truncate(f)
/Applications/SageMath-8.1.app/Contents/Resources/sage/src/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.__call__ (build/cythonized/sage/symbolic/expression.cpp:32775)()
5273 z^2 + x^y
5274 """
-> 5275 return self._parent._call_element_(self, *args, **kwds)
5276
5277 def variables(self):
/Applications/SageMath-8.1.app/Contents/Resources/sage/src/sage/symbolic/ring.pyx in sage.symbolic.ring.SymbolicRing._call_element_ (build/cythonized/sage/symbolic/ring.cpp:11496)()
973 d[ vars[i] ] = arg
974 except IndexError:
--> 975 raise ValueError("the number of arguments must be less than or equal to %s"%len(vars))
976
977 return _the_element.subs(d, **kwds)
ValueError: the number of arguments must be less than or equal to 0
Additionally, is there a faster/more trustworthy built-in function or package which computes the rational/integer roots of polynomials in $\mathbb{Q}[x]$ (i.e. better than just f.roots())?canuckleheadFri, 11 May 2018 23:00:02 -0500https://ask.sagemath.org/question/42317/How do I code a Laurent Series with variable coefficients?https://ask.sagemath.org/question/39662/how-do-i-code-a-laurent-series-with-variable-coefficients/Edit: Adding more context.
I am attempting the following procedure:
1. Begin with a polynomial $Z(u)$ with variable coefficients, of the form $1 + a*u + b*u^2 + c*u^3 + p*b*u^4 + p^2*a*u^5 + p^3*u^6$.
2. Examine the coefficients of $Z'(u)/Z(u)$ as a power series in $u$.
It is this quest which leads me to attempt to construct a LaurentSeriesRing with variable coefficients. However, I keep encountering TypeErrors, I am wondering if a kind soul could help me in my quest. I will use here a very simple polynomial f to get the point across.
I am attempting to construct a LaurentSeriesRing with variable coefficients. However, I keep encountering TypeErrors, I am wondering if a kind soul could help me in my quest. I will use here a very simple polynomial f to get the point across.
sage: R.<t> = LaurentSeriesRing(QQ, 't')
sage: var('a')
a
sage: f = 1 + a*t
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-31-06d3f2f41e45> in <module>()
----> 1 f = Integer(1) + a*t
sage/structure/element.pyx in sage.structure.element.Element.__mul__ (/usr/lib/sagemath//src/build/cythonized/sage/structure/element.c:12443)()
sage/structure/coerce.pyx in sage.structure.coerce.CoercionModel_cache_maps.bin_op (/usr/lib/sagemath//src/build/cythonized/sage/structure/coerce.c:10496)()
TypeError: unsupported operand parent(s) for '*': 'Symbolic Ring' and 'Laurent Series Ring in t over Rational Field'
I also tried:
sage: R.<u> = QQ[]
sage: var('a')
a
sage: f = 1 + a*u
sage: ff = derivative(f, u)
sage: R.<u> = LaurentSeriesRing(QQ); R
sage: f/ff + O(u^5)
----------------------
TypeError Traceback (most recent call last)
<ipython-input-28-c4846de7ced8> in <module>()
----> 1 f/ff + O(u**Integer(5))
sage/structure/element.pyx in sage.structure.element.Element.__add__ (/usr/lib/sagemath//src/build/cythonized/sage/structure/element.c:11198)()
sage/structure/coerce.pyx in sage.structure.coerce.CoercionModel_cache_maps.bin_op (/usr/lib/sagemath//src/build/cythonized/sage/structure/coerce.c:10496)()
TypeError: unsupported operand parent(s) for '+': 'Symbolic Ring' and 'Laurent Series Ring in u over Rational Field'masseygirlSun, 19 Nov 2017 13:35:21 -0600https://ask.sagemath.org/question/39662/How can I take a fractional power and a power series inverse?https://ask.sagemath.org/question/39734/how-can-i-take-a-fractional-power-and-a-power-series-inverse/I am attempting to take the power series inverse of the Taylor series expansion of $(x^4-x)^{1/3}$ around the point 0.
When I attempt to define g=(x^4-x)^{1/3} :
sage: R.<x> = LaurentPolynomialRing(QQ);
sage: g = (x^4-x)^{1/3}
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-21-675538f6f472> in <module>()
----> 1 g = (x**Integer(4)-x)**{Integer(1)/Integer(3)}
sage/rings/polynomial/laurent_polynomial.pyx in sage.rings.polynomial.laurent_polynomial.LaurentPolynomial_univariate.__pow__ (/usr/lib/sagemath//src/build/cythonized/sage/rings/polynomial/laurent_polynomial.c:10802)()
TypeError: int() argument must be a string or a number, not 'set'
Now, when I define $g$ as follows, I am unable to take the power series inverse:
sage: var('x')
x
sage: g = (1-x)**(1/3)
sage: G = g.taylor(x, 0, 10)
sage: 1/G
-4782969/(55913*x^10 + 64515*x^9 + 75735*x^8 + 90882*x^7 + 112266*x^6 + 144342*x^5 + 196830*x^4 + 295245*x^3 + 531441*x^2 + 1594323*x - 4782969)
sage: 1/G + O(x^10)
---------------------------------------------------------------------------
ArithmeticError Traceback (most recent call last)
<ipython-input-12-9fe94787aacb> in <module>()
----> 1 Integer(1)/G + O(x**Integer(10))
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/rings/big_oh.py in O(*x, **kwds)
154 elif hasattr(x, 'O'):
155 return x.O(**kwds)
--> 156 raise ArithmeticError("O(%s) not defined" % (x,))
ArithmeticError: O(x^10) not defined
sage: G.inverse()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-14-34018a4209b6> in <module>()
How can I have the best of both worlds? In the end, I would like to have an element in the Laurent Series Ring, for the next stage is to take the formal integral of the result, and the composition inverse of this formal integral.masseygirlWed, 22 Nov 2017 14:36:44 -0600https://ask.sagemath.org/question/39734/laurent series ring induced homomorphismhttps://ask.sagemath.org/question/39123/laurent-series-ring-induced-homomorphism/ Can you not lift homomorphism of the base ring to the homomorphism of Laurent series ring in sage? (not manually)AntWed, 11 Oct 2017 11:05:11 -0500https://ask.sagemath.org/question/39123/Coercion from symbolic ring to Laurent series ring?https://ask.sagemath.org/question/33806/coercion-from-symbolic-ring-to-laurent-series-ring/Is there a good way to convert from a symbolic expression to a Laurent series ring? For example, if x is a symbolic variable and LSR is a laurent series ring, then sage produces an error for
LSR(1/x)
saying that the element is not integral.jaicouruWed, 15 Jun 2016 16:12:44 -0500https://ask.sagemath.org/question/33806/integrating formal Laurent serieshttps://ask.sagemath.org/question/10546/integrating-formal-laurent-series/I would like to compute some integrals of products of Laurent series, with the goal of getting an explicit expression for the n-th coefficient of the result. It gets pretty messy so I was hoping that sage could keep track of the details for me. Here are the things I don't know how to do:
1) Define a Laurent series by giving an expression for its n-th coefficient.
2) Formally multiply and integrate Laurent series, producing an explicit expression for the n-th coefficient of the result.
Is this possible? I apologize if some or all of this is explained elsewhere.
EDIT: An example of what I want to do would be to define a power series such as sum(n * x^n,n,0,infinity) and then integrate it and/or multiply it by another power series, resulting in yet another power series whose coefficients I can read off. The O(x^n) notation is not very useful to me since I would like to have an expression for an arbitrary coefficient of that resulting series in terms of n.anilbvWed, 18 Sep 2013 12:39:16 -0500https://ask.sagemath.org/question/10546/Laurent series, Rational Functions in sqrt(q)?https://ask.sagemath.org/question/9869/laurent-series-rational-functions-in-sqrtq/I need to construct the ring of formal Laurent series in `q**(1/2)` over the rational numbers. How would I do that in sage?
I realize that there's a perfectly good workaround, but I'd be nonetheless very happy if I didn't have to use it. I could just use Laurent series in another variable, like t,
R.<t> = LaurentSeriesRing(QQ)
I could then define q to be `t**2`, and use t as a formal square root of q. But then I still can't raise q to a non-integer power - sage complains that there's a non-integer in the exponent. I'd make about 500 mistakes just typing in formulas and it would be hard to read the output.
Another workaround which I'm not keen on is to just say
var('q')
and just use symbolic expressions instead. I don't really want to do that either: I like having all the Laurent series methods available and I gather that working in an explicit ring is a lot faster? If I'm misinformed there, then please let me know.
Lastly, I'd also like to construct the rational functions in sqrt(q) - same basic problem, as far as I can see. Any help appreciated.
Benjamin YoungSat, 02 Mar 2013 06:26:10 -0600https://ask.sagemath.org/question/9869/simplify coefficients of laurent series?https://ask.sagemath.org/question/9828/simplify-coefficients-of-laurent-series/I am working with a Laurent series f. My goal is to calculate the principal part of f^3. The code I am using is this:
R.<u> = LaurentSeriesRing(SR, 'u'); R
b2, b1, a0, a1, a2, a3, a4 = var('b2 b1 a0 a1 a2 a3 a4')
f = b2*u^-2 + b1*u^-1 + a0 + a1*u + a2*u^2 + a3*u^3 + a4*u^4 + O(u^5)
f^3
The answer I get is:
b2^3*u^-6 + 3*b1*b2^2*u^-5 + (a0*b2^2 + 2*b1^2*b2 + (2*a0*b2 + b1^2)*b2)*u^-4 + (2*a0*b1*b2 + a1*b2^2 + (2*a0*b2 + b1^2)*b1 + 2*(a0*b1 + a1*b2)*b2)*u^-3 + (2*a1*b1*b2 + a2*b2^2 + (2*a0*b2 + b1^2)*a0 + 2*(a0*b1 + a1*b2)*b1 + (a0^2 + 2*a1*b1 + 2*a2*b2)*b2)*u^-2 + (2*a2*b1*b2 + a3*b2^2 + (2*a0*b2 + b1^2)*a1 + 2*(a0*b1 + a1*b2)*a0 + 2*(a0*a1 + a2*b1 + a3*b2)*b2 + (a0^2 + 2*a1*b1 + 2*a2*b2)*b1)*u^-1 + (2*a3*b1*b2 + a4*b2^2 + (2*a0*b2 + b1^2)*a2 + 2*(a0*b1 + a1*b2)*a1 + 2*(a0*a1 + a2*b1 + a3*b2)*b1 + (a0^2 + 2*a1*b1 + 2*a2*b2)*a0 + (2*a0*a2 + a1^2 + 2*a3*b1 + 2*a4*b2)*b2) + O(u)
SAGE does not simplify the coefficients of the result. Is there some command that I can enter that will allow me to simultaneously simplify the coefficients of each power of u and output the result up to O(u)? The simplify command does not seem to work.
sdkwokThu, 21 Feb 2013 03:55:37 -0600https://ask.sagemath.org/question/9828/