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.Sat, 19 Jan 2019 07:42:20 -0600Redefine Method in Sage classhttp://ask.sagemath.org/question/45102/redefine-method-in-sage-class/I am using the a class to manipulate vector fields of $\mathbb{R}^n$.
I am using an other convention on the lie brackets : to compute $XY=[X,Y]$ I have to enter $XY=-X.bracket(Y)$.
**I would like to redefine the method "bracket()"** so that I include this minus sign in the redefinition.
Of course I can each time put a minus sign in front all my definition or call Y.bracket(X) to compute [X,Y] but I don't want to use them (the display is then not adapted ...).
Here is my code
from sage import *
reset()
def mybracket(A,B):
return B.bracket(A)
M.<x,y> = EuclideanSpace()
X = M.vector_field(0,1-y*x^2, name='X')
Y = M.vector_field(-(y-1),x, name='Y')
YX = Y.mybracket(X)
*AttributeError: 'VectorFieldFreeModule_with_category.element_class' object has no attribute 'mybracket'*
ThankssagenotdeadSat, 19 Jan 2019 07:42:20 -0600http://ask.sagemath.org/question/45102/Can I get a matrix to show with brackets instead of parentheses?http://ask.sagemath.org/question/24068/can-i-get-a-matrix-to-show-with-brackets-instead-of-parentheses/I'm using Sage and SageTeX to make worksheets and quizzes for my Linear Algebra course. I'd like my presentation to match the book's, and the book uses brackets around its matrices instead of parentheses. Is that doable? Is there a way, for example, to get `latex(A)` to generate
\left[\begin{array}{rrr} 6 & 6 & 1 \\ 7 & 0 & 6 \\ 4 & -7 & -7 \end{array}\right]
instead of
\left(\begin{array}{rrr} 6 & 6 & 1 \\ 7 & 0 & 6 \\ 4 & -7 & -7 \end{array}\right)
for some matrix A.mathochistTue, 09 Sep 2014 10:28:54 -0500http://ask.sagemath.org/question/24068/Make sage to don't open brackets while solving equationhttp://ask.sagemath.org/question/8138/make-sage-to-dont-open-brackets-while-solving-equation/Hi,
I have an equation
import sympy
...
eq1 = 80*X*e^(T*p) + X*e^(2*T*p) == 5*e^(T*p)/(e^(T*p) - 1) + e^(T*p)/(e^(T*p) - e^(2*T))
and when I do
Xi = eq1.solve(X)
X = Xi[0].right()
X = X.simplify_full()
X = sympy.simplify(X)
X = X.subs(e^(p*T), z)
X = SR(X)
get answer
X = (6*z - 5*e^(2*T) - 1)/(z^3 - z^2*e^(2*T) + 79*z^2 - 79*z*e^(2*T) - 80*z + 80*e^(2*T))
Next I need to find pole of X (z that gives denominator==0). But sagemath opened the brackets in denominator
sage: Xi
[X == -(6*e^(T*p) - 5*e^(2*T) - 1)/(79*e^(T*p + 2*T) + e^(2*T*p + 2*T) + 80*e^(T*p) - 79*e^(2*T*p) - e^(3*T*p) - 80*e^(2*T))]
it's very bad. Here numerator have only 3rd power, but if it will be bigger, sagemath (i think) give me no solution.
When I do prevision commands using pen and paper I get in denominator
(z-1)*(z+80)*(z-e^(2*T))
how to get it with sagemath?
(sorry for bad eng.)
avi9526Wed, 01 Jun 2011 05:28:33 -0500http://ask.sagemath.org/question/8138/