• ## sage/graphs/generic_graph.py

# HG changeset patch
# User Burcin Erocal <burcin@erocal.org>
# Date 1284018066 -7200
# Node ID 076f0585ee952f6c8aaf845ee4a9bda7e6d6608f
# Parent  a031f5c783ff2e534ce3f57425795e2d06c4a15f
#9394: Make the latex typesetting for symbolic expressions containing rational functions with a negative overall coefficient prettier. The minus sign is printed before the \frac now.

diff --git a/sage/graphs/generic_graph.py b/sage/graphs/generic_graph.py
 a "-1/2" [label=" ", texlbl="$-\frac{1}{2}$"]; "-1" [label=" ", texlbl="$-1$"]; "1/2" -> "-2" [label=" ", texlbl="$x \ {\mapsto}\ \frac{-1}{x}$"]; "1/2" -> "-2" [label=" ", texlbl="$x \ {\mapsto}\ -\frac{1}{x}$"]; "1/2" -> "2/3" [label=" ", texlbl="$x \ {\mapsto}\ \frac{1}{x + 1}$"]; "1" -> "-1" [label=" ", texlbl="$x \ {\mapsto}\ \frac{-1}{x}$"]; "1" -> "-1" [label=" ", texlbl="$x \ {\mapsto}\ -\frac{1}{x}$"]; "1" -> "1/2" [label=" ", texlbl="$x \ {\mapsto}\ \frac{1}{x + 1}$"]; "1/4" -> "-4" [label=" ", texlbl="$x \ {\mapsto}\ \frac{-1}{x}$"]; "1/4" -> "-4" [label=" ", texlbl="$x \ {\mapsto}\ -\frac{1}{x}$"]; "1/4" -> "4/5" [label=" ", texlbl="$x \ {\mapsto}\ \frac{1}{x + 1}$"]; "2" -> "-1/2" [label=" ", texlbl="$x \ {\mapsto}\ \frac{-1}{x}$"]; "2" -> "-1/2" [label=" ", texlbl="$x \ {\mapsto}\ -\frac{1}{x}$"]; "2" -> "1/3" [label=" ", texlbl="$x \ {\mapsto}\ \frac{1}{x + 1}$"]; }
• ## sage/rings/polynomial/polynomial_element.pyx

diff --git a/sage/rings/polynomial/polynomial_element.pyx b/sage/rings/polynomial/polynomial_element.pyx
 a sage: X = var('X') sage: f = expand((X-1)*(X-I)^3*(X^2 - sqrt(2))); f -sqrt(2)*X^4 + I*sqrt(2) + X^6 + (-3*I - 1)*X^5 + (3*I - 3)*X^4 + (3*I + 1)*sqrt(2)*X^3 + (I + 3)*X^3 + (-3*I + 3)*sqrt(2)*X^2 - I*X^2 + (-I - 3)*sqrt(2)*X -sqrt(2)*X^4 + I*sqrt(2) + X^6 - (3*I + 1)*X^5 + (3*I - 3)*X^4 + (3*I + 1)*sqrt(2)*X^3 + (I + 3)*X^3 - (3*I - 3)*sqrt(2)*X^2 - I*X^2 - (I + 3)*sqrt(2)*X sage: print f.roots() [(I, 3), (-2^(1/4), 1), (2^(1/4), 1), (1, 1)]
• ## sage/symbolic/expression.pyx

diff --git a/sage/symbolic/expression.pyx b/sage/symbolic/expression.pyx
 a Check if #7876 is fixed:: sage: (1/2-1/2*I )*sqrt(2) (-1/2*I + 1/2)*sqrt(2) -(1/2*I - 1/2)*sqrt(2) sage: latex((1/2-1/2*I )*sqrt(2)) \left(-\frac{1}{2} i + \frac{1}{2}\right) \, \sqrt{2} -\left(\frac{1}{2} i - \frac{1}{2}\right) \, \sqrt{2} """ return self._parent._repr_element_(self) Check that the sign is correct (#9086):: sage: latex(-1/x) \frac{-1}{x} -\frac{1}{x} sage: latex(1/-x) \frac{-1}{x} -\frac{1}{x} More tests for the sign (#9314):: sage: latex(-2/x) \frac{-2}{x} -\frac{2}{x} sage: latex(-x/y) \frac{-x}{y} -\frac{x}{y} sage: latex(-x*z/y) \frac{-x z}{y} -\frac{x z}{y} sage: latex(-x/z/y) \frac{-x}{y z} -\frac{x}{y z} Check if #9394 is fixed:: sage: var('n') n sage: latex( e^(2*I*pi*n*x - 2*I*pi*n) ) e^{\left(2 i \, \pi n x - 2 i \, \pi n\right)} sage: latex( e^(2*I*pi*n*x - (2*I+1)*pi*n) ) e^{\left(2 i \, \pi n x - \left(2 i + 1\right) \, \pi n\right)} sage: x+(1-2*I)*y x - (2*I - 1)*y sage: latex(x+(1-2*I)*y) x - \left(2 i - 1\right) \, y """ return self._parent._latex_element_(self)
• ## sage/symbolic/random_tests.py

diff --git a/sage/symbolic/random_tests.py b/sage/symbolic/random_tests.py
 a sage: from sage.symbolic.random_tests import * sage: set_random_seed(2) sage: random_expr(50, nvars=3, coeff_generator=CDF.random_element) (euler_gamma - v3^(-e) + (v2 - factorial(-e/v2))^(((2.85879036573 - 1.18163393202*I)*v2 + (2.85879036573 - 1.18163393202*I)*v3)*pi - 0.247786879678 + 0.931826724898*I)*arccsc((0.891138386848 - 0.0936820840629*I)/v1) + (-0.553423153995 + 0.5481180572*I)*v3 + 0.149683576515 - 0.155746451854*I)*v1 + arccsch(pi + e)*elliptic_f(khinchin*v2, 1.4656989704 + 0.863754357069*I) (euler_gamma - v3^(-e) + (v2 - factorial(-e/v2))^(((2.85879036573 - 1.18163393202*I)*v2 + (2.85879036573 - 1.18163393202*I)*v3)*pi - 0.247786879678 + 0.931826724898*I)*arccsc((0.891138386848 - 0.0936820840629*I)/v1) - (0.553423153995 - 0.5481180572*I)*v3 + 0.149683576515 - 0.155746451854*I)*v1 + arccsch(pi + e)*elliptic_f(khinchin*v2, 1.4656989704 + 0.863754357069*I) sage: random_expr(5, verbose=True) About to apply dirac_delta to [1] About to apply arccsch to [0]