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.Mon, 19 Oct 2020 17:04:35 -0500Why does plot choke on x to the 1/3 power, when it will calculate it just fine?https://ask.sagemath.org/question/53976/why-does-plot-choke-on-x-to-the-13-power-when-it-will-calculate-it-just-fine/plot(x^(1/3),-10,10) fails for negative numbers:
'can't convert complex to float'
OTOH, sage will calculate a negative to the 1/3 just fine.
-10^(1/3).n()
-2.15443469003188
cybervigilanteMon, 19 Oct 2020 17:04:35 -0500https://ask.sagemath.org/question/53976/A problem in powerserieshttps://ask.sagemath.org/question/45792/a-problem-in-powerseries/It seems there is a problem when expanding tan(t), sinh(t), cosh(t) using PowerSeries. The following works fine
R.<t> = PowerSeriesRing(QQ)
sin(t)/cos(t)
t + 1/3*t^3 + 2/15*t^5 + 17/315*t^7 + 62/2835*t^9 + 1382/155925*t^11 + 21844/6081075*t^13 + 929569/638512875*t^15 + 6404582/10854718875*t^17 + 443861162/1856156927625*t^19 + O(t^20)
However, `tan(t)` returns
TypeError: cannot coerce arguments: no canonical coercion from Power Series Ring in t over Rational Field to Symbolic RingirizosSat, 16 Mar 2019 10:41:49 -0500https://ask.sagemath.org/question/45792/n-th power of matriceshttps://ask.sagemath.org/question/35155/n-th-power-of-matrices/Is there any way to calculate the n-th power of a (upper unitriangular) matrix in Sage? Here n is an integer variable.
For example, if y=matrix([[1,0,0],[0,1,1],[0,0,1]]), then I want to obtain a formula in n for y^n. In this case this would be y^n=matrix([[1,0,0],[0,1,n],[0,0,1]]).
I tried the following:
sage: y=matrix([[1,0,0],[0,1,1],[0,0,1]]); var('n');
sage: y^n
This resulted in the error: "NotImplementedError: non-integral exponents not supported"
Adding
sage: assume(n, 'integer')
has no effect at all.irisSun, 16 Oct 2016 03:56:39 -0500https://ask.sagemath.org/question/35155/Limit of a matrix powerhttps://ask.sagemath.org/question/40248/limit-of-a-matrix-power/Hello!
I'm new in Sagemath and I want to calculate the limit of the power of a given 3x3 diagonal matrix:
J=matrix([[1,0,0],[0,-1/2-1/2*I,0],[0,0,-1/2+1/2*I]]); #Given diagonal matrix
n=var('n');
limit(J^n,n=infinity) #The limit command fails =(
Is there any way to do this?
Trank you so much!dg.aragonesWed, 20 Dec 2017 02:17:31 -0600https://ask.sagemath.org/question/40248/Export to C codehttps://ask.sagemath.org/question/7922/export-to-c-code/Is it possible to export the result of a calculation to C source code? To be more specific, I have a very long equation emerging from a Sage calculation which I need to feed into a C simulation program, but C doesn't understand the x^2, x^3, ... syntax. I ended up using the re module to manually replace the terms with the proper pow function calls, but I thought maybe there is a more elegant solution to this.
hennesMon, 07 Feb 2011 01:26:21 -0600https://ask.sagemath.org/question/7922/Finite field q power computationshttps://ask.sagemath.org/question/32907/finite-field-q-power-computations/ Hey there, i'm trying to make a fast computation algorithm using shift operations. I'm having a field GF(q) and a field GF(q^m) for some integer m and i have an element x \in GF(q^m). I want to represent x in a normal basis of the vectorspace GF(q^m) over GF(q), so that I can use shift operations for computing x^q^k fast. Are there any way of doing this ?BelphegorTue, 29 Mar 2016 07:19:40 -0500https://ask.sagemath.org/question/32907/Numeric evaluation of exp(x^2) in a sum TypeErrorhttps://ask.sagemath.org/question/10946/numeric-evaluation-of-expx2-in-a-sum-typeerror/Define simple function of one variable with sum:
sage: r, i = var('r i')
sage: h(r) = sum(exp(i), i, -r, r)
sage: n(h(1))
4.08616126963049
OK, now change the argument of exponent to i^2:
sage: h(r) = sum(exp(i^2), i, -r, r)
sage: n(h(1))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-128-85150c4c79b2> in <module>()
----> 1 n(h(Integer(1)))
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/misc/functional.pyc in numerical_approx(x, prec, digits)
1395 prec = int((digits+1) * LOG_TEN_TWO_PLUS_EPSILON) + 1
1396 try:
-> 1397 return x._numerical_approx(prec)
1398 except AttributeError:
1399 from sage.rings.complex_double import is_ComplexDoubleElement
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression._numerical_approx (sage/symbolic/expression.cpp:22617)()
TypeError: cannot evaluate symbolic expression numerically
Why is that and what am I doing wrong?sage_userSat, 18 Jan 2014 23:29:40 -0600https://ask.sagemath.org/question/10946/How to simplify x^a/x into x^(a-1) OR how to solve...?https://ask.sagemath.org/question/10197/how-to-simplify-xax-into-xa-1-or-how-to-solve/Can any body show me which function simplifies x^a/x into x^(a-1)?
A related question is how to solve x^a == 2*x to have x = 2^(1/(a-1))?
Mathematica works out these questions well, but I'm a huge fan of Sage/Maxima, and eager to get an answer using Sage. Thanks!QiangWed, 17 Jul 2013 04:05:49 -0500https://ask.sagemath.org/question/10197/"Sage for power users" by W. Stein (PDF without error?)https://ask.sagemath.org/question/10333/sage-for-power-users-by-w-stein-pdf-without-error/I think that the PDF written by William Steing and named "Sage for power users" is a really good documentation.
http://modular.math.washington.edu/books/sagebook/sagebook.pdf
However the are some pages that are not well compiled. Is there a fixed version?
I couldn't find it. Thx!fjnb86Tue, 09 Jul 2013 03:52:52 -0500https://ask.sagemath.org/question/10333/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/Plotting an Infinite Power Towerhttps://ask.sagemath.org/question/9188/plotting-an-infinite-power-tower/How would one go about expressing/plotting the infinite "power tower" function f(x)=x^(x^(x^...))? I am not finding much information with search/google. Thank you.NickSun, 02 Sep 2012 20:02:32 -0500https://ask.sagemath.org/question/9188/Power of a polynomial mod (n, X^r - 1)https://ask.sagemath.org/question/8742/power-of-a-polynomial-mod-n-xr-1/I need to calculate (X + a)^n mod (n, X^r - 1), where n can be very large.
I use the following code:
R.<x>=PolynomialRing(Integers(n))
pow(x + a, n, X^r - 1)
A better (i.e. faster) solution?
Thanks.mcl1962Mon, 27 Feb 2012 00:39:15 -0600https://ask.sagemath.org/question/8742/Round trip through Mathematica's FullSimplifyhttps://ask.sagemath.org/question/7845/round-trip-through-mathematicas-fullsimplify/The following command returns 1:
<code>
mathematica(-2/(1 + sqrt(3)*I)).FullSimplify().sage()
</code>
The issue is that Mathematica simplifies this expression to (-1)/(2/3), which it considers to be defined in terms of the primitive root. Sage on the other hand converts (-1)/(2/3) to 1, with the idea that any root will do. My question: is it a bug that putting this equation into Mathematica and bringing it back to Sage changes it from a complex number to a real number?
dstahlkeThu, 06 Jan 2011 16:54:26 -0600https://ask.sagemath.org/question/7845/fractional power to negative numberhttps://ask.sagemath.org/question/7820/fractional-power-to-negative-number/bool( (-2)^(1/3) == - 2^(1/3) ) returns False
Is there any way in sage that will say they are same?
ShuThu, 16 Dec 2010 06:14:52 -0600https://ask.sagemath.org/question/7820/