2020-12-27 12:33:16 +0200 received badge ● Famous Question (source) 2020-12-22 09:00:37 +0200 received badge ● Notable Question (source) 2020-02-23 03:44:59 +0200 commented answer Running VIM inside Sage Shell When I type %edit then 1+1 in vim (which is the editor of my system) and exit, it emits '1+1/n' which is not executed by SAGE. Any help? 2019-12-06 20:15:29 +0200 received badge ● Good Question (source) 2019-10-29 04:08:29 +0200 received badge ● Nice Question (source) 2019-06-26 17:42:20 +0200 received badge ● Popular Question (source) 2019-01-08 05:04:35 +0200 received badge ● Self-Learner (source) 2019-01-08 05:04:35 +0200 received badge ● Teacher (source) 2019-01-08 01:20:15 +0200 answered a question How to display complex numbers with real part before imaginary part? Well after using the code a couple days, I modified it again and here is a better version. E.g. now 2+(1-sqrt(3))i is typeset as shown v.s. as 2+i+sqrt(3)i in the previous version.  def cpx(z): r""" Return a LaTeX string for this complex number. EXAMPLE:: sage: latex_of_complex(0) 0 sage: latex_of_complex(2) 2 sage: latex_of_complex(4*i) 4 \mathbf{i} sage: latex_of_complex(7 + 8*i) 7 + 8 \mathbf{i} """ if z == 0: return LatexExpr('0') re = z.real().simplify() im = z.imag().simplify() if (re == 0) or (im==0) : return LatexExpr(latex(z).replace('i',r'\mathbf{i}')) elif im > 0: s = '+' else: s = '-' rel = latex(re) iml = latex(abs(im)) if rel.find('+') >= 1 or rel.find('-') >=1: repl = r'\left('+rel+r'\right)' else: repl = rel if iml.find('+') >=1 or iml.find('-') >=1: impl = r'\left('+iml+r'\right)'+r'\mathbf{i}' else: impl = iml+r'\mathbf{i}' if abs(im) ==1: return LatexExpr(repl + s + r'\mathbf{i}') return LatexExpr(repl + s + impl)  2019-01-05 17:53:33 +0200 received badge ● Editor (source) 2019-01-05 08:10:41 +0200 received badge ● Supporter (source) 2019-01-05 08:10:14 +0200 received badge ● Scholar (source) 2019-01-05 08:09:12 +0200 commented answer How to display complex numbers with real part before imaginary part? Thanks. It does what I want! Perhaps, sage should have a built-in function for that task. The codes above typeset a-bi as a+ -bi. but just a minor modification fixes that:  def cpx(z): if z == 0: return LatexExpr('0') a = z.real() b = z.imag() if (a == 0) or (b==0) : return LatexExpr(latex(z).replace('i',r'\mathbf{i}')) elif b > 0: s = '+' else: s = '-' return latex(a) + LatexExpr(s) + latex(abs(b) * i).replace('i', r'\mathbf{i}')   2019-01-04 19:53:29 +0200 received badge ● Student (source) 2019-01-04 18:17:42 +0200 commented answer How to display complex numbers with real part before imaginary part? Thanks, Well, what I want is to make some homework and use sage (sagetex) to do the computations. Now I realize a bigger problem is that sage displays imaginary part in front of the real part. E.g. latex(7+8i) returns 8i + 7. I understand this is a different question but can I get some help here? 2019-01-04 16:39:35 +0200 asked a question How to display complex numbers with real part before imaginary part? Also I would like to have latex(I) output \mathbf{i} instead of just i. Is there a way to do so? 2016-06-26 16:18:25 +0200 commented answer sage automatically expanding polynomial But looks like sage will still expand e.g. 5(2x -7) into 10*x - 35. How to keep it in the original form?