2019-09-14 19:48:28 -0500 received badge ● Nice Answer (source) 2019-09-13 19:41:37 -0500 answered a question Sage is not preparsing Python 3 underscored integers Good point. Indeed, the preparser is not able to handle such litterals yet. This is now trac ticket 28490. 2019-09-13 11:47:37 -0500 commented answer installing sage-8.8-Ubuntu_18.04-x86_64.tar.bz2 Is everything working now ? 2019-09-13 11:40:38 -0500 answered a question Exploiting the results of an optimization If you put %display latex you do not have to write show(D), simply write D and start a new cell. Regarding your second question, you can do: SR.var("x") == x1  and it will look like what you want if you have %display latex Regarding your last question, you can get the value of x in the first (actually the only one) solution of z by typing z[0][x] 2019-09-13 11:37:02 -0500 edited question Exploiting the results of an optimization The code bellow work perfectly but if i get ride of show(), it doesn't display in LaTeX secondly I would like to display not Simply show(x1) but "x=show(x1)". How can I do that ? (The question continue after the code) %display latex var('A, x, y, l, alpha, beta, R, p_x, p_y'); U= A*x^(alpha)*y^(beta); show(U) D = p_x*x + p_y*y; show(D) show(U) solve(D==R, y) L = U-l*(D-R) show(L) L_x= L.diff(x) show(L_x) L_y= L.diff(y) show(L_y) L_l= L.diff(l) %display latex var('A, x, y, l, alpha, beta, R, p_x, p_y'); U= A*x^(alpha)*y^(beta); show(U) D = p_x*x + p_y*y; show(D) show(U) solve(D==R, y) L = U-l*(D-R) show(L) L_x= L.diff(x) show(L_x) L_y= L.diff(y) show(L_y) L_l= L.diff(l) show(L_l) z=solve([L_x==0, L_y==0, L_l==0,], x, y, l) show(z[0]) x1=z[0][0].right() show(x1) y1=z[0][1].right() show(y1) l1=z[0][2].right().canonicalize_radical() show(l1) U1=U.subs(x=x1,y=y1).canonicalize_radical() show(U1) latex(U1)  Now yesterday some one shows me how to do the same thing with a dictionary z=solve([L_x==0, L_y==0, L_l==0,], x, y, l, solution_dict=True) show(z)  how can I extact $x= solution$ and so on. 2019-09-13 11:33:26 -0500 answered a question Finite Fields: Basic Question When you write sage: k = GF(9, 'a')  The Python name k points to the field with 9 elements: sage: k Finite Field in a of size 3^2  But the Python name a does not point to anything: sage: a NameError: name 'a' is not defined  If you want to get the generator of the field, you can do: sage: k.gen() a sage: k.gen()^8 1  So, if you want the Python name a to point to that generator of the field, you can just do: sage: a = k.gen() sage: a a sage: a^2 a + 1 sage: x = 2*a+1 sage: x 2*a + 1 sage: x^3 a  Now, Sage has some magic to do that, you could also do (it is very convenient for objects with several generators): sage: k.inject_variables() Defining a  Also, there is something else, which is convenient for mathematicians, but violates the Python language (there is a specific Sage preparsing behind the scenes), you can do: sage: k. = GF(9)  This defines both k and a at the same time. 2019-09-13 11:23:48 -0500 commented answer installing sage-8.8-Ubuntu_18.04-x86_64.tar.bz2 You have to do sudo apt install python 2019-09-13 09:06:48 -0500 received badge ● Nice Answer (source) 2019-09-13 08:13:53 -0500 edited question degree versus in_degree I have a problem when calling degree and in_degree on directed graph I loaded. In particular, I had thought, for a particular node, that degree = in + out degree but am getting a situation where in_degree > degree for a given node. Here is the output for a graph I loaded: sage: T.in_degree(vertices=[0],labels=True) {0: 628} sage: T.degree(vertices=[0],labels=True) {0: 394}  This is also the case for other nodes in the graph. Any idea what's going on here? thanks! --David 2019-09-13 05:49:11 -0500 answered a question Memory leak with matroid is_connected() method I can not reproduce you problem, you should provide more details, see: sage: I = random_matrix(ZZ,10,10) sage: M = Matroid(matrix = I, ring = GF(2)) sage: for _ in range(10): ....: for i in range(0, M.corank() + 1): ....: for F in M.coflats(i): ....: pass ....: get_memory_usage() ....: 8393.46875 8393.71875 8393.71875 8393.71875 8393.71875 8393.71875 8393.71875 8393.71875 8393.71875 8393.71875  2019-09-13 05:33:21 -0500 answered a question More physics constants in Sagemath As explained in the doc you provided, this constant appears in the constant database, so you can do: sage: from scipy.constants import physical_constants sage: physical_constants["Bohr magneton"] (9.274009994e-24, 'J T^-1', 5.7e-32)  So you can do something like: sage: Bohr = physical_constants["Bohr magneton"][0] sage: Bohr 9.274009994e-24  2019-09-13 04:29:50 -0500 answered a question How to Latex-print matrices as a bold uppercase letter? Ragarding the first question, you should understand that when you write: sage: A = matrix(2,2,var('a', 'b', 'c', 'd'))  A is a Python name, that is a kind of pointer to the matrix object, but the matrix object doesn't know anything about which names point to it. For example, you can then do: sage: B = A  Here B is just another Python name pointing to the very same object in memory as you can check with: sage: B is A True  So, if you want to type A.as_symbol(), there is nowhere in the matrix object that registered the fact that the matrix has "A" as a string representation. We can define a function that finds one of the Python names of the matrix object within the globals() dictionary and pick the first one that appears (and that is not ugly like _42), but it is kind of artificial, like: sage: def sym(a): ....: for i in globals(): ....: if not i.startswith('_') and globals()[i] is a: ....: return SR.var(i, latex_name="\Bold{{{}}}".format(i))  You have: sage: latex(sym(A)) {\Bold{A}}  But of course: sage: latex(sym(B)) {\Bold{A}}  Regarding the second question, it is a bit different, since the symbolic variable knows a string reprentation of itself, and you can even tune a latex one as follows: sage: A = SR.var('A', latex_name="\Bold{A}") sage: B = SR.var('B', latex_name="\Bold{B}") sage: c = SR.var('c') sage: A*B A*B sage: latex(A*B) {\Bold{A}} {\Bold{B}} sage: e = (A+B)*c sage: e (A + B)*c sage: e.expand() A*c + B*c sage: latex(e.expand()) {\Bold{A}} c + {\Bold{B}} c  2019-09-13 03:35:57 -0500 answered a question SageAppliance not more maintained after 8.1? Volker (the current release manager of Sage) used to build this on his laptop, so perhaps he just stopped to do so since there is now the cygwin build, see https://groups.google.com/forum/#!top... Let me ask for more details. 2019-09-13 03:27:39 -0500 answered a question Sage Math can't find pandoc on MacOS Mojave I am not a mac user, but the error you get about pandoc is weird since it should be sufficient that it is on your path. Regarding latex, note that you need xetexpackage, see https://nbconvert.readthedocs.io/en/l... 2019-09-12 15:06:53 -0500 commented question degree versus in_degree There might be a bug, could you please provide the code for T so that we can inspect further ? 2019-09-12 15:01:10 -0500 commented question 3 questions in one about exploiting the result of an optimization You can try again. 2019-09-12 15:00:46 -0500 answered a question 3 questions in one about exploiting the result of an optimization Regarding 1, see the answer of https://ask.sagemath.org/question/478... Regarding 2, which factorization would you expect ? Regarding 3, you ar lucky because in the tree of the representation of the expression, alpha+beta appears as subtrees, so the following works: sage: U1.subs({alpha+beta:1}) A*(R*alpha/p_x)^alpha*(R*beta/p_y)^beta  Regarding 4, if you are using jupyter notebook, you can add the following in the first cell: %display latex  2019-09-12 14:52:58 -0500 edited question 3 questions in one about exploiting the result of an optimization This is an incredible result of SageMath since one is obliged to help Mathematica to obtain the result  var('A, x, y, l, alpha, beta, R, p_x, p_y'); U= A*x^(alpha)*y^(beta); show(U) D = p_x*x + p_y*y; show(D) show(U) solve(D==R, y) L = U-l*(D-R) show(L) L_x= L.diff(x) show(L_x) L_y= L.diff(y) show(L_y) L_lambda= L.diff(l) show(L_l) z=solve([L_x==0, L_y==0, L_l==0,], x, y, l) show(z[0]) x1=z[0][0].right() show(x1) y1=z[0][1].right() show(y1) U1=U.subs(x=x1,y=y1) show(U1)  But I would ameliorate the presentation : 1) How can I substitute greek $\lambda$ to l in the code ? 2) The final result should be simplified because there are possible factorizations ? 3) How can I, without rewriting, all the code add the hypothesis $\alpha+ \beta =1$ ? 4) how to have the results automaticaly written in LaTeX without using show() A great hand shake for the one who will help me on those maters. 2019-09-12 14:48:22 -0500 commented question Optimization under constraint I bet L_l (which is not defined) stands for L_lambda. 2019-09-12 14:47:25 -0500 answered a question Optimization under constraint Regarding 1., it is not possible to use unicode λ in variables names, since Sage relies on Python 2, which does not allow it, so you have to wait the migration of Sage to Python 3 for that. Regarding 2, you can use the solution_dict=True of solve : sage: z=solve([L_x==0, L_y==0, L_l==0,], x, y, l, solution_dict=True) sage: z [{l: (A*alpha + A*beta)*(R*alpha/((alpha + beta)*p_x))^alpha*(R*beta/((alpha + beta)*p_y))^beta/R, y: R*beta/((alpha + beta)*p_y), x: R*alpha/((alpha + beta)*p_x)}] sage: z[0] {l: (A*alpha + A*beta)*(R*alpha/((alpha + beta)*p_x))^alpha*(R*beta/((alpha + beta)*p_y))^beta/R, y: R*beta/((alpha + beta)*p_y), x: R*alpha/((alpha + beta)*p_x)} sage: z[0][x] R*alpha/((alpha + beta)*p_x) sage: z[0][y] R*beta/((alpha + beta)*p_y)  You can pass a dictionary for substituting: sage: U.subs(z[0]) A*(R*alpha/((alpha + beta)*p_x))^alpha*(R*beta/((alpha + beta)*p_y))^beta  2019-09-12 14:41:24 -0500 edited question Optimization under constraint Here is an incredible powerfull solution of a constrained optimization that Mathematica cannot solve without help var('A, x, y, l, alpha, beta, R, p_x, p_y'); U= A*x^(alpha)*y^(beta); show(U) D = p_x*x + p_y*y; show(D) show(U) solve(D==R, y) L = U-l*(D-R) show(L) L_x= L.diff(x) show(L_x) L_y= L.diff(y) show(L_y) L_lambda= L.diff(l) show(L_l) z=solve([L_x==0, L_y==0, L_l==0,], x, y, l)  Now I have two questions in one : I would use greek lambda in place of l ? I would retreive the values of x and y to put it in U ? I have tried some solutions as z[0 : 1 :...] but it doesnt work ? How can I do it ? 2019-09-12 14:26:56 -0500 commented answer installing sage-8.8-Ubuntu_18.04-x86_64.tar.bz2 The thing is that Sage is still using Python2.7 while most disto moved to Python 3 by default. Soon, Sage will be Python 3, but meanwhile, you have to install Python 2.7 from the distro. Don't worry, your distro supports having both Python installed at the same time. 2019-09-12 10:18:47 -0500 commented answer installing sage-8.8-Ubuntu_18.04-x86_64.tar.bz2 Indeed ! It has been a very long time that i did not install Sage from binaries, but you might also have to install gfortran and openssl, let us see with further errors. 2019-09-12 07:39:40 -0500 commented answer installing sage-8.8-Ubuntu_18.04-x86_64.tar.bz2 Don't give up, you are not so far, you should type ./sage not sage (see the dot and the slash), because your SageMath directory is not in your path. 2019-09-12 04:15:36 -0500 commented answer installing sage-8.8-Ubuntu_18.04-x86_64.tar.bz2 Yes you can, it is really up to you as long as you do not do that as root, but I would suggest to unpack the tarball in a dedicated directory, like "~/sage".or whatever Note that once you unpack and run ./sage from that directory, you can not move it anymore since some paths are hardcoded, so if you want to move the Sage directory, you should re-unpack it. 2019-09-12 04:15:17 -0500 received badge ● Nice Answer (source) 2019-09-11 18:31:42 -0500 answered a question installing sage-8.8-Ubuntu_18.04-x86_64.tar.bz2 You seem to be doing contractictoty things: when you write tar -xjf *.tar.bz2, you seem to be willing to install Sage from some binaries downloaded from Sage website. when you write apt install sagemath-common, you seem to be willing to install Sage from Ubuntu repositories, but then you should install sagemath-jupyter, because sagemath-common only ships some file that are common to all arcitectures (in particular, it does not provide compiled files, which are required). Which Sage do you want to install ? If you want to install six, you should do that as a normal user, with the command pip install --user six. In the example you gave, you are running the pip command as root, wich is not advised, and which probably explains the error messages you get. 2019-09-10 15:33:58 -0500 received badge ● Nice Answer (source) 2019-09-10 13:06:06 -0500 commented answer Substitution of free variable Yes, but you might have to do some assumption on their order i guess. 2019-09-10 12:39:35 -0500 answered a question Substitution of free variable If you are sure that there is only one free variable, then you can easily identify it. First, use solution_dict option to deal with the result more easily: sage: sol1 = solve([x+y==1], x, y, solution_dict=True) sage: sol1 [{y: r3, x: -r3 + 1}]  Now, you can ask for the variables appearing in a symbolic expression, see: sage: sol1[0][x] -r3 + 1 sage: sol1[0][x].variables()[0]  So, you can give it a Python name and use it afterwards: sage: freevar = sol1[0][x].variables()[0] sage: expr = sol1[0][x] sage: expr -r3 + 1 sage: expr.subs({freevar:10}) -9  2019-09-10 09:34:16 -0500 answered a question Wehre can i download maxima? I am not sure how it is related so Sage, but the download URL is http://maxima.sourceforge.net/downloa... That said, maxima is shipped with Sage, so if you want to run it without a dedicated download, you can do: sage -maxima  2019-09-10 06:58:49 -0500 answered a question How to re-use value from interact? You can try with global variables, something like: Cell 1 a = 3  Cell 2 @interact(n=a) def square(n): global a1 print("{} squared is {}".format(n, n*n)) a1 = n  Cell 3 a1