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.Fri, 10 Apr 2020 08:54:33 -0500Definition of symbolic functions on path algebrahttps://ask.sagemath.org/question/50655/definition-of-symbolic-functions-on-path-algebra/I tried to define a symbolic function on path algbera like that:
G = DiGraph({1:{2:['a']}, 2:{3:['b']}})
P = G.path_semigroup()
A = P.algebra(GF(7))
A.inject_variables()
def ev(self, x): return 2*x
foo = function("foo", nargs=1, eval_func=ev)
foo(a)
But I get an error: TypeError: cannot coerce arguments: no canonical coercion from Path algebra of Multi-digraph on 3 vertices over Finite Field of size 7 to Symbolic Ring. My question how can I define a symbolic function to accept path algebra variables?
Thanks.Z3r0Fri, 10 Apr 2020 08:54:33 -0500https://ask.sagemath.org/question/50655/how to best simplify/factor symbolic expressionshttps://ask.sagemath.org/question/49616/how-to-best-simplifyfactor-symbolic-expressions/Define symbolic expressions T3 and T3s.
q1,q2,q3 = var('q1,q2,q3')
T3 = (q1^2*q2^2 + 1)*(q1^2*q3^2 + 1)*(q2^2*q3^2 + 1)*(q1*q2 + 1)*(q1*q2 - 1)*(q1*q3 + 1)*(q1*q3 - 1)*(q2*q3 + 1)*(q2*q3 - 1)/((q1^2*q2^2*q3^2 + 1)*(q1*q2*q3 + 1)*(q1*q2*q3 - 1)*(q1^2 + 1)*(q2^2 + 1)*(q3^2 + 1)*(q1 + 1)*(q1 - 1)*(q2 + 1)*(q2 - 1)*(q3 + 1)*(q3 - 1))
T3s = (q1^4*q2^4 - 1)*(q1^4*q3^4 - 1)*(q2^4*q3^4 - 1)/((q1^4*q2^4*q3^4 - 1)*(q1^4 - 1)*(q2^4 - 1)*(q3^4 - 1))
Is there any method to reduce T3 to its simpler (at least for a human) form T3s in Sage?rue82Tue, 21 Jan 2020 05:07:05 -0600https://ask.sagemath.org/question/49616/symbolic constant in clifford algebrahttps://ask.sagemath.org/question/33763/symbolic-constant-in-clifford-algebra/ Dear all,
First of all I'd like to state that I am far from a SageMath expert. Right now, I am working on Clifford algebra's and I would like to do some computations with SageMath Cloud. Unfortunately, I experience the problem that when I define a symbolic constant, Sage doesn't know how to multiply this with elements in the Clifford algebra. This is the code that I'm using.
START CODE
C = ComplexField();
sage: Q = QuadraticForm(C, 3, [0,0,1,1,0,0])
sage: Cl.<x,y,z> = CliffordAlgebra(Q)
var('e')
e*x
END CODE
I get an error for e*x: ''unsupported operand parent(s) for '*': 'Symbolic Ring' and 'The Clifford algebra of the Quadratic form in 3 variables over Complex Field with 53 bits of precision with coefficients:''
Does anyone maybe know how to work around this? Maybe I am defining the variable all wrong?
Thank you very much!
Kind regards,
David
davidvanovereemMon, 13 Jun 2016 08:01:50 -0500https://ask.sagemath.org/question/33763/How to multiply symbolic constant with element in clifford algebra?https://ask.sagemath.org/question/33764/how-to-multiply-symbolic-constant-with-element-in-clifford-algebra/Dear all,
first I would like to state that I am only a beginner at using SageMath. Currently I am working on Clifford algebra's but unfortunately I'm experiencing a problem. I cannot find a solution in the documentation so I hope maybe someone here has an idea!
I would like to define a symbolic constant in the field of complex numbers, and multiply this with an element from the clifford algebra. Unfortunately, SageMath doesn't like this! This is the code that I'm using:
START CODE
sage: Q = QuadraticForm(CC, 3, [0,0,1,1,0,0])
sage: Cl.<x,y,z> = CliffordAlgebra(Q)
var('e')
e*x
END CODE
the operation e*x now gives me an error: ''TypeError: unsupported operand parent(s) for '*': 'Symbolic Ring' and 'The Clifford algebra of the Quadratic form in 3 variables over Complex Field with 53 bits of precision with coefficients: ...''
Does anyone maybe have an idea how to work around this? Maybe I'm defing the symbolic constant all wrong?
Thank you very much! Kind regards,
David
davidvanovereemMon, 13 Jun 2016 08:07:26 -0500https://ask.sagemath.org/question/33764/Symbolic Linear Algebrahttps://ask.sagemath.org/question/26952/symbolic-linear-algebra/I'd like to manipulate symbolic expression in linear algebra. More specifically, suppose that A,B, etc. are matrices and v,w,.. etc are column vectors. I have various expressions in them that I'd like expanded and grouped. It also should know about transpose (that it's an involution). For example, if I write the expression:
transpose(v-w)*A*(v-w). It should be able to expand this to
transpose(v)*A*v - transpose(v)*A*w - transpose(w)*A*v + transpose(w)*A*w
Also, I'd like to specify that A is symmetric -- A == transpose(A). In that case the above would simplify to
transpose(v)*A*v - 2*transpose(v)*A*w + transpose(w)*A*w
if we idenfity a 1 by 1 matrix with a scalar. It would also be nice, if we could specify symbolic scalars, and, for example to say that A in hom(V,W), where V,W are some vector spaces. In that case if we try to multiply things that are incompatible we would get an error. This looks like it should be part of some sort of universal algebra package. Does such a thing exist in SAGE?VictorWed, 27 May 2015 09:59:07 -0500https://ask.sagemath.org/question/26952/Working with complex symbolic expressionshttps://ask.sagemath.org/question/8716/working-with-complex-symbolic-expressions/I am a beginner at Sage so my questions may not be well informed, so bear with me.
The context: I am trying to use sage to explore the exponential function assuming all I know about it is that it is its own derivative and has the value 1 at z = 0. It is then easy to develop the Taylor series to any degree using formula like:
expp2( z ) = 1 + ( 1/ factorial( 1 ) )* z + ( 1/ factorial( 2 ) ) * ( z ^ 2 )
You can take 2 of these for z = a and z = b and multiply them together in Sage. Getting something like:
1/4*(b^2 + 2*b + 2)*(a^2 + 2*a + 2)
Now I have done the algebra by hand and know this reduces to the Taylor expansion for z = a + b.
What I do not get is how to show this part in Sage in a nice clean way ( I have some ways I do not like so much ).
Here I have 2 questions one specific, and one general ( I am interested in the answer to either one or both):
1) If this exponential question interests anyone, could you offer some tips? I have tried various ( but not all ) applications of expand and simplify. I am still plugging away.
2) Is there a guide that would help me learn how to carry out algebraic operations over complex expressions. I have looked at several basic tutorials, but they do not have much detail. The most useful single resource I have found is
http://www.sagemath.org/doc/reference/sage/symbolic/expression.html
and the pages linking from it.
russ_henselMon, 13 Feb 2012 08:07:47 -0600https://ask.sagemath.org/question/8716/Symbolic matrices and "integrity" of their inversehttps://ask.sagemath.org/question/8391/symbolic-matrices-and-integrity-of-their-inverse/I have to solve the following problem:
Does a matrix $G\in GL(n,\mathbb{Z})$ exists such that
$$
G\times A\times G^{-1}=B
$$
being $A,B$ given matrices in $\mathbb{Q}$?
Doing everything by hand, I finally find myself with a bunch of symbolic matrices. Now I have to check if they can lay inside $GL(n,\mathbb{Z})$, i.e. if there are integer values for the variables in the matrix such that the matrix is integer, invertible and with integer inverse.
E.g.:
$$\left(\begin{array}{cc}x & 0 \\\\ 0 & y\end{array}\right)$$ does the trick only for $x=y=1$.
Is there a quick method within Sage to solve that last problem?
Thanks!JesustcMon, 17 Oct 2011 05:44:30 -0500https://ask.sagemath.org/question/8391/Filtering an expression: keeping only term with even powerhttps://ask.sagemath.org/question/9456/filtering-an-expression-keeping-only-term-with-even-power/In the expression
$$
x^2 y^2+x y^2+x^3y + 5 x^4 y^4
$$
I would like to keep only the term where the variables have even power
$$
x^2y^2+5 x^4 y^4
$$
Is there a way to do it?
I look into this [post](http://ask.sagemath.org/question/1747/extract-terms-from-a-sum?answer=2598#2598).
But once I get the operands, I don't see how to analyze the variable exponent.Nicolas Essis-BretonMon, 22 Oct 2012 12:26:25 -0500https://ask.sagemath.org/question/9456/Extract terms from a sumhttps://ask.sagemath.org/question/9295/extract-terms-from-a-sum/Is there some way to programmatically extract the first, second, third, and so on terms from a sum of symbolic terms (or equivalently, turn such a sum into the list of its summands)? For example, after
sage: A,B,C = var('A'), var('B'), var('C')
sage: F = A*B+C; F
A*B + C
Is there some method you can call on F to extract A*B (or C)? This would be useful especially for displaying sage in LaTeX via sageTeX when a formula that is the sum of 4 terms (say) runs over the margin and has to be split up somehow. I would also be interested in a workaround in sageTeX that would allow you to flexibly insert a linebreak in a formula under the circumstances that the formula generated by Sage got too long for a line.
heatkernelTue, 04 Sep 2012 17:05:14 -0500https://ask.sagemath.org/question/9295/Substitution using Dictionary with Matrix as Valuehttps://ask.sagemath.org/question/9075/substitution-using-dictionary-with-matrix-as-value/As a newcomer to SAGE, trying to use it to do symbolic linear algebra, I am wondering why substitution of a variable using a dictionary doesn't work in this case:
sage: aMatrix = matrix(SR,1,1)
sage: var('aVariable')
aVariable
sage: aDict = {}
sage: aDict[aVariable] = aMatrix
sage: aDict[aVariable]
[0]
but:
sage: aVariable.subs(aDict)
....
/Applications/sage/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.substitute (sage/symbolic/expression.cpp:16025)()
/Applications/sage/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.coerce_in (sage/symbolic/expression.cpp:11265)()
/Applications/sage/local/lib/python2.7/site-packages/sage/structure/parent_old.so in sage.structure.parent_old.Parent._coerce_ (sage/structure/parent_old.c:3369)()
/Applications/sage/local/lib/python2.7/site-packages/sage/structure/parent.so in sage.structure.parent.Parent.coerce (sage/structure/parent.c:8912)()
TypeError: no canonical coercion from Full MatrixSpace of 1 by 1 dense matrices over Symbolic Ring to Symbolic Ring
Functionality to substitute matrices for variables seems to be indispensable to doing symbolic linear algebra, so I am sure there is a proper way to do this.
heatkernelThu, 14 Jun 2012 10:58:48 -0500https://ask.sagemath.org/question/9075/"Abstract" linear algebrahttps://ask.sagemath.org/question/7670/abstract-linear-algebra/This is more of a general question about whether we can do with Sage what we normally do as mathematicians on paper and in our minds. For example, if I do
V = VectorSpace(QQ,4)
W = VectorSpace(QQ,4)
V==W
I get: True. This is quite disturbing - while V and W are isomorphic they should not be identical. As I understand it, a vectorspace over QQ for Sage is just QQ^4, that's it. In other words, the Linear algebra package, while excellent, is not really about vector spaces but rather about arrays of numbers.
Any thoughts on this desire of mine to have a genuine "coordinate-free" approach?
marcoMon, 06 Sep 2010 18:28:29 -0500https://ask.sagemath.org/question/7670/