Ticket #9394: trac_9394-leading_minus.patch

File trac_9394-leading_minus.patch, 5.3 KB (added by burcin, 9 years ago)
  • 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 b  
    1212212122              "-1/2" [label=" ", texlbl="$-\frac{1}{2}$"];
    1212312123              "-1" [label=" ", texlbl="$-1$"];
    1212412124            <BLANKLINE>
    12125               "1/2" -> "-2" [label=" ", texlbl="$x \ {\mapsto}\ \frac{-1}{x}$"];
     12125              "1/2" -> "-2" [label=" ", texlbl="$x \ {\mapsto}\ -\frac{1}{x}$"];
    1212612126              "1/2" -> "2/3" [label=" ", texlbl="$x \ {\mapsto}\ \frac{1}{x + 1}$"];
    12127               "1" -> "-1" [label=" ", texlbl="$x \ {\mapsto}\ \frac{-1}{x}$"];
     12127              "1" -> "-1" [label=" ", texlbl="$x \ {\mapsto}\ -\frac{1}{x}$"];
    1212812128              "1" -> "1/2" [label=" ", texlbl="$x \ {\mapsto}\ \frac{1}{x + 1}$"];
    12129               "1/4" -> "-4" [label=" ", texlbl="$x \ {\mapsto}\ \frac{-1}{x}$"];
     12129              "1/4" -> "-4" [label=" ", texlbl="$x \ {\mapsto}\ -\frac{1}{x}$"];
    1213012130              "1/4" -> "4/5" [label=" ", texlbl="$x \ {\mapsto}\ \frac{1}{x + 1}$"];
    12131               "2" -> "-1/2" [label=" ", texlbl="$x \ {\mapsto}\ \frac{-1}{x}$"];
     12131              "2" -> "-1/2" [label=" ", texlbl="$x \ {\mapsto}\ -\frac{1}{x}$"];
    1213212132              "2" -> "1/3" [label=" ", texlbl="$x \ {\mapsto}\ \frac{1}{x + 1}$"];
    1213312133            }
    1213412134
  • sage/rings/polynomial/polynomial_element.pyx

    diff --git a/sage/rings/polynomial/polynomial_element.pyx b/sage/rings/polynomial/polynomial_element.pyx
    a b  
    41754175       
    41764176            sage: X = var('X')
    41774177            sage: f = expand((X-1)*(X-I)^3*(X^2 - sqrt(2))); f
    4178             -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
     4178            -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
    41794179            sage: print f.roots()
    41804180            [(I, 3), (-2^(1/4), 1), (2^(1/4), 1), (1, 1)]
    41814181       
  • sage/symbolic/expression.pyx

    diff --git a/sage/symbolic/expression.pyx b/sage/symbolic/expression.pyx
    a b  
    404404        Check if #7876 is fixed::
    405405
    406406            sage: (1/2-1/2*I )*sqrt(2)
    407             (-1/2*I + 1/2)*sqrt(2)
     407            -(1/2*I - 1/2)*sqrt(2)
    408408            sage: latex((1/2-1/2*I )*sqrt(2))
    409             \left(-\frac{1}{2} i + \frac{1}{2}\right) \, \sqrt{2}
     409            -\left(\frac{1}{2} i - \frac{1}{2}\right) \, \sqrt{2}
    410410        """
    411411        return self._parent._repr_element_(self)
    412412
     
    600600        Check that the sign is correct (#9086)::
    601601
    602602            sage: latex(-1/x)
    603             \frac{-1}{x}
     603            -\frac{1}{x}
    604604            sage: latex(1/-x)
    605             \frac{-1}{x}
     605            -\frac{1}{x}
    606606
    607607        More tests for the sign (#9314)::
    608608
    609609            sage: latex(-2/x)
    610             \frac{-2}{x}
     610            -\frac{2}{x}
    611611            sage: latex(-x/y)
    612             \frac{-x}{y}
     612            -\frac{x}{y}
    613613            sage: latex(-x*z/y)
    614             \frac{-x z}{y}
     614            -\frac{x z}{y}
    615615            sage: latex(-x/z/y)
    616             \frac{-x}{y z}
     616            -\frac{x}{y z}
     617
     618        Check if #9394 is fixed::
     619
     620            sage: var('n')
     621            n
     622            sage: latex( e^(2*I*pi*n*x - 2*I*pi*n) )
     623            e^{\left(2 i \, \pi n x - 2 i \, \pi n\right)}
     624            sage: latex( e^(2*I*pi*n*x - (2*I+1)*pi*n) )
     625            e^{\left(2 i \, \pi n x - \left(2 i + 1\right) \, \pi n\right)}
     626            sage: x+(1-2*I)*y
     627            x - (2*I - 1)*y
     628            sage: latex(x+(1-2*I)*y)
     629            x - \left(2 i - 1\right) \, y
    617630        """
    618631        return self._parent._latex_element_(self)
    619632
  • sage/symbolic/random_tests.py

    diff --git a/sage/symbolic/random_tests.py b/sage/symbolic/random_tests.py
    a b  
    235235        sage: from sage.symbolic.random_tests import *
    236236        sage: set_random_seed(2)
    237237        sage: random_expr(50, nvars=3, coeff_generator=CDF.random_element)
    238         (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)
     238        (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)
    239239        sage: random_expr(5, verbose=True)
    240240        About to apply dirac_delta to [1]
    241241        About to apply arccsch to [0]