ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 11 May 2018 23:00:02 -0500Multivariate Laurent serieshttp://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 -0500http://ask.sagemath.org/question/29669/Laurent Expansion at Infinity / Root findinghttp://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 -0500http://ask.sagemath.org/question/42317/How do I code a Laurent Series with variable coefficients?http://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 -0600http://ask.sagemath.org/question/39662/How can I take a fractional power and a power series inverse?http://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 -0600http://ask.sagemath.org/question/39734/