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.Wed, 20 Jun 2018 14:01:41 -0500RuntimeError: ECL says: THROW: The catch RAT-ERR is undefinedhttp://ask.sagemath.org/question/42686/runtimeerror-ecl-says-throw-the-catch-rat-err-is-undefined/Using `8.3.beta6` on Linux Manjaro
Is this a known issue? Problem with integrate.
sage: var('x')
sage: integrate((cos(x) + 2*sin(x) + 1)/(cos(x)^2 - 2*cos(x)*sin(x) + 2*sin(x) + 3),x)
gives
RuntimeError Traceback (most recent call last)
<ipython-input-2-f1dceacbaccd> in <module>()
----> 1 integrate((cos(x) + Integer(2)*sin(x) + Integer(1))/(cos(x)**Integer(2) - Integer(2)*cos(x)*sin(x) + Integer(2)*sin(x) + Integer(3)),x)
.......
RuntimeError: ECL says: THROW: The catch RAT-ERR is undefined.
This one also
integrate(log(x + sqrt(x + 1))/(x^2 + 1),x)
gives
RuntimeError Traceback (most recent call last)
<ipython-input-70-f29d0d9e0a0b> in <module>()
----> 1 anti=integrate(log(x + sqrt(x + Integer(1)))/(x**Integer(2) + Integer(1)),x)
......NasserWed, 20 Jun 2018 07:09:30 -0500http://ask.sagemath.org/question/42686/translation errors from fricas to sagehttp://ask.sagemath.org/question/42685/translation-errors-from-fricas-to-sage/Sorry that I do not know if these are known issues or not. Thought to report them. If there are known, feel free to close this.
Using Sage `version 8.3.beta6`
This one seems to be that there is no translation from fricas to sage. Is this due to the `atan` ?
sage: var('x a')
sage: integrate(1/(1+a*cos(x)),x,algorithm="fricas")
NotImplementedError: The translation of the FriCAS Expression "atan(((cos(x)+a)*((-1)*a^2+1)^(1/2))/((a^2+(-1))*sin(x)))/(((-1)*a^2+1)^(1/2)) to sage is not yet implemented.
And this one
sage: var('x a b')
sage: anti=integrate(1/(b*x^2+a),x,algorithm="fricas")
NotImplementedError: The translation of the FriCAS Expression "log(((b*x^2+(-1)*a)*((-1)*a*b)^(1/2)+2*a*b*x)/(b*x^2+a))/(2*((-1)*a*b)^(1/2)) to sage is not yet implemented.NasserWed, 20 Jun 2018 05:54:12 -0500http://ask.sagemath.org/question/42685/how to correctly check that integration evaluated?http://ask.sagemath.org/question/42690/how-to-correctly-check-that-integration-evaluated/What is the correct way in sage to check that the result of integration has evaluated? I.e. the result has no unevaluated `integrate` remaining in it?
The way I am checking fail in some cases. For example
sage: var('x')
sage: anti=integrate((4*x - sqrt(-x^2 + 1))/(sqrt(-x^2 + 1) + 5), x)
sage: anti
-x - 4*sqrt(-x^2 + 1) + 5*integrate(1/(sqrt(x + 1)*sqrt(-x + 1) + 5), x) + 20*log(sqrt(-x^2 + 1) + 5)
The above did not fully evaluate, since there is an `integrate` inside the result returned. But when I do
sage: isinstance(anti.operator(), sage.symbolic.integration.integral.IndefiniteIntegral)
False
I was expecting to get `True`. It failed the check, because `integrate` was not the first operator. This one works
sage: anti=integrate(1/(sqrt(x + 1)*sqrt(-x + 1) + 5), x)
sage: isinstance(anti.operator(), sage.symbolic.integration.integral.IndefiniteIntegral)
True
So what is the correct way to tell sage to scan the whole expression and if there is an instance of `integrate` any where, to return `True`
Thank you
--Nasser
NasserWed, 20 Jun 2018 10:23:42 -0500http://ask.sagemath.org/question/42690/How to substitute values for derivatives?http://ask.sagemath.org/question/42698/how-to-substitute-values-for-derivatives/ I would like to first differentiate a function, then substitute values for derivatives within the function.
For example, a function might be `cos(theta)*sin(phi)`. I would like to differentiate with respect to another variable (time in this case):
sage: t = var('t')
sage: theta = function('theta')(t)
sage: phi = function('phi')(t)
sage: A = cos(theta)*sin(phi)
sage: C = diff(A,t,t)
sage: C
-cos(theta(t))*sin(phi(t))*diff(phi(t), t)^2 - 2*cos(phi(t))*sin(theta(t))*diff(phi(t), t)*diff(theta(t), t) - cos(theta(t))*sin(phi(t))*diff(theta(t), t)^2 + cos(phi(t))*cos(theta(t))*diff(phi(t), t, t) - sin(phi(t))*sin(theta(t))*diff(theta(t), t, t)
sage: C.subs(theta=5,phi=6,diff(theta(t),t)=7,diff(phi(t),t)=8,diff(theta(t),t,t)=9,diff(phi(t),t,t)=10)
File "<ipython-input-147-f1b68bf72320>", line 1
C.subs(theta=Integer(5),phi=Integer(6),diff(theta(t),t)=Integer(7),diff(phi(t),t)=Integer(8),diff(theta(t),t,t)=Integer(9),diff(phi(t),t,t)=Integer(10))
SyntaxError: keyword can't be an expression
I believe the error comes from trying to define the entire function theta(t), diff(phi(t),t,t), etc. as a single number. It should work just as well to substitute other variables in the place of the derivatives; I only want the derivatives there for getting the initial equations. Is there a way to either:
1. Define each derivative to be a specific value and evaluate the expression, or
2. Substitute variables for derivatives, which can in turn be substituted with values and the expression evaluated?bob323Wed, 20 Jun 2018 14:01:41 -0500http://ask.sagemath.org/question/42698/How to convert string to sage expression?http://ask.sagemath.org/question/42692/how-to-convert-string-to-sage-expression/In python one can use `parse_expr` to convert a string which contains valid sympy expression to an sympy expression.
I can't find how to do the same in sage. I tried `eval` but this works sometimes and not other times. Here is an example
var('x')
sage: expr=sin(x)
sage: expr=str(expr)
sage: expr=eval(expr)
sin(x)
But not on this one
sage: expr=-1/2*x/(x^2 + 1)
sage: expr=str(expr)
sage: expr=eval(expr)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-16-599d1fa18625> in <module>()
----> 1 expr=eval(expr)
<string> in <module>()
/usr/lib/python2.7/site-packages/sage/structure/element.pyx in sage.structure.element.Element.__xor__ (build/cythonized/sage/structure/element.c:8986)()
951
952 def __xor__(self, right):
--> 953 raise RuntimeError("Use ** for exponentiation, not '^', which means xor\n"+\
954 "in Python, and has the wrong precedence.")
955
RuntimeError: Use ** for exponentiation, not '^', which means xor
in Python, and has the wrong precedence.
I do not know before hand the "type" of the expression, other than it is valid sage expression, but in a string.
I found I could do this
sage: var('x')
sage: expr=-1/2*x/(x^2 + 1)
sage: expr=str(expr)
sage: expr=sage_eval(expr,locals={'x':x})
sage: expr
-1/2*x/(x^2 + 1)
and it works. But this means I need to know before hand that 'x' symbol was there. Which is not possible for me.
I am looking for something similar to Mathematica's `ToExpression` described in
http://reference.wolfram.com/language/ref/ToExpression.html or python `parse_expr`
I found answer here https://ask.sagemath.org/question/41135/converting-strings-into-expressions/ using something called `SR` which I still do not understand, but it does not work for me.
sage: expr=integrate(x^2*(sqrt(x^2 + 1) - 2)/((x^3 - (x^2 + 1)^(3/2) - 1)*sqrt(x^2 + 1)), x)
sage: expr=str(expr)
sage: expr=SR(expr)
TypeError Traceback (most recent call last)
So, how would one convert string that contains arbitrary sage valid expression to sage expression?NasserWed, 20 Jun 2018 11:15:49 -0500http://ask.sagemath.org/question/42692/Is it possible to default to real field?http://ask.sagemath.org/question/42675/is-it-possible-to-default-to-real-field/It appears that Sage defaults symbolic variables to the complex field. This is passed along to Maxima, eventually triggering segfaults. Given that all of my variables are real, is it possible to default the symbolic domain to the real field BEFORE asking any calculations of Maxima?
[Related to my thread on the Development mailing list.]Richard_LTue, 19 Jun 2018 16:04:55 -0500http://ask.sagemath.org/question/42675/computational timehttp://ask.sagemath.org/question/42680/computational-time/ i am using two platforms to run the code. one is sagemath cloud and second is sagemath terminal. the computational time obtained in both the platform is different. the results obtained are better in sagemath terminal. i am writing paper so please suggest me which result i have to consider for my research paper.santoshiWed, 20 Jun 2018 03:24:53 -0500http://ask.sagemath.org/question/42680/Exception in sage-fricas interfacehttp://ask.sagemath.org/question/42683/exception-in-sage-fricas-interface/ I get an error in this specific integral. Here is how to reproduce it. I call fricas from sage to do an integral. Convert the result back to sage syntax. Then use
isinstance(anti.operator(), sage.symbolic.integration.integral.IndefiniteIntegral)
As a way to check if the result has no unevaluated integral in it anywhere, so I would know it actually evaluated and not echoed back.
This works OK for everything I tried so far. It works on all the tests I did on Maxima. Except on this one I found so far using Fricas
sage: fricas.setSimplifyDenomsFlag(fricas.true)
sage: var('x')
sage: theIntegral = fricas(x*(x^2-1)^9)
sage: anti = theIntegral.integrate(x)
sage: anti = anti.sage()
sage: anti
1/20*x^20 - 1/2*x^18 + 9/4*x^16 - 6*x^14 + 21/2*x^12 - 63/5*x^10 + 21/2*x^8 - 6*x^6 + 9/4*x^4 - 1/2*x^2
sage: isinstance(anti.operator(), sage.symbolic.integration.integral.IndefiniteIntegral)
and now
AttributeError Traceback (most recent call last)
<ipython-input-16-ebdd05a45434> in <module>()
----> 1 isinstance(anti.operator(), sage.symbolic.integration.integral.IndefiniteIntegral)
/usr/lib/python2.7/site-packages/sage/structure/element.pyx in sage.structure.element.Element.__getattr__ (build/cythonized/sage/structure/element.c:4531)()
491 AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'
492 """
--> 493 return self.getattr_from_category(name)
494
495 cdef getattr_from_category(self, name):
/usr/lib/python2.7/site-packages/sage/structure/element.pyx in sage.structure.element.Element.getattr_from_category (build/cythonized/sage/structure/element.c:4640)()
504 else:
505 cls = P._abstract_element_class
--> 506 return getattr_from_other_class(self, cls, name)
507
508 def __dir__(self):
/usr/lib/python2.7/site-packages/sage/cpython/getattr.pyx in sage.cpython.getattr.getattr_from_other_class (build/cythonized/sage/cpython/getattr.c:2536)()
392 dummy_error_message.cls = type(self)
393 dummy_error_message.name = name
--> 394 raise AttributeError(dummy_error_message)
395 attribute = <object>attr
396 # Check for a descriptor (__get__ in Python)
AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'operator'
The above works OK on other integrals. For example
sage: theIntegral = fricas(x*(x^2+1)^(1/2))
sage: anti = theIntegral.integrate(x)
sage: anti = anti.sage()
sage: anti
1/3*(x^2 + 1)^(3/2)
sage: isinstance(anti.operator(), sage.symbolic.integration.integral.IndefiniteIntegral)
False
sage:
No error.
I am using sage: `SageMath version 8.3.beta6, Release Date: 2018-06-17` and
>fricas
Checking for foreign routines
AXIOM="/usr/lib/fricas/target/x86_64-linux-gnu"
spad-lib="/usr/lib/fricas/target/x86_64-linux-gnu/lib/libspad.so"
foreign routines found
openServer result 0
FriCAS Computer Algebra System
Version: FriCAS 1.3.3
Timestamp: Tue Jun 19 19:53:54 CDT 2018
Any idea why this error shows up on this integral? Is it possible to fix it?
Thank you
--Nasser
NasserWed, 20 Jun 2018 05:06:00 -0500http://ask.sagemath.org/question/42683/Segmentation fault (core dumped) SageMath version 8.2http://ask.sagemath.org/question/42664/segmentation-fault-core-dumped-sagemath-version-82/Sage still core dumps. I thought earlier it was fixed, but it is not.
/usr/bin/sage-python: line 2: 2794 Segmentation fault (core dumped) sage -python "$@"
**Short summary of the problem**: When I run a sage script which iterates over large list of integrals, then call maxima, it segfault, but only when the list is long. (trial and error shows when it is over 45 entries)
When I change the algorithm from "maxima" to "fricas", the script runs and it works. NO OTHER CHNAGES.
When the list is short, using maxima no longer causes a segfault. So it seems like a memory corruption for me.
Why when the list is short it works, but when adding one more entry to the list, it segfault? And only when using maxima?
The script uses Python multiprocessing.
The script is long, but only because the list is long. So I was not sure if I should post it here. (I could if needed) but I put a link to it here. Please see https://www.12000.org/tmp/sage_segfault/test_maxima.sage
To run, simply download to any folder and type `./test_maxima.sage`
It will segfault. I tried it on **sage 8.2**, **sage 8.1**, **sage 8.3 beta 6**. On latest **Manjora linux 17.1** and also on **Linux mint 19** and tried it on standalone PC running Linux and inside Virtual box running Linux.
Could someone please try this script to see if they get the segfault? Otherwise, I could not test maxima for integration and will have just leave it out. I do not know where the dump file is written to. Does any one know? I do not see it in same folder I am running the script from.NasserTue, 19 Jun 2018 08:20:18 -0500http://ask.sagemath.org/question/42664/Problem in Relative Homology Computation ?http://ask.sagemath.org/question/42676/problem-in-relative-homology-computation/ I am trying to understand how to compute relative homologies between cubical complexes and a given subcomplex. Consider the cubical complex of the elementary cube [0,1]x[0,1],defined via:
Square = CubicalComplex([([0,1],[0,1])])
I further refer to the edges ofthe complex as:
First Edge: [0,0] x [0,1]
Second Edge: [0,1] x [1,1]
Third Edge: [1,1] x [0,1]
Fourth Edge: [0,1] x [0,0]
Imagine labeling the edges of a square in a clockwise fashion, with the vertical leftmost one being the first edge.
When i try to compute the relative homology of Square in relation to the subcomplex generated by the First, Second and Third edges, i do:
FirstandSecondandThirdEdges = CubicalComplex([([0,0],[0,1]),([0,1],[1,1]),([1,1],[0,1])])
Then, the calculation of the homology
Square.homology(subcomplex=FirstandSecondandThirdEdges,reduced=False)
and the result is: {0: 0, 1: Z, 2: Z} (which I suspect is wrong).
In order to calculate the homology in relation to the subcomplex generated by the First ,Third and Fourth edges, i first define:
FirstandThirdandFourthEdges = CubicalComplex([([0,0],[0,1]),([0,1],[0,0]),([1,1],[0,1])])
To calculate the relative homology:
Square.homology(subcomplex=FirstandThirdandFourthEdges,reduced=False)
And the result is: {0: 0, 1: 0, 2: 0}.
I am not experienced with homology calculations, but I believe the two results should be the same, since the latter configuration is just a rotation of the first one by 180 degrees.I also believe that the right result should given by {0: 0, 1: 0, 2: 0} in both cases, which is the same as considering the relative homology of Square and a single arbitrary edge. Are these calculations correct ? Is my intuition wrong about these two relative homologies groups?
If anyone could point out some mistake, I would very much appreciate :)D7-BraneTue, 19 Jun 2018 18:22:06 -0500http://ask.sagemath.org/question/42676/Using SageMath in IDLEhttp://ask.sagemath.org/question/42652/using-sagemath-in-idle/I am trying to use IDLE with Python 2.7.15 and use functions from Sage 8.2 on a Windows 10 machine. I know that I have to have Python 2.x (which I do). My script is the following:
#! C:\Program Files\SageMath 8.2\runtime\bin\env sage -python
from sage.all import *
Suits = Set(["Hearts", "Diamonds", "Spades", "Clubs"])
Values = Set([2, 3, 4, 5, 6, 7, 8, 9, 10, "Jack", "Queen", "King", "Ace"])
Cards = cartesian_product([Values, Suits])
print(Cards.cardinality)
(from the combinat package/documentation and question/8215/using-sage-in-a-python-cgi-script/ which I can't post a direct link to because this is my first question). Then when I try to run it in IDLE I get
Traceback (most recent call last):
File "C:/Users/ME/Documents/Math/Programming/Playing/playing_1.py", line 3, in <module>
from sage.all import *
ImportError: No module named sage.all
For what its worth, I get the same error when trying to import numpy, sklearn, and pandas. I have Anaconda downloaded but I am using Python 3 in that so I presume that is where that issue is coming from. If I am wrong I'd love to know!
EDIT:
I realize I did not ask a question. My question is, can anyone help me get this to work? Thank you!trevor_kMon, 18 Jun 2018 15:45:03 -0500http://ask.sagemath.org/question/42652/Possible bug with identity morphismhttp://ask.sagemath.org/question/42625/possible-bug-with-identity-morphism/I have a number field `U` for which I consider its automorphisms through `Hom(U,U)`.
The identity `one=Hom(U,U).identity()` behaves weirdly under right multiplication:
U = CyclotomicField(3)
f = Hom(U,U)[1]
print f
print "--------------------"
one = Hom(U,U).identity()
print f*one
print "--------------------"
print one*f
print "--------------------"
print f*f
When I run this code, I expect `f` to be printed thrice, followed by the identity morphism.
However, while the first and third output do in fact both print `f`, the second prints
Composite map:
From: Cyclotomic Field of order 3 and degree 2
To: Cyclotomic Field of order 3 and degree 2
Defn: Identity endomorphism of Cyclotomic Field of order 3 and degree 2
then
Ring endomorphism of Cyclotomic Field of order 3 and degree 2
Defn: zeta3 |--> -zeta3 - 1
Is this a bug or is this this behaviour explained somewhere in the documentation?
MadPidgeonSun, 17 Jun 2018 05:47:03 -0500http://ask.sagemath.org/question/42625/PARI/GP error in wrapping custom-defined PARI functions in Sage using the command gp.set()http://ask.sagemath.org/question/42638/parigp-error-in-wrapping-custom-defined-pari-functions-in-sage-using-the-command-gpset/ I have a library in PARI/GP and since Sage also supports the GP calculator I have been trying to shift my library using gp.set() and gp.get() commands. So far all functions are working but I got a PARI/GP error while implementing this function in Sage using gp.set(). Here is the code of that function:
compareSides(printedgesonscreen=0) =
{
local( edge, edgesCheckList1:list, edgesCheckList2:list, cancelCriterion);
edgesCheckList1 = listcreate(2*numberOfLines);
edgesCheckList2 = listcreate(2*numberOfLines);
for (j = 1, numberOfSpheres,
if( deleteFlag[j] == 0,
if( printedgesonscreen == 1,
print("Cell ",j," lies on the hemisphere with center at ",
divideInNumberField(K,Lambda[j],Mu[j]) );
print(" with radius square ", radiusSquare[j],
" and has the following edges:");
);
for( s = 1, length( pointsOfLine[j]),
edge = setintersect(Set(pointsOfLine[j][s]),
Set(pointsOfSphere[j]:list));
if(length(edge) == 2,
if(printedgesonscreen == 1, print(edge); );
if( setsearch(Set(edgesCheckList1),edge),
if(setsearch(Set(edgesCheckList2),edge),
if (printedgesonscreen == 1,
print("***Error in function compareSides: triple edge in cell diagram");
);
,
listput(edgesCheckList2,edge);
);
, /* else not yet entered in edgesCheckList1 */
listput(edgesCheckList1,edge);
);
);
if(length(edge) > 2,
print("***Error in function compareSides: edge with three corners");
);
);
);
);
if(Set(edgesCheckList1) == Set(edgesCheckList2),
print("All ", length(edgesCheckList1), " = ",
length(edgesCheckList2)," edges appear twice.");
if( length(edgesCheckList1) > 3,
cancelCriterion = 1
,
cancelCriterion = 0
);
, /* else some edges do not appear twice. */
print("Some edges do not appear twice:");
print(setminus(Set(edgesCheckList1),Set(edgesCheckList2)));
);
listkill(edgesCheckList1); listkill(edgesCheckList2);
/* Return */ cancelCriterion
};
I have run this function in the GP calculator of Sage using the gp.console() command and it works fine but I don't understand why it is not working using gp.set(). Here is the implementation I did:
gp.set('compareSides(printedgesonscreen=0)','{ local( edge, edgesCheckList1:list, edgesCheckList2:list, cancelCriterion); edgesCheckList1 = listcreate(2*numberOfLines); edgesCheckList2 = listcreate(2*numberOfLines); for (j = 1, numberOfSpheres, if( deleteFlag[j] == 0, if( printedgesonscreen == 1, print("Cell ",j," lies on the hemisphere with center at ", divideInNumberField(K,Lambda[j],Mu[j]) ); print(" with radius square ", radiusSquare[j], " and has the following edges:"); ); for( s = 1, length( pointsOfLine[j]), edge = setintersect(Set(pointsOfLine[j][s]), Set(pointsOfSphere[j]:list)); if(length(edge) == 2, if(printedgesonscreen == 1, print(edge); ); if( setsearch(Set(edgesCheckList1),edge), if(setsearch(Set(edgesCheckList2),edge), if (printedgesonscreen == 1, print("***Error in function compareSides: triple edge in cell diagram"); ); , listput(edgesCheckList2,edge); ); , /* else not yet entered in edgesCheckList1 */ listput(edgesCheckList1,edge); ); ); if(length(edge) > 2, print("***Error in function compareSides: edge with three corners"); ); ); ); ); if(Set(edgesCheckList1) == Set(edgesCheckList2), print("All ", length(edgesCheckList1), " = ", length(edgesCheckList2)," edges appear twice."); if( length(edgesCheckList1) > 3, cancelCriterion = 1; , cancelCriterion = 0; ); , /* else some edges do not appear twice. */ print("Some edges do not appear twice:"); print(setminus(Set(edgesCheckList1),Set(edgesCheckList2))); ); listkill(edgesCheckList1); listkill(edgesCheckList2); /* Return */ cancelCriterion}')
When I run this in Sage it shows a PARI/GP error and outputs the whole code. I have been trying to find the bug since the last 3 days. Please help me regarding this. Thank you.MathematicianMon, 18 Jun 2018 02:20:09 -0500http://ask.sagemath.org/question/42638/Imaginary part of a ratio of polynomialshttp://ask.sagemath.org/question/42609/imaginary-part-of-a-ratio-of-polynomials/When working with polynomial rings with complex coefficients, how to pass the assumption that the unknown variable belongs to the Reals set?
I am trying to recover and plot the imaginary part of the the ratio of polynomials *arg2*, but as sage assumes the independent variable is complex, it takes a long time and returns a huge answer. But I think the answer could be much simpler if it assumes that the independent variable belongs to the Reals set. The *assume()* function doesn't seems to work in this case.
*arg* has complex terms in the numerator and denominator. *arg2* has complex terms only on the numerator. So, it should be easy to obtain the imaginary part of *arg2*.
s = polygen(CC, "s")
omega = polygen(CC, "omega")
I = CC(I)
# assume(omega, "real") # this does not work
s21 = 0.894292331092066/(s^4 + 2.14081977623463*s^3 + 3.15237117897600*s^2 + 2.31898630138664*s + 0.902488008823108)
s21_omega = s21.subs(s=I*omega)
s21_omega_diff = s21_omega.derivative()
arg = 1/s21_omega*s21_omega_diff
num = arg.numerator()
den = arg.denominator()
den_conj = den.map_coefficients(lambda z: z.conjugate())
num2 = (num*den_conj).map_coefficients(lambda z: 0 if abs(z.real())<1e-10 and abs(z.imag())<1e-10 else z.imag()*I if abs(z.real())<1e-10 and abs(z.imag())>=1e-10 else z.real() if abs(z.real())>=1e-10 and abs(z.imag())<1e-10 else z)
den2 = (den*den_conj).map_coefficients(lambda z: 0 if abs(z.real())<1e-10 and abs(z.imag())<1e-10 else z.imag()*I if abs(z.real())<1e-10 and abs(z.imag())>=1e-10 else z.real() if abs(z.real())>=1e-10 and abs(z.imag())<1e-10 else z)
arg2 = num2/den2
print(arg2)
print(imag(arg2))
# plot(-imag(arg2), (-1.5, 1.5)).show()
Output:
(-3.19903509380033*omega^15 - 1.71213939841908*I*omega^14 + 9.63823791915898*omega^13 + 3.11426578979509*I*omega^12 - 15.8129908994689*omega^11 - 4.60245136409720*I*omega^10 + 13.7326241083798*omega^9 + 1.24770230131999*I*omega^8 - 9.58497293293397*omega^7 - 0.760732566992820*I*omega^6 + 4.72291963120453*omega^5 - 2.52135706735033*I*omega^4 - 2.44038907746050*omega^3 - 0.463630243025939*I*omega^2 + 0.203401406783201*omega - 1.36326886734867*I)/(0.799758773450081*omega^16 - 2.75378226261685*omega^14 + 5.27099696648963*omega^12 - 5.49304964335183*omega^10 + 4.79248646646703*omega^8 - 3.14861308746971*omega^6 + 2.44038907746050*omega^4 - 0.406802813566401*omega^2 + 0.530548112702672)
2.55845638284151*imag_part(omega)^31/(0.639614095710378*imag_part(omega)^32 + 10.2338255313661*imag_part(omega)^30*real_part(omega)^2 + 76.7536914852462*imag_part(omega)^28*real_part(omega)^4 + 358.183893597743*imag_part(omega)^26*real_part(omega)^6 + 1164.09765419317*imag_part(omega)^24*real_part(omega)^8 + 2793.83437005430*imag_part(omega)^22*real_part(omega)^10 + 5122.02967846394*imag_part(omega)^20*real_part(omega)^12 + 7317.18525490165*imag_part(omega)^18*real_part(omega)^14 + 8231.83341181278*imag_part(omega)^16*real_part(omega)^16 + 7317.18525493145*imag_part(omega)^14*real_part(omega)^18 + 5122.02967846394*imag_part(omega)^12*real_part(omega)^20 + 2793.83437005430*imag_part(omega)^10*real_part(omega)^22 + 1164.09765419317*imag_part(omega)^8*real_part(omega)^24 + 358.183893597743*imag_part(omega)^6*real_part(omega)^26 + ... (huge answer)
Thank you!joaoffFri, 15 Jun 2018 09:23:09 -0500http://ask.sagemath.org/question/42609/Quotient ring involving Laurent polynomialshttp://ask.sagemath.org/question/42650/quotient-ring-involving-laurent-polynomials/Hi all,
I have actually two closely related questions:
Q1
Below is a working code that involves no Laurent polynomials:
sage: P = PolynomialRing(ZZ,'t0,t1')
sage: A.<T0,T1> = QuotientRing(P,[t0^2-1, t1^2-1])
sage: T0^2
sage: T1^2
The output is
1
1
I want to make a q-analog of it so it will produce its (Q,q)-deformation:
(Q-1)*T0 + Q
(q-1)*T1 + q
My attempt below didn't compile, and I'm wondering if there's a good solution to it.
sage: R = LaurentPolynomialRing(ZZ,'Q,q')
sage: P = PolynomialRing(R,'t0,t1')
sage: A.<T0,T1> = QuotientRing(P,[t0^2-1, t1^2-1])
sage: T0^2
sage: T1^2
Q2
I'm trying to implement the most general Hecke algebra of type B2 with unequal parameters for the two nodes. This is labeled as a TODO in the Sage Reference Manual (cannot post direct link due too low karma):
doc.sagemath.org/html/en/reference/algebras/sage/algebras/iwahori_hecke_algebra.html
Does anyone know any update to this?CJLaiMon, 18 Jun 2018 14:35:35 -0500http://ask.sagemath.org/question/42650/Direct sum for tensor product of CombinatorialFreeModulehttp://ask.sagemath.org/question/42658/direct-sum-for-tensor-product-of-combinatorialfreemodule/Problem: Given a finite free resolution C of $\mathbb{Z}$ over $\mathbb{Z}G$ I would like to consider the free resolution $C \otimes C$. Then of course in this new resolution I'm going to have direct sums of tensor products. In sage I'm working with CombinatorialFreeModule, there is a way to defining a direct sum over CombinatorialFreeModule_Tensor?
Thanks in advance.MarioMMon, 18 Jun 2018 20:39:48 -0500http://ask.sagemath.org/question/42658/difference between calling maxima lib and maxima processhttp://ask.sagemath.org/question/42656/difference-between-calling-maxima-lib-and-maxima-process/This question came up after reading answer here [timeout-does-not-work-with-maxima-ok-with-others/](https://ask.sagemath.org/question/42644/timeout-does-not-work-with-maxima-ok-with-others/)
So I thought to make new question.
Why does the following return back from maxima right away, without hanging (it is unevaluated integral, which is OK, since it could not do it) but sage does not hang
sage: var('x')
sage: r=maxima(sqrt(x^2 + 1)*arctan(x)^2)
sage: r.integrate(x)
'integrate(sqrt(_SAGE_VAR_x^2+1)*atan(_SAGE_VAR_x)^2,_SAGE_VAR_x)
But when doing the following, it hangs
sage: integrate(sqrt(x^2 + 1)*arctan(x)^2,x,algorithm="maxima")
I understand now that the first call was to the maxima process. While the second was to the maxim lib linked to sage process itself?
But should not the maxima code be the same? Then why does the first call not hang, while the second one does?
I have expected both to hang.
Using SageMath version 8.3.beta5, Release Date: 2018-06-09NasserMon, 18 Jun 2018 18:01:54 -0500http://ask.sagemath.org/question/42656/Sage give only three of five roots of simple equationhttp://ask.sagemath.org/question/42646/sage-give-only-three-of-five-roots-of-simple-equation/The equation below
f=-32/59049*r^6 + 32/2187*r^5 - 32/243*r^4 + 352/729*r^3 - 56/81*r^2 +
8/27*r
solve(f,r)
[r=−3*sqrt(3)/2+9,r=3*sqrt(3)/2+9,r=0]frederico firmoMon, 18 Jun 2018 10:02:55 -0500http://ask.sagemath.org/question/42646/timeout does not work with maxima. Ok with othershttp://ask.sagemath.org/question/42644/timeout-does-not-work-with-maxima-ok-with-others/This is using SageMath version 8.3.beta5, Release Date: 2018-06-09
I set a timeout using Python signal to put a limit on how long an integral can take (since as far as I know python itself does not have a timeout constraint support to use on a call to a function, so one must program this in)
If integrate takes more than some number of seconds, an exception is raised. This way my script does not hang on an integral.
I found it works with `fricas`, but not with `maxima`. i.e. when I set the algorithm to `maxima`, and pick an integral that takes too long and set the timeout to short time (10 seconds), the exception never fires. It means the signal was lost or ignored.
When I do the same thing, set the algorithm to `fricas`, and pick an integral that also takes long time for `fricas` to do, the timeout works.
Same exact code. Only difference is the algorithm used.
May be the way I am setting timer is not the best, and there are more robust ways to do this. But I do not understand now why it works with `fricas` and not with `maxima`. Here is an example. This is file called `test_hanged.sag`
#!/usr/bin/env sage
import sys, os, signal, time
from sage.all import *
class TimeoutError(Exception):
pass
def handler(signum,frame):
print("handler fired")
raise TimeoutError()
signal.signal(signal.SIGALRM, handler)
signal.alarm(10) #10 seconds time out
try:
#this call will hang. Timer is either lost or ignored. Only with maxima
integrate(sqrt(x^2 + 1)*arctan(x)^2,x, algorithm="maxima")
#never reach here
signal.alarm(0)
print "Finished "
except Exception as e:
#this never gets called. It is supposed to be called after 10 seconds
print "exception=", type(e).__name__
print "finished...."
Then `$ ./test_hang.sage` just hangs. Now the following with `fricas`, works. Same code. Just changed the call to integrate
#!/usr/bin/env sage
import sys, os, signal, time
from sage.all import *
class TimeoutError(Exception):
pass
def handler(signum,frame):
print("handler fired")
raise TimeoutError()
signal.signal(signal.SIGALRM, handler)
signal.alarm(10) #10 seconds time out
try:
#this call will hang or take too long if there is no timeout
integrate((x+(1+x)^(1/2))^(1/2)/(x^2+1)/(1+x)^(1/2),x,algorithm="fricas")
#never reach here, due to time out
signal.alarm(0)
print "Finished "
except Exception as e:
#this is now called. So timer worked.
print "exception=", type(e).__name__
print "finished...."
And now
./test_hang.sage
handler fired
exception= TimeoutError
finished....
Any idea why the above works with `fricas` and not with `maxima`? I need now to try to find better way to do timeouts, as the above does not work for all.NasserMon, 18 Jun 2018 05:24:39 -0500http://ask.sagemath.org/question/42644/why ? help does not work for me?http://ask.sagemath.org/question/42645/why-help-does-not-work-for-me/ I installed SageMath version 8.3.beta5 on Linux Manjaro 2 days ago first time using its package manager (it build sage, took loooong time).
But for some reason, I can't use the ? help. As in sin? or anything. It gives an error
ImportError: No module named sphinx.application
For example
sage: sin?
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-24-f06d370d3a79> in <module>()
----> 1 get_ipython().magic(u'pinfo sin')
/usr/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s)
2158 magic_name, _, magic_arg_s = arg_s.partition(' ')
2159 magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2160 return self.run_line_magic(magic_name, magic_arg_s)
2161
2162 #-------------------------------------------------------------------------
/usr/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_line_magic(self, magic_name, line)
2079 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2080 with self.builtin_trap:
-> 2081 result = fn(*args,**kwargs)
2082 return result
2083
<decorator-gen-74> in pinfo(self, parameter_s, namespaces)
/usr/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)
186 # but it's overkill for just that one bit of state.
187 def magic_deco(arg):
--> 188 call = lambda f, *a, **k: f(*a, **k)
189
190 if callable(arg):
/usr/lib/python2.7/site-packages/IPython/core/magics/namespace.pyc in pinfo(self, parameter_s, namespaces)
59 else:
60 self.shell._inspect('pinfo', oname, detail_level=detail_level,
---> 61 namespaces=namespaces)
62
63 @line_magic
/usr/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in _inspect(self, meth, oname, namespaces, **kw)
1534 elif meth == 'pinfo':
1535 pmethod(info.obj, oname, formatter, info,
-> 1536 enable_html_pager=self.enable_html_pager, **kw)
1537 else:
1538 pmethod(info.obj, oname)
/usr/lib/python2.7/site-packages/IPython/core/oinspect.pyc in pinfo(self, obj, oname, formatter, info, detail_level, enable_html_pager)
713 - detail_level: if set to 1, more information is given.
714 """
--> 715 info = self._get_info(obj, oname, formatter, info, detail_level)
716 if not enable_html_pager:
717 del info['text/html']
/usr/lib/python2.7/site-packages/IPython/core/oinspect.pyc in _get_info(self, obj, oname, formatter, info, detail_level)
614 """Retrieve an info dict and format it."""
615
--> 616 info = self._info(obj, oname=oname, info=info, detail_level=detail_level)
617
618 _mime = {
/usr/lib/python2.7/site-packages/IPython/core/oinspect.pyc in _info(self, obj, oname, info, detail_level)
763 ds += "\nDocstring:\n" + obj.__doc__
764 else:
--> 765 ds = getdoc(obj)
766 if ds is None:
767 ds = '<no docstring>'
/usr/lib/python2.7/site-packages/sage/misc/lazy_import.pyx in sage.misc.lazy_import.LazyImport.__call__ (build/cythonized/sage/misc/lazy_import.c:3768)()
352 True
353 """
--> 354 return self.get_object()(*args, **kwds)
355
356 def __repr__(self):
/usr/lib/python2.7/site-packages/sage/misc/sageinspect.py in sage_getdoc(obj, obj_name, embedded_override)
1911 - extensions by Nick Alexander
1912 """
-> 1913 import sage.misc.sagedoc
1914 if obj is None:
1915 return ''
/usr/lib/python2.7/site-packages/sage/misc/sagedoc.py in <module>()
49 from sage.misc.temporary_file import tmp_dir
50 from .viewer import browser
---> 51 from .sphinxify import sphinxify
52 import sage.version
53 from sage.env import SAGE_DOC_SRC, SAGE_DOC, SAGE_SRC
/usr/lib/python2.7/site-packages/sage/misc/sphinxify.py in <module>()
24 from tempfile import mkdtemp
25 from sage.env import SAGE_DOC_SRC
---> 26 from sphinx.application import Sphinx
27
28
ImportError: No module named sphinx.application
sage:
I tried sin? on https://sagecell.sagemath.org/ and it works there. So I guess something is wrong with my setup or may be because I am using beta version?
But this was what got installed automatically for me when I searched package manager for sage.
thanks
--NasserNasserMon, 18 Jun 2018 06:48:30 -0500http://ask.sagemath.org/question/42645/error using algorithm="sympy" on an integralhttp://ask.sagemath.org/question/42637/error-using-algorithmsympy-on-an-integral/Hello,
sorry if this is basic question, but I just started yesterday using sage.
When I set algorithm to sympy, I get strange error. But for all other algorithms, it works ok.
May be because I am using beta version? SageMath version 8.3.beta5, Release Date: 2018-06-09
var('t')
sage: integrate(log(t)/(t + 1),t, algorithm="maxima")
log(t + 1)*log(t) + dilog(-t)
sage: integrate(log(t)/(t + 1),t, algorithm="fricas")
integral(log(t)/(t + 1), t)
sage: integrate(log(t)/(t + 1),t, algorithm="giac")
integrate(log(t)/(t + 1), t)
sage: integrate(log(t)/(t + 1),t, algorithm="sympy")
gives
AttributeError Traceback (most recent call last)
<ipython-input-18-636e47034533> in <module>()
----> 1 integrate(log(t)/(t + Integer(1)),t, algorithm="sympy")
/usr/lib/python2.7/site-packages/sage/misc/functional.py in integral(x, *args, **kwds)
751 """
752 if hasattr(x, 'integral'):
--> 753 return x.integral(*args, **kwds)
754 else:
755 from sage.symbolic.ring import SR
/usr/lib/python2.7/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:69762)()
12345 R = ring.SR
12346 return R(integral(f, v, a, b, **kwds))
> 12347 return integral(self, *args, **kwds)
12348
12349 integrate = integral
/usr/lib/python2.7/site-packages/sage/symbolic/integration/integral.py in integrate(expression, v, a, b, algorithm, hold)
814 if not integrator:
815 raise ValueError("Unknown algorithm: %s" % algorithm)
--> 816 return integrator(expression, v, a, b)
817 if a is None:
818 return indefinite_integral(expression, v, hold=hold)
/usr/lib/python2.7/site-packages/sage/symbolic/integration/external.py in sympy_integrator(expression, v, a, b)
54 else:
55 result = sympy.integrate(ex, (v, a._sympy_(), b._sympy_()))
---> 56 return result._sage_()
57
58 def mma_free_integrator(expression, v, a=None, b=None):
/usr/lib/python2.7/site-packages/sage/interfaces/sympy.py in _sympysage_piecewise(self)
508 """
509 from sage.functions.other import cases
--> 510 return cases([(p.cond._sage_(),p.expr._sage_()) for p in self.args])
511
512 def _sympysage_fresnels(self):
/usr/lib/python2.7/site-packages/sage/interfaces/sympy.py in _sympysage_add(self)
190 s = 0
191 for x in self.args:
--> 192 s += x._sage_()
193 return s
194
/usr/lib/python2.7/site-packages/sage/interfaces/sympy.py in _sympysage_mul(self)
204 s = 1
205 for x in self.args:
--> 206 s *= x._sage_()
207 return s
208
/usr/lib/python2.7/site-packages/sage/interfaces/sympy.py in _sympysage_function(self)
273 fname = self.func.__name__
274 func = getattr(sagefuncs, fname, None)
--> 275 args = [arg._sage_() for arg in self.args]
276
277 # In the case the function is not known in sage:
AttributeError: 'TupleArg' object has no attribute '_sage_'
sage:
Sagemath seems to ship with its own python. So may be this is an why? I have python 3.6.5 installed on my Linux, and it works ok there, with sympy 1.1.1
[me@me-pc rubi_4_15_2]$ python --version
Python 3.6.5 :: Anaconda, Inc.
[me@me-pc rubi_4_15_2]$ python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from sympy import *
>>> t=symbols('t')
>>> integrate(log(t)/(t + 1),t)
Piecewise((I*pi*log(t + 1) - polylog(2, t + 1), Abs(t + 1) < 1), (-I*pi*log(1/(t + 1)) - polylog(2, t + 1), Abs(1/(t + 1)) < 1), (-I*pi*meijerg(((), (1, 1)), ((0, 0), ()), t + 1) + I*pi*meijerg(((1, 1), ()), ((), (0, 0)), t + 1) - polylog(2, t + 1), True))
>>>
And sage seems to be using sympy 1.1.1 as well
sage: import sympy
sage: print(sympy.__version__)
1.1.1
So why this error only shows up from inside sage and not from python itself, both calling same sympy?NasserSun, 17 Jun 2018 19:22:48 -0500http://ask.sagemath.org/question/42637/How to set an option for algorithm used by Integratehttp://ask.sagemath.org/question/42627/how-to-set-an-option-for-algorithm-used-by-integrate/**Update**
I think this issue is resolved now. Thanks to an answer by [Matrin R at Fricas group](https://groups.google.com/forum/#!topic/fricas-devel/aV7uLH8plZM), doing this from sage works
sage: fricas.setSimplifyDenomsFlag(fricas.true)
This sets the flag inside sage as I wanted. I verified it works.
----------
Original question
-----------------
Hello;
When using Fricas directly, I always set
setSimplifyDenomsFlag(true)
Before calling integrate. For example
setSimplifyDenomsFlag(true)
integrate((x+(1+x)^(1/2))^(1/2)/(x^2+1)/(1+x)^(1/2),x)
Otherwise, many integrals will hang or take too much time. Since I have a timeout of 3 minutes, it will fail.
But from sage, I could only do
integrate((x+(1+x)^(1/2))^(1/2)/(x^2+1)/(1+x)^(1/2),x,algorithm="fricas")
Is there a way to somewhere pass this command to fricas along with the integrate command? i.e. is there a way to pass 2 commands to be executed in same transaction to the other CAS? Because without being able to set this flag before calling integrate, this will not work. By default this flag is set to false in Fricas for some reason.
ps. I asked at the Fricas forum if there is a way to rebuild fricas on Linux with this flag set to true. If so, I can rebuild-fricas. But I do not know now. I asked here fyi
[https://groups.google.com/forum/#!topic/fricas-devel/aV7uLH8plZM](https://groups.google.com/forum/#!topic/fricas-devel/aV7uLH8plZM)
Thank you
--NasserNasserSun, 17 Jun 2018 07:46:02 -0500http://ask.sagemath.org/question/42627/syllables on symbolic expressionhttp://ask.sagemath.org/question/42632/syllables-on-symbolic-expression/ If I have a symbolic expression, is there a way to obtain, something like the syllables of this expression in the way as in elements of a FreeGroup?MarioMSun, 17 Jun 2018 17:11:40 -0500http://ask.sagemath.org/question/42632/More problems with general power of a matrixhttp://ask.sagemath.org/question/42532/more-problems-with-general-power-of-a-matrix/Even though in version 8.2 the code for the general power of a matrix has been improved (c.f. [question 41622](https://ask.sagemath.org/question/41622/bug-in-general-power-of-a-matrix/)), it still doesn't work in some cases, as i.e. this singular, diagonalizable matrix
A=matrix(QQbar,3,3,[[-2,-8,-12],[1,4,4],[0,0,1]])
k=var('k')
A**k
shows.
Concerning the [remark in trac ticket 25520](https://trac.sagemath.org/ticket/25520): Why not defining $0^x=1$ for $x\in {\bf N}$, which seems reasonable, since the number of functions $\emptyset \to \emptyset$ is 1?Frank ZenterWed, 06 Jun 2018 09:12:15 -0500http://ask.sagemath.org/question/42532/Translating Gamma from fricas to sage causes exceptionhttp://ask.sagemath.org/question/42626/translating-gamma-from-fricas-to-sage-causes-exception/hello;
I just started trying sage to test Fricas integrate, but for some results, it fails, even though Fricas actually is able to do the integration.
It fails because it can't translate Fricas result to sage syntax, so it gives an exception. I record this as failed integrate, since
for any exception thrown, I assume it failed. But this is not fair for Fricas since it actually did not fail.
Here is an example
sage: var('t, n')
anti=integrate(log(t)^(-n - 1),t, algorithm="fricas")
exception trapped is
NotImplementedError: The translation of the FriCAS
Expression cos((n+1)*pi )*Gamma((-1)*n,(-1)*log(t)) to sage is not yet implemented.
Why it can't translate it, since Maxima result has a gamma in it. Is it the UpperCase Gamma that is the problem?
integrate(log(t)^(-n - 1),t, algorithm="maxima")
-(-log(t))^n*log(t)^(-n)*gamma(-n, -log(t))
No error. I am using
SageMath version 8.3.beta5, Release Date: 2018-06-09
ps. Output from Fricas itself matches what is shown above OK.
FriCAS Computer Algebra System
Version: FriCAS 1.3.3
Timestamp: Sun Jun 17 01:20:37 CDT 2018
(1) -> integrate(log(t)^(-n - 1),t)
(1) cos((n + 1)%pi)Gamma(- n,- log(t))
Type: Union(Expression(Integer),...)NasserSun, 17 Jun 2018 06:57:59 -0500http://ask.sagemath.org/question/42626/How to find version number of CAS used by sagehttp://ask.sagemath.org/question/42617/how-to-find-version-number-of-cas-used-by-sage/Hello. sagemath newbie here.
When I type
r=integrate(sqrt(x),x,algorithm="sympy")
or
r=integrate(sqrt(x),x,algorithm="fricas")
or
r=integrate(sqrt(x),x,algorithm="maxima")
etc..
what command to use to find what version numbers of those CAS it is using? For Fricas, I just installed it, so I know it is 1.3.3-1, But in general, how does one ask sage to provide this information? Is there a command to use?
Will these be the same obtained on the bash command line when doing
$which maxima
$which fricas
If that is the case, then I can find the version numbers easily. But what about sympy? How do I know which sympy sage is using to make sure.
Thank you,
--NasserNasserSun, 17 Jun 2018 02:14:20 -0500http://ask.sagemath.org/question/42617/subgroup of unit group of number field (without calculating unit group)?http://ask.sagemath.org/question/42622/subgroup-of-unit-group-of-number-field-without-calculating-unit-group/https://ask.sagemath.org/question/27274/subgroup-of-number-field-unit-group/
There is a similar question in this link. But I want to know whether I can do this (without knowing the unit group).
So, I have collected a list of elements (from another code), which will be generators of the subgroup I want to generate. What should I do?
mathjainSun, 17 Jun 2018 04:51:27 -0500http://ask.sagemath.org/question/42622/About SymmetricGroupRepresentation()http://ask.sagemath.org/question/42614/about-symmetricgrouprepresentation/I am a new student in SAGE. I read the following discussion:
`evaluation of character of symmetric group`
and then also read the manual.
However, I am still confused about some fundamental problem:
(I cannot find these function in "Sage Reference Manual: Groups, Release 8.2". Are both new functions?).
1. About
SymmetricGroupRepresentation(partition, implementation='specht', ring=None, cache_matrices=True)
I am confused about "partition". Suppose for $S_3$, and partition $=[2,1]$. What does it mean? (It seems $[1,2]$ is not valid)
2. About
spc = SymmetricGroupRepresentation([2,1], 'specht')
spc.representation_matrix(Permutation([1,2,3]))
When I use
spc.representation_matrix(Permutation([1,2]))
error pops out. However, as far as I know, $(1,2)$ is a valid permutation, which represent the matrix representation: $$\begin{bmatrix}0 & 1 & 0 \\\ 1 & 0 & 0 \\\ 0 & 0 & 1\end{bmatrix}$$
However, if I use 'orthogonal' instead of 'specht', the answer becomes
$$\begin{bmatrix}1 & 0 \\\ 0 & 1\end{bmatrix}$$
But I test another permutation: $[1,2,3]$, the answer is the same. However, $[1,2]$ and $[1,2,3]$ are in the different conjugacy classes; they should not have the same character.
I cannot find "Permutation" in "Sage Reference Manual: Group". Where can I find this function?sleeve chenSat, 16 Jun 2018 17:15:58 -0500http://ask.sagemath.org/question/42614/RecursionError when installing SageMath 8.2http://ask.sagemath.org/question/42562/recursionerror-when-installing-sagemath-82/I downloaded `sage-8.2-OSX_10.13.4-x86_64.dmg`. Then I ran `./sage` from the extracted `SageMath` directory in a Terminal. Then I got the following error:
Last login: Sun Jun 10 23:17:18 on ttys001
/Users/jing/tools/SageMath/sage ; exit;
➜ ~ /Users/jing/tools/SageMath/sage ; exit;
RecursionError: maximum recursion depth exceeded during compilation
************************************************************************
It seems that you are attempting to run Sage from an unpacked source
tarball, but you have not compiled it yet (or maybe the build has not
finished). You should run `make` in the Sage root directory first.
If you did not intend to build Sage from source, you should download
a binary tarball instead. Read README.txt for more information.
************************************************************************
[Process completed]
I am using macOS 10.13.4. Can anyone help me on this?Jingguo YaoSun, 10 Jun 2018 10:23:32 -0500http://ask.sagemath.org/question/42562/How to compute common zeros of system of polynomial equations with dimension 2?http://ask.sagemath.org/question/42591/how-to-compute-common-zeros-of-system-of-polynomial-equations-with-dimension-2/I have some ideal of homogenous polynomials defined over some finite field:
J is the ideal of interest. However I can't call J.variety() since it is not zero dimensional. The system of equations might contain 6 or 231 polynomials in four variables:
sage: [I.gens() for I in J.minimal_associated_primes()]
[[x1 + x2, x0 + x3], [x2 + x3, x0 + x1], [x1 + x3, x0 + x2]]
sage: J.dimension()
2
Any ideas?
On request. The program computes the invariant under the group $2_{+}^{1+2\cdot2}$ homogenous polynomials of given degree. To construct the polynomials and get a list of them call: homInvar(6):
F = ZZ;
a = matrix(F, [[0,0,0,-1],[0,0,1,0],[0,-1,0,0],[1,0,0,0]])
b = matrix(F, [[1,0,0,0],[0,1,0,0],[0,0,-1,0],[0,0,0,-1]])
c = matrix(F, [[0,1,0,0],[-1,0,0,0],[0,0,0,1],[0,0,-1,0]])
d = matrix(F, [[0,1,0,0],[1,0,0,0],[0,0,0,-1],[0,0,-1,0]])
def getPart(deg):
part = []
for k in range(deg+1):
for l in range(deg+1):
for m in range(deg+1):
for n in range(deg+1):
if k+l+m+n == deg:
part.append((k,l,n,m))
return part
def p(x,part):
x = x.list()
pol = 0
for p in [part]:
mon = 1
for i in range(len(p)):
k = p[i]
mon = mon * x[i]**k
pol = pol + mon
return pol
def getGroup():
G = []
for k in range(4):
for l in range(4):
for m in range(4):
for n in range(4):
g = a**k*b**l*c**m*d**n
if G.count(g)==0:
G.append(g)
return G
def reynolds(Gr,part):
reyn = 0
n = len(part)
X = list(var('x%d' % i) for i in range(n))
x = matrix([X]).transpose()
for g in Gr:
reyn += p(g*x,part=part)
#print reyn
return 1/len(Gr)* reyn
def homInvar(deg,Gr=getGroup(),getPart=getPart):
parts = getPart(deg)
inv = set([])
for part in parts:
r = reynolds(Gr,part)
#print r
if r != 0:
inv.add(r)
return invsagemathuserThu, 14 Jun 2018 05:49:21 -0500http://ask.sagemath.org/question/42591/