Ticket #9880: trac_9880-fix_doctests-sage_5_10_beta2.take2.patch

File trac_9880-fix_doctests-sage_5_10_beta2.take2.patch, 135.0 KB (added by burcin, 7 years ago)
  • doc/de/tutorial/introduction.rst

    # HG changeset patch
    # User Burcin Erocal <burcin@erocal.org>
    # Date 1369307548 -7200
    # Node ID 7e3021979ca35362c973e8c2f3fa26920845b040
    # Parent  482d99a53023ad1fd6d90f847e09b26606025cd2
    Trac #9880: Fix doctests after order changes in Pynac.
    
    diff --git a/doc/de/tutorial/introduction.rst b/doc/de/tutorial/introduction.rst
    a b  
    4848    1
    4949
    5050    sage: k = 1/(sqrt(3)*I + 3/4 + sqrt(73)*5/9); k
    51     1/(I*sqrt(3) + 5/9*sqrt(73) + 3/4)
     51    36/(20*sqrt(73) + 36*I*sqrt(3) + 27)
    5252    sage: N(k)
    5353    0.165495678130644 - 0.0521492082074256*I
    5454    sage: N(k,30)      # 30 "bits"
    5555    0.16549568 - 0.052149208*I
    5656    sage: latex(k)
    57     \frac{1}{i \, \sqrt{3} + \frac{5}{9} \, \sqrt{73} + \frac{3}{4}}
     57    \frac{36}{20 \, \sqrt{73} + 36 i \, \sqrt{3} + 27}
    5858
    5959.. _installation:
    6060
  • doc/de/tutorial/tour_algebra.rst

    diff --git a/doc/de/tutorial/tour_algebra.rst b/doc/de/tutorial/tour_algebra.rst
    a b  
    5454    sage: eq2 = q*y+p*x==-6
    5555    sage: eq3 = q*y^2+p*x^2==24
    5656    sage: solve([eq1,eq2,eq3,p==1],p,q,x,y)
    57     [[p == 1, q == 8, x == -4/3*sqrt(10) - 2/3, y == 1/6*sqrt(2)*sqrt(5) - 2/3],
    58      [p == 1, q == 8, x == 4/3*sqrt(10) - 2/3, y == -1/6*sqrt(2)*sqrt(5) - 2/3]]
     57    [[p == 1, q == 8, x == -4/3*sqrt(10) - 2/3, y == 1/6*sqrt(5)*sqrt(2) - 2/3],
     58     [p == 1, q == 8, x == 4/3*sqrt(10) - 2/3, y == -1/6*sqrt(5)*sqrt(2) - 2/3]]
    5959
    6060Um eine numerische Approximation der Lösungen zu erhalten können Sie
    6161stattdessen wie folgt vorgehen:
     
    140140
    141141    sage: f = 1/((1+x)*(x-1))
    142142    sage: f.partial_fraction(x)
    143     1/2/(x - 1) - 1/2/(x + 1)
     143    -1/2/(x + 1) + 1/2/(x - 1)
    144144
    145145.. _section-systems:
    146146
     
    173173    sage: t = var("t")
    174174    sage: f = t^2*exp(t) - sin(t)
    175175    sage: f.laplace(t,s)
    176     2/(s - 1)^3 - 1/(s^2 + 1)
     176    -1/(s^2 + 1) + 2/(s - 1)^3
    177177
    178178Hier ist ein komplizierteres Beispiel. Die Verschiebung des
    179179Gleichgewichts einer verkoppelten Feder, die an der linken Wand
  • doc/en/a_tour_of_sage/index.rst

    diff --git a/doc/en/a_tour_of_sage/index.rst b/doc/en/a_tour_of_sage/index.rst
    a b  
    4040
    4141    sage: x = var('x')   # create a symbolic variable
    4242    sage: integrate(sqrt(x)*sqrt(1+x), x)
    43     1/4*((x + 1)^(3/2)/x^(3/2) + sqrt(x + 1)/sqrt(x))/((x + 1)^2/x^2 - 2*(x + 1)/x + 1) + 1/8*log(sqrt(x + 1)/sqrt(x) - 1) - 1/8*log(sqrt(x + 1)/sqrt(x) + 1)
     43    1/4*((x + 1)^(3/2)/x^(3/2) + sqrt(x + 1)/sqrt(x))/((x + 1)^2/x^2 - 2*(x + 1)/x + 1) - 1/8*log(sqrt(x + 1)/sqrt(x) + 1) + 1/8*log(sqrt(x + 1)/sqrt(x) - 1)
    4444
    4545This asks Sage to solve a quadratic equation. The symbol ``==``
    4646represents equality in Sage.
  • doc/en/constructions/calculus.rst

    diff --git a/doc/en/constructions/calculus.rst b/doc/en/constructions/calculus.rst
    a b  
    2525    sage: f = x^3 * e^(k*x) * sin(w*x); f
    2626    x^3*e^(k*x)*sin(w*x)
    2727    sage: f.diff(x)
    28     k*x^3*e^(k*x)*sin(w*x) + w*x^3*e^(k*x)*cos(w*x) + 3*x^2*e^(k*x)*sin(w*x)
     28    w*x^3*cos(w*x)*e^(k*x) + k*x^3*e^(k*x)*sin(w*x) + 3*x^2*e^(k*x)*sin(w*x)
    2929    sage: latex(f.diff(x))
    30     k x^{3} e^{\left(k x\right)} \sin\left(w x\right) + w x^{3} e^{\left(k x\right)} \cos\left(w x\right) + 3 \, x^{2} e^{\left(k x\right)} \sin\left(w x\right)
     30    w x^{3} \cos\left(w x\right) e^{\left(k x\right)} + k x^{3} e^{\left(k x\right)} \sin\left(w x\right) + 3 \, x^{2} e^{\left(k x\right)} \sin\left(w x\right)
    3131
    3232If you type ``view(f.diff(x))`` another window will open up
    3333displaying the compiled output. In the notebook, you can enter
     
    147147    (x, k, w)
    148148    sage: f = x^3 * e^(k*x) * sin(w*x)
    149149    sage: f.integrate(x)
    150     -(((k^6*w + 3*k^4*w^3 + 3*k^2*w^5 + w^7)*x^3 - 24*k^3*w + 24*k*w^3 - 6*(k^5*w + 2*k^3*w^3 + k*w^5)*x^2 + 6*(3*k^4*w + 2*k^2*w^3 - w^5)*x)*e^(k*x)*cos(w*x) - ((k^7 + 3*k^5*w^2 + 3*k^3*w^4 + k*w^6)*x^3 - 6*k^4 + 36*k^2*w^2 - 6*w^4 - 3*(k^6 + k^4*w^2 - k^2*w^4 - w^6)*x^2 + 6*(k^5 - 2*k^3*w^2 - 3*k*w^4)*x)*e^(k*x)*sin(w*x))/(k^8 + 4*k^6*w^2 + 6*k^4*w^4 + 4*k^2*w^6 + w^8)
     150    ((24*k^3*w - 24*k*w^3 - (k^6*w + 3*k^4*w^3 + 3*k^2*w^5 + w^7)*x^3 + 6*(k^5*w + 2*k^3*w^3 + k*w^5)*x^2 - 6*(3*k^4*w + 2*k^2*w^3 - w^5)*x)*cos(w*x)*e^(k*x) - (6*k^4 - 36*k^2*w^2 + 6*w^4 - (k^7 + 3*k^5*w^2 + 3*k^3*w^4 + k*w^6)*x^3 + 3*(k^6 + k^4*w^2 - k^2*w^4 - w^6)*x^2 - 6*(k^5 - 2*k^3*w^2 - 3*k*w^4)*x)*e^(k*x)*sin(w*x))/(k^8 + 4*k^6*w^2 + 6*k^4*w^4 + 4*k^2*w^6 + w^8)
    151151    sage: integrate(1/x^2, x, 1, infinity)
    152152    1
    153153
     
    232232    sage: f2(x) = 1-x
    233233    sage: f = Piecewise([[(0,1),f1],[(1,2),f2]])
    234234    sage: f.laplace(x, s)
    235     (s + 1)*e^(-2*s)/s^2 - e^(-s)/s + 1/s - e^(-s)/s^2
     235    -e^(-s)/s + (s + 1)*e^(-2*s)/s^2 + 1/s - e^(-s)/s^2
    236236
    237237For other "reasonable" functions, Laplace transforms can be
    238238computed using the Maxima interface:
     
    283283    sage: y=function('y',x); desolve(diff(y,x,2) + 3*x == y, dvar = y, ics = [1,1,1])
    284284    3*x - 2*e^(x - 1)
    285285    sage: desolve(diff(y,x,2) + 3*x == y, dvar = y)
    286     k1*e^x + k2*e^(-x) + 3*x
     286    k2*e^(-x) + k1*e^x + 3*x
    287287    sage: desolve(diff(y,x) + 3*x == y, dvar = y)
    288288    (3*(x + 1)*e^(-x) + c)*e^x
    289289    sage: desolve(diff(y,x) + 3*x == y, dvar = y, ics = [1,1]).expand()
     
    375375    sage: f.fourier_series_sine_coefficient(2,pi)
    376376    -3/pi
    377377    sage: f.fourier_series_partial_sum(3,pi)
    378     -3*sin(2*x)/pi + sin(x)/pi - 3*cos(x)/pi + 1/4
     378    -3*cos(x)/pi - 3*sin(2*x)/pi + sin(x)/pi + 1/4
    379379
    380380Type ``show(f.plot_fourier_series_partial_sum(15,pi,-5,5))`` and
    381381``show(f.plot_fourier_series_partial_sum_cesaro(15,pi,-5,5))``
  • doc/en/constructions/polynomials.rst

    diff --git a/doc/en/constructions/polynomials.rst b/doc/en/constructions/polynomials.rst
    a b  
    259259    sage: g = f.subs(x = 5/z); g
    260260    (3*y + 25*y/z^2 + 5/z)^3
    261261    sage: h = g.rational_simplify(); h
    262     (27*y^3*z^6 + 135*y^2*z^5 + 225*(3*y^3 + y)*z^4 + 125*(18*y^2 + 1)*z^3 + 
    263     1875*(3*y^3 + y)*z^2 + 15625*y^3 + 9375*y^2*z)/z^6
     262    (27*y^3*z^6 + 135*y^2*z^5 + 225*(3*y^3 + y)*z^4 + 125*(18*y^2 + 1)*z^3 +
     263    15625*y^3 + 9375*y^2*z + 1875*(3*y^3 + y)*z^2)/z^6
    264264
    265265Roots of multivariate polynomials
    266266=================================
  • doc/en/prep/Advanced-2DPlotting.rst

    diff --git a/doc/en/prep/Advanced-2DPlotting.rst b/doc/en/prep/Advanced-2DPlotting.rst
    a b  
    312312    sage: fibonacci
    313313    [(0, 0), (1, 1), (2, 1), (3, 2), (4, 3), (5, 5)]
    314314    sage: asymptotic
    315     [(0, 1/5*sqrt(5)), (1, 1/10*(sqrt(5) + 1)*sqrt(5)), (2, 1/20*(sqrt(5) + 1)^2*sqrt(5)), (3, 1/40*(sqrt(5) + 1)^3*sqrt(5)), (4, 1/80*(sqrt(5) + 1)^4*sqrt(5)), (5, 1/160*(sqrt(5) + 1)^5*sqrt(5))]
     315    [(0, 1/5*sqrt(5)), (1, 1/10*sqrt(5)*(sqrt(5) + 1)), (2, 1/20*sqrt(5)*(sqrt(5) + 1)^2), (3, 1/40*sqrt(5)*(sqrt(5) + 1)^3), (4, 1/80*sqrt(5)*(sqrt(5) + 1)^4), (5, 1/160*sqrt(5)*(sqrt(5) + 1)^5)]
    316316
    317317Now we can plot not just the two sets of points, but also use several of
    318318the documented options for plotting points. Those coming from other
  • doc/en/prep/Calculus.rst

    diff --git a/doc/en/prep/Calculus.rst b/doc/en/prep/Calculus.rst
    a b  
    136136::
    137137
    138138    sage: derivative(sinh(x^2+sqrt(x-1)),x)
    139     1/2*(4*x + 1/sqrt(x - 1))*cosh(sqrt(x - 1) + x^2)
     139    1/2*(4*x + 1/sqrt(x - 1))*cosh(x^2 + sqrt(x - 1))
    140140
    141141And maybe even knows those you don't want.  In this case, we put the
    142142computation inside ``show()`` since the output is so long.
     
    290290
    291291    sage: h(x)=sec(x)
    292292    sage: h.integrate(x)
    293     x |--> log(tan(x) + sec(x))
     293    x |--> log(sec(x) + tan(x))
    294294
    295295Since I defined ``h`` as a function, the answer I get is also a
    296296function.  If I just want an expression as the answer, I can do the
     
    299299::
    300300
    301301    sage: integrate(sec(x),x)
    302     log(tan(x) + sec(x))
     302    log(sec(x) + tan(x))
    303303
    304304Here is another (longer) example.  Do you remember what command would
    305305help it look nicer in the browser?
     
    307307::
    308308
    309309    sage: integrate(1/(1+x^5),x)
    310     1/5*(sqrt(5) - 1)*sqrt(5)*arctan((4*x - sqrt(5) - 1)/sqrt(-2*sqrt(5) + 10))/sqrt(-2*sqrt(5) + 10) + 1/5*(sqrt(5) + 1)*sqrt(5)*arctan((4*x + sqrt(5) - 1)/sqrt(2*sqrt(5) + 10))/sqrt(2*sqrt(5) + 10) - 1/2*(sqrt(5) - 3)*log((sqrt(5) - 1)*x + 2*x^2 + 2)/(5*sqrt(5) - 5) - 1/2*(sqrt(5) + 3)*log(-(sqrt(5) + 1)*x + 2*x^2 + 2)/(5*sqrt(5) + 5) + 1/5*log(x + 1)
     310    1/5*sqrt(5)*(sqrt(5) + 1)*arctan((4*x + sqrt(5) - 1)/sqrt(2*sqrt(5) + 10))/sqrt(2*sqrt(5) + 10) + 1/5*sqrt(5)*(sqrt(5) - 1)*arctan((4*x - sqrt(5) - 1)/sqrt(-2*sqrt(5) + 10))/sqrt(-2*sqrt(5) + 10) - 1/2*(sqrt(5) + 3)*log(2*x^2 - x*(sqrt(5) + 1) + 2)/(5*sqrt(5) + 5) - 1/2*(sqrt(5) - 3)*log(2*x^2 + x*(sqrt(5) - 1) + 2)/(5*sqrt(5) - 5) + 1/5*log(x + 1)
    311311
    312312Some integrals are a little tricky, of course.  If Sage doesn't know the
    313313whole antiderivative, it returns as much of it as it (more properly, as
     
    392392::
    393393
    394394    sage: integral(h,(x,0,pi/8))
    395     -1/2*log(-sin(1/8*pi) + 1) + 1/2*log(sin(1/8*pi) + 1)
     395    1/2*log(sin(1/8*pi) + 1) - 1/2*log(-sin(1/8*pi) + 1)
    396396
    397397Here, just a number might be more helpful.  Sage has several ways of
    398398numerical evaluating integrals.
  • doc/en/thematic_tutorials/tutorial-comprehensions.rst

    diff --git a/doc/en/thematic_tutorials/tutorial-comprehensions.rst b/doc/en/thematic_tutorials/tutorial-comprehensions.rst
    a b  
    322322    x^3 + 2*x^2 + 2*x + 1
    323323
    324324    sage: factor(sum( x^p.length() for p in Permutations(3) ))
    325     (x + 1)*(x^2 + x + 1)
     325    (x^2 + x + 1)*(x + 1)
    326326
    327327    sage: P = Permutations(5)
    328328    sage: all( p in P for p in P )
  • doc/en/tutorial/introduction.rst

    diff --git a/doc/en/tutorial/introduction.rst b/doc/en/tutorial/introduction.rst
    a b  
    4646    1
    4747
    4848    sage: k = 1/(sqrt(3)*I + 3/4 + sqrt(73)*5/9); k
    49     1/(I*sqrt(3) + 5/9*sqrt(73) + 3/4)
     49    36/(20*sqrt(73) + 36*I*sqrt(3) + 27)
    5050    sage: N(k)
    5151    0.165495678130644 - 0.0521492082074256*I
    5252    sage: N(k,30)      # 30 "bits"
    5353    0.16549568 - 0.052149208*I
    5454    sage: latex(k)
    55     \frac{1}{i \, \sqrt{3} + \frac{5}{9} \, \sqrt{73} + \frac{3}{4}}
     55    \frac{36}{20 \, \sqrt{73} + 36 i \, \sqrt{3} + 27}
    5656
    5757.. _installation:
    5858
  • doc/en/tutorial/tour_algebra.rst

    diff --git a/doc/en/tutorial/tour_algebra.rst b/doc/en/tutorial/tour_algebra.rst
    a b  
    5252    sage: eq2 = q*y+p*x==-6
    5353    sage: eq3 = q*y^2+p*x^2==24
    5454    sage: solve([eq1,eq2,eq3,p==1],p,q,x,y)
    55     [[p == 1, q == 8, x == -4/3*sqrt(10) - 2/3, y == 1/6*sqrt(2)*sqrt(5) - 2/3],
    56      [p == 1, q == 8, x == 4/3*sqrt(10) - 2/3, y == -1/6*sqrt(2)*sqrt(5) - 2/3]]
     55    [[p == 1, q == 8, x == -4/3*sqrt(10) - 2/3, y == 1/6*sqrt(5)*sqrt(2) - 2/3],
     56     [p == 1, q == 8, x == 4/3*sqrt(10) - 2/3, y == -1/6*sqrt(5)*sqrt(2) - 2/3]]
    5757
    5858For numerical approximations of the solutions, you can instead use:
    5959
     
    138138
    139139    sage: f = 1/((1+x)*(x-1))
    140140    sage: f.partial_fraction(x)
    141     1/2/(x - 1) - 1/2/(x + 1)
     141    -1/2/(x + 1) + 1/2/(x - 1)
    142142
    143143.. _section-systems:
    144144
     
    170170    sage: t = var("t")
    171171    sage: f = t^2*exp(t) - sin(t)
    172172    sage: f.laplace(t,s)
    173     2/(s - 1)^3 - 1/(s^2 + 1)
     173    -1/(s^2 + 1) + 2/(s - 1)^3
    174174
    175175Here is a more involved example. The displacement from equilibrium
    176176(respectively) for a coupled spring attached to a wall on the left
  • doc/fr/a_tour_of_sage/index.rst

    diff --git a/doc/fr/a_tour_of_sage/index.rst b/doc/fr/a_tour_of_sage/index.rst
    a b  
    4343
    4444    sage: x = var('x')   # Créer une variable symbolique
    4545    sage: integrate(sqrt(x)*sqrt(1+x), x)
    46     1/4*((x + 1)^(3/2)/x^(3/2) + sqrt(x + 1)/sqrt(x))/((x + 1)^2/x^2 - 2*(x + 1)/x + 1) + 1/8*log(sqrt(x + 1)/sqrt(x) - 1) - 1/8*log(sqrt(x + 1)/sqrt(x) + 1)
     46    1/4*((x + 1)^(3/2)/x^(3/2) + sqrt(x + 1)/sqrt(x))/((x + 1)^2/x^2 - 2*(x + 1)/x + 1) - 1/8*log(sqrt(x + 1)/sqrt(x) + 1) + 1/8*log(sqrt(x + 1)/sqrt(x) - 1)
    4747
    4848Ceci permet de demander à Sage de résoudre une équation
    4949quadratique. Le symbole ``==`` représente l'égalité sous Sage.
     
    140140================================
    141141
    142142Quand vous utilisez Sage, vous avez accès à l'une des plus grandes
    143 collections Open Source d'algorithmes de calcul.
    144  No newline at end of file
     143collections Open Source d'algorithmes de calcul.
  • doc/fr/tutorial/introduction.rst

    diff --git a/doc/fr/tutorial/introduction.rst b/doc/fr/tutorial/introduction.rst
    a b  
    4747    1
    4848   
    4949    sage: k = 1/(sqrt(3)*I + 3/4 + sqrt(73)*5/9); k
    50     1/(I*sqrt(3) + 5/9*sqrt(73) + 3/4)
     50    36/(20*sqrt(73) + 36*I*sqrt(3) + 27)
    5151    sage: N(k)
    5252    0.165495678130644 - 0.0521492082074256*I
    5353    sage: N(k,30)      # 30 "bits"
    5454    0.16549568 - 0.052149208*I
    5555    sage: latex(k)
    56     \frac{1}{i \, \sqrt{3} + \frac{5}{9} \, \sqrt{73} + \frac{3}{4}}
     56    \frac{36}{20 \, \sqrt{73} + 36 i \, \sqrt{3} + 27}
    5757
    5858.. _installation:
    5959
  • doc/fr/tutorial/tour_algebra.rst

    diff --git a/doc/fr/tutorial/tour_algebra.rst b/doc/fr/tutorial/tour_algebra.rst
    a b  
    5050    sage: eq2 = q*y+p*x==-6
    5151    sage: eq3 = q*y^2+p*x^2==24
    5252    sage: solve([eq1,eq2,eq3,p==1],p,q,x,y)
    53     [[p == 1, q == 8, x == -4/3*sqrt(10) - 2/3, y == 1/6*sqrt(2)*sqrt(5) - 2/3],
    54      [p == 1, q == 8, x == 4/3*sqrt(10) - 2/3, y == -1/6*sqrt(2)*sqrt(5) - 2/3]]
     53    [[p == 1, q == 8, x == -4/3*sqrt(10) - 2/3, y == 1/6*sqrt(5)*sqrt(2) - 2/3], [p == 1, q == 8, x == 4/3*sqrt(10) - 2/3, y == -1/6*sqrt(5)*sqrt(2) - 2/3]]
    5554
    5655Pour une résolution numérique, on peut utiliser à la place :
    5756
     
    117116
    118117    sage: f = 1/((1+x)*(x-1))
    119118    sage: f.partial_fraction(x)
    120     1/2/(x - 1) - 1/2/(x + 1)
     119    -1/2/(x + 1) + 1/2/(x - 1)
    121120
    122121.. _section-systems:
    123122
     
    150149    sage: t = var("t")
    151150    sage: f = t^2*exp(t) - sin(t)
    152151    sage: f.laplace(t,s)
    153     2/(s - 1)^3 - 1/(s^2 + 1)
     152    -1/(s^2 + 1) + 2/(s - 1)^3
    154153
    155154Voici un exemple plus élaboré. L'élongation à partir du point
    156155d'équilibre de ressorts couplés attachés à gauche à un mur
  • doc/ru/tutorial/introduction.rst

    diff --git a/doc/ru/tutorial/introduction.rst b/doc/ru/tutorial/introduction.rst
    a b  
    4747    1
    4848
    4949    sage: k = 1/(sqrt(3)*I + 3/4 + sqrt(73)*5/9); k
    50     1/(I*sqrt(3) + 5/9*sqrt(73) + 3/4)
     50    36/(20*sqrt(73) + 36*I*sqrt(3) + 27)
    5151    sage: N(k)
    5252    0.165495678130644 - 0.0521492082074256*I
    5353    sage: N(k,30)      # Точность 30 бит
    5454    0.16549568 - 0.052149208*I
    5555    sage: latex(k)
    56     \frac{1}{i \, \sqrt{3} + \frac{5}{9} \, \sqrt{73} + \frac{3}{4}}
     56    \frac{36}{20 \, \sqrt{73} + 36 i \, \sqrt{3} + 27}
    5757
    5858.. _installation:
    5959
  • doc/ru/tutorial/tour_algebra.rst

    diff --git a/doc/ru/tutorial/tour_algebra.rst b/doc/ru/tutorial/tour_algebra.rst
    a b  
    4949    sage: eq2 = q*y+p*x==-6
    5050    sage: eq3 = q*y^2+p*x^2==24
    5151    sage: solve([eq1,eq2,eq3,p==1],p,q,x,y)
    52     [[p == 1, q == 8, x == -4/3*sqrt(10) - 2/3, y == 1/6*sqrt(2)*sqrt(5) - 2/3],
    53      [p == 1, q == 8, x == 4/3*sqrt(10) - 2/3, y == -1/6*sqrt(2)*sqrt(5) - 2/3]]
     52    [[p == 1, q == 8, x == -4/3*sqrt(10) - 2/3, y == 1/6*sqrt(5)*sqrt(2) - 2/3], [p == 1, q == 8, x == 4/3*sqrt(10) - 2/3, y == -1/6*sqrt(5)*sqrt(2) - 2/3]]
    5453
    5554Для приближенных значений решения можно использовать:
    5655
     
    135134
    136135    sage: f = 1/((1+x)*(x-1))
    137136    sage: f.partial_fraction(x)
    138     1/2/(x - 1) - 1/2/(x + 1)
     137    -1/2/(x + 1) + 1/2/(x - 1)
    139138
    140139.. _section-systems:
    141140
     
    167166    sage: t = var("t")
    168167    sage: f = t^2*exp(t) - sin(t)
    169168    sage: f.laplace(t,s)
    170     2/(s - 1)^3 - 1/(s^2 + 1)
     169    -1/(s^2 + 1) + 2/(s - 1)^3
    171170
    172171Приведем более сложный пример. Отклонение от положения равновесия для пары
    173172пружин, прикрепленных к стене слева,
  • doc/tr/a_tour_of_sage/index.rst

    diff --git a/doc/tr/a_tour_of_sage/index.rst b/doc/tr/a_tour_of_sage/index.rst
    a b  
    3737
    3838    sage: x = var('x')   # değişkeni sembolik olarak yaratıyoruz
    3939    sage: integrate(sqrt(x)*sqrt(1+x), x)
    40     1/4*((x + 1)^(3/2)/x^(3/2) + sqrt(x + 1)/sqrt(x))/((x + 1)^2/x^2 - 2*(x + 1)/x + 1) + 1/8*log(sqrt(x + 1)/sqrt(x) - 1) - 1/8*log(sqrt(x + 1)/sqrt(x) + 1)
     40    1/4*((x + 1)^(3/2)/x^(3/2) + sqrt(x + 1)/sqrt(x))/((x + 1)^2/x^2 - 2*(x + 1)/x + 1) - 1/8*log(sqrt(x + 1)/sqrt(x) + 1) + 1/8*log(sqrt(x + 1)/sqrt(x) - 1)
    4141
    4242Bu komut Sage'e ikinci derece denklemi çözdürür. ``==`` sembolü Sage'de eşitlik anlamına gelir.
    4343
     
    126126Sage'de Algoritmaların Kullanımı
    127127================================
    128128
    129 Sage kullanırken dünyanın en geniş açık kaynak hesaplama algoritma koleksiyonlarından biriyle çalışırsınız.
    130  No newline at end of file
     129Sage kullanırken dünyanın en geniş açık kaynak hesaplama algoritma koleksiyonlarından biriyle çalışırsınız.
  • sage/calculus/calculus.py

    diff --git a/sage/calculus/calculus.py b/sage/calculus/calculus.py
    a b  
    109109    [   (r, theta) |--> cos(theta) (r, theta) |--> -r*sin(theta)]
    110110    [   (r, theta) |--> sin(theta)  (r, theta) |--> r*cos(theta)]
    111111    sage: T.diff().det() # Jacobian
    112     (r, theta) |--> r*sin(theta)^2 + r*cos(theta)^2
     112    (r, theta) |--> r*cos(theta)^2 + r*sin(theta)^2
    113113
    114114When the order of variables is ambiguous, Sage will raise an
    115115exception when differentiating::
     
    206206::
    207207
    208208    sage: f(x,y) = log(x)*cos(y); f
    209     (x, y) |--> log(x)*cos(y)
     209    (x, y) |--> cos(y)*log(x)
    210210
    211211Then we have fixed an order of variables and there is no ambiguity
    212212substituting or evaluating::
     
    269269    sage: ComplexField(200)(sin(I))
    270270    1.1752011936438014568823818505956008151557179813340958702296*I
    271271    sage: f = sin(I) + cos(I/2); f
    272     sin(I) + cos(1/2*I)
     272    cos(1/2*I) + sin(I)
    273273    sage: CC(f)
    274274    1.12762596520638 + 1.17520119364380*I
    275275    sage: ComplexField(200)(f)
     
    370370Check that the problem with Taylor expansions of the gamma function
    371371(Trac #9217) is fixed::
    372372
    373     sage: taylor(gamma(1/3+x),x,0,3)      # random output - remove this in trac #9880
    374     -1/432*((36*(pi*sqrt(3) + 9*log(3))*euler_gamma^2 + 27*pi^2*log(3) + 72*euler_gamma^3 + 243*log(3)^3 + 18*(6*pi*sqrt(3)*log(3) + pi^2 + 27*log(3)^2 + 12*psi(1, 1/3))*euler_gamma + 324*psi(1, 1/3)*log(3) + (pi^3 + 9*(9*log(3)^2 + 4*psi(1, 1/3))*pi)*sqrt(3))*gamma(1/3) - 72*gamma(1/3)*psi(2, 1/3))*x^3 + 1/24*(6*pi*sqrt(3)*log(3) + 4*(pi*sqrt(3) + 9*log(3))*euler_gamma + pi^2 + 12*euler_gamma^2 + 27*log(3)^2 + 12*psi(1, 1/3))*x^2*gamma(1/3) - 1/6*(6*euler_gamma + pi*sqrt(3) + 9*log(3))*x*gamma(1/3) + gamma(1/3)
     373    sage: taylor(gamma(1/3+x),x,0,3)
     374    -1/432*((72*euler_gamma^3 + 36*euler_gamma^2*(sqrt(3)*pi + 9*log(3)) +
     375    27*pi^2*log(3) + 243*log(3)^3 + 18*euler_gamma*(6*sqrt(3)*pi*log(3) + pi^2
     376    + 27*log(3)^2 + 12*psi(1, 1/3)) + 324*log(3)*psi(1, 1/3) + sqrt(3)*(pi^3 +
     377    9*pi*(9*log(3)^2 + 4*psi(1, 1/3))))*gamma(1/3) - 72*psi(2,
     378    1/3)*gamma(1/3))*x^3 + 1/24*(6*sqrt(3)*pi*log(3) + 12*euler_gamma^2 + pi^2
     379    + 4*euler_gamma*(sqrt(3)*pi + 9*log(3)) + 27*log(3)^2 + 12*psi(1,
     380    1/3))*x^2*gamma(1/3) - 1/6*(6*euler_gamma + sqrt(3)*pi +
     381    9*log(3))*x*gamma(1/3) + gamma(1/3)
    375382    sage: map(lambda f:f[0].n(), _.coeffs())  # numerical coefficients to make comparison easier; Maple 12 gives same answer
    376383    [2.6789385347..., -8.3905259853..., 26.662447494..., -80.683148377...]
    377384
     
    379386
    380387    sage: k = var("k")
    381388    sage: sum(1/(1+k^2), k, -oo, oo)
    382     1/2*I*psi(-I) - 1/2*I*psi(I) + 1/2*I*psi(-I + 1) - 1/2*I*psi(I + 1)
     389    -1/2*I*psi(I + 1) + 1/2*I*psi(-I + 1) - 1/2*I*psi(I) + 1/2*I*psi(-I)
    383390
    384391Ensure that ticket #8624 is fixed::
    385392
     
    487494    ::
    488495
    489496        sage: symbolic_sum(k * binomial(n, k), k, 1, n)
    490         n*2^(n - 1)
     497        2^(n - 1)*n
    491498
    492499    ::
    493500
     
    865872
    866873        sage: f = x^3 - x + 1
    867874        sage: a = f.solve(x)[0].rhs(); a
    868         -1/2*(I*sqrt(3) + 1)*(1/18*sqrt(3)*sqrt(23) - 1/2)^(1/3) - 1/6*(-I*sqrt(3) + 1)/(1/18*sqrt(3)*sqrt(23) - 1/2)^(1/3)
     875        -1/2*(1/18*sqrt(23)*sqrt(3) - 1/2)^(1/3)*(I*sqrt(3) + 1) - 1/6*(-I*sqrt(3) + 1)/(1/18*sqrt(23)*sqrt(3) - 1/2)^(1/3)
    869876        sage: a.minpoly()
    870877        x^3 - x + 1
    871878
     
    878885        sage: f = a.minpoly(); f
    879886        x^8 - 40*x^6 + 352*x^4 - 960*x^2 + 576
    880887        sage: f(a)
    881         ((((sqrt(2) + sqrt(3) + sqrt(5))^2 - 40)*(sqrt(2) + sqrt(3) + sqrt(5))^2 + 352)*(sqrt(2) + sqrt(3) + sqrt(5))^2 - 960)*(sqrt(2) + sqrt(3) + sqrt(5))^2 + 576
     888        ((((sqrt(5) + sqrt(3) + sqrt(2))^2 - 40)*(sqrt(5) + sqrt(3) + sqrt(2))^2 + 352)*(sqrt(5) + sqrt(3) + sqrt(2))^2 - 960)*(sqrt(5) + sqrt(3) + sqrt(2))^2 + 576
    882889        sage: f(a).expand()
    883890        0
    884891
     
    13011308        sage: xt = E[0,2].inverse_laplace(s,t)
    13021309        sage: yt = E[1,2].inverse_laplace(s,t)
    13031310        sage: xt
    1304         629/2*e^(-4*t) - 91/2*e^(4*t) + 1
     1311        -91/2*e^(4*t) + 629/2*e^(-4*t) + 1
    13051312        sage: yt
    1306         629/8*e^(-4*t) + 91/8*e^(4*t)
     1313        91/8*e^(4*t) + 629/8*e^(-4*t)
    13071314        sage: p1 = plot(xt,0,1/2,rgbcolor=(1,0,0))
    13081315        sage: p2 = plot(yt,0,1/2,rgbcolor=(0,1,0))
    13091316        sage: (p1+p2).save(os.path.join(SAGE_TMP, "de_plot.png"))
     
    17261733    Trac #8459 fixed::
    17271734
    17281735        sage: maxima('3*li[2](u)+8*li[33](exp(u))').sage()
    1729         3*polylog(2, u) + 8*polylog(33, e^u)
     1736        8*polylog(33, e^u) + 3*polylog(2, u)
    17301737
    17311738    Check if #8345 is fixed::
    17321739
  • sage/calculus/desolvers.py

    diff --git a/sage/calculus/desolvers.py b/sage/calculus/desolvers.py
    a b  
    140140        sage: y = function('y', x)
    141141        sage: de = diff(y,x,2) - y == x
    142142        sage: desolve(de, y)
    143         k1*e^x + k2*e^(-x) - x
     143        k2*e^(-x) + k1*e^x - x
    144144       
    145145
    146146    ::
    147147
    148148        sage: f = desolve(de, y, [10,2,1]); f
    149         -x + 5*e^(-x + 10) + 7*e^(x - 10)
     149        -x + 7*e^(x - 10) + 5*e^(-x + 10)
    150150
    151151    ::
    152152
     
    162162
    163163        sage: de = diff(y,x,2) + y == 0
    164164        sage: desolve(de, y)
    165         k1*sin(x) + k2*cos(x)
     165        k2*cos(x) + k1*sin(x)
    166166
    167167    ::
    168168
    169169        sage: desolve(de, y, [0,1,pi/2,4])
    170         4*sin(x) + cos(x)
     170        cos(x) + 4*sin(x)
    171171
    172172    ::
    173173
     
    219219    ::
    220220
    221221        sage: desolve(diff(y,x)*sin(y) == cos(x),y,[pi/2,1])
    222         -cos(y(x)) == sin(x) - cos(1) - 1
     222        -cos(y(x)) == -cos(1) + sin(x) - 1
    223223
    224224    Linear equation - Sage returns the expression on the right hand side only::
    225225
    226226        sage: desolve(diff(y,x)+(y) == cos(x),y)
    227         1/2*((sin(x) + cos(x))*e^x + 2*c)*e^(-x)
     227        1/2*((cos(x) + sin(x))*e^x + 2*c)*e^(-x)
    228228
    229229    ::
    230230
    231231        sage: desolve(diff(y,x)+(y) == cos(x),y,show_method=True)
    232         [1/2*((sin(x) + cos(x))*e^x + 2*c)*e^(-x), 'linear']
     232        [1/2*((cos(x) + sin(x))*e^x + 2*c)*e^(-x), 'linear']
    233233
    234234    ::
    235235
    236236        sage: desolve(diff(y,x)+(y) == cos(x),y,[0,1])
    237         1/2*(e^x*sin(x) + e^x*cos(x) + 1)*e^(-x)
     237        1/2*(cos(x)*e^x + e^x*sin(x) + 1)*e^(-x)
    238238
    239239    This ODE with separated variables is solved as
    240240    exact. Explanation - factor does not split `e^{x-y}` in Maxima
     
    312312    ::
    313313       
    314314        sage: desolve(diff(y,x,2)+2*diff(y,x)+y == cos(x),y,[0,3,pi/2,2])
    315         3*((e^(1/2*pi) - 2)*x/pi + 1)*e^(-x) + 1/2*sin(x)
     315        3*(x*(e^(1/2*pi) - 2)/pi + 1)*e^(-x) + 1/2*sin(x)
    316316       
    317317    ::
    318318       
    319319        sage: desolve(diff(y,x,2)+2*diff(y,x)+y == cos(x),y,[0,3,pi/2,2],show_method=True)
    320         [3*((e^(1/2*pi) - 2)*x/pi + 1)*e^(-x) + 1/2*sin(x), 'variationofparameters']
     320        [3*(x*(e^(1/2*pi) - 2)/pi + 1)*e^(-x) + 1/2*sin(x), 'variationofparameters']
    321321       
    322322    ::
    323323       
     
    342342    ::
    343343       
    344344        sage: desolve(diff(y,x,2)+2*diff(y,x)+y == 0,y,[0,3,pi/2,2])
    345         (2*(2*e^(1/2*pi) - 3)*x/pi + 3)*e^(-x)
     345        (2*x*(2*e^(1/2*pi) - 3)/pi + 3)*e^(-x)
    346346       
    347347    ::
    348348       
    349349        sage: desolve(diff(y,x,2)+2*diff(y,x)+y == 0,y,[0,3,pi/2,2],show_method=True)
    350         [(2*(2*e^(1/2*pi) - 3)*x/pi + 3)*e^(-x), 'constcoeff']
     350        [(2*x*(2*e^(1/2*pi) - 3)/pi + 3)*e^(-x), 'constcoeff']
    351351       
    352352    TESTS:
    353353   
     
    365365        sage: sage.calculus.calculus.maxima('domain:complex')  # back to the default complex domain
    366366        complex
    367367        sage: desolve(x*diff(y,x)-x*sqrt(y^2+x^2)-y == 0, y, contrib_ode=True)
    368         [1/2*(2*x^2*sqrt(x^(-2)) - 2*x*sqrt(x^(-2))*arcsinh(y(x)/sqrt(x^2))
    369         - 2*x*sqrt(x^(-2))*arcsinh(y(x)^2/(sqrt(y(x)^2)*x))
    370         + log(4*(2*x^2*sqrt((x^2*y(x)^2 + y(x)^4)/x^2)*sqrt(x^(-2)) + x^2 + 2*y(x)^2)/x^2))/(x*sqrt(x^(-2))) == c]
     368        [1/2*(2*x^2*sqrt(x^(-2)) - 2*x*sqrt(x^(-2))*arcsinh(y(x)/sqrt(x^2)) -
     369            2*x*sqrt(x^(-2))*arcsinh(y(x)^2/(x*sqrt(y(x)^2))) +
     370            log(4*(2*x^2*sqrt((x^2*y(x)^2 + y(x)^4)/x^2)*sqrt(x^(-2)) + x^2 +
     371            2*y(x)^2)/x^2))/(x*sqrt(x^(-2))) == c]
    371372
    372373    Trac #6479 fixed::
    373374
     
    702703        sage: de2 = diff(y,t) - x + 1 == 0
    703704        sage: desolve_system([de1, de2], [x,y])
    704705        [x(t) == (x(0) - 1)*cos(t) - (y(0) - 1)*sin(t) + 1,
    705          y(t) == (x(0) - 1)*sin(t) + (y(0) - 1)*cos(t) + 1]
     706         y(t) == (y(0) - 1)*cos(t) + (x(0) - 1)*sin(t) + 1]
    706707         
    707708    Now we give some initial conditions::
    708709   
  • sage/calculus/functional.py

    diff --git a/sage/calculus/functional.py b/sage/calculus/functional.py
    a b  
    9393        (a, x)
    9494        sage: f = exp(sin(a - x^2))/x
    9595        sage: derivative(f, x)
    96         -2*e^(sin(-x^2 + a))*cos(-x^2 + a) - e^(sin(-x^2 + a))/x^2
     96        -2*cos(-x^2 + a)*e^(sin(-x^2 + a)) - e^(sin(-x^2 + a))/x^2
    9797        sage: derivative(f, a)
    98         e^(sin(-x^2 + a))*cos(-x^2 + a)/x
     98        cos(-x^2 + a)*e^(sin(-x^2 + a))/x
    9999   
    100100    Syntax for repeated differentiation::
    101101   
     
    167167    ::
    168168   
    169169        sage: integral(x/(x^3-1), x)
    170         1/3*sqrt(3)*arctan(1/3*(2*x + 1)*sqrt(3)) + 1/3*log(x - 1) - 1/6*log(x^2 + x + 1)
     170        1/3*sqrt(3)*arctan(1/3*sqrt(3)*(2*x + 1)) - 1/6*log(x^2 + x + 1) + 1/3*log(x - 1)
    171171   
    172172    ::
    173173   
     
    214214    Note, however, that::
    215215   
    216216        sage: integral( exp(-x^2)*ln(x), x, 0, oo)
    217         -1/4*(euler_gamma + 2*log(2))*sqrt(pi)
     217        -1/4*sqrt(pi)*(euler_gamma + 2*log(2))
    218218   
    219219    This definite integral is easy::
    220220   
     
    371371    Taylor polynomial in two variables::
    372372
    373373        sage: x,y=var('x y'); taylor(x*y^3,(x,1),(y,-1),4)
    374         (y + 1)^3*(x - 1) + (y + 1)^3 - 3*(y + 1)^2*(x - 1) - 3*(y + 1)^2 + 3*(y + 1)*(x - 1) - x + 3*y + 3
     374        (x - 1)*(y + 1)^3 - 3*(x - 1)*(y + 1)^2 + (y + 1)^3 + 3*(x - 1)*(y + 1) - 3*(y + 1)^2 - x + 3*y + 3
    375375    """
    376376    if not isinstance(f, Expression):
    377377        f = SR(f)
     
    382382    EXAMPLES::
    383383   
    384384        sage: a = (x-1)*(x^2 - 1); a
    385         (x - 1)*(x^2 - 1)
     385        (x^2 - 1)*(x - 1)
    386386        sage: expand(a)
    387387        x^3 - x^2 - x + 1
    388388   
  • sage/calculus/functions.py

    diff --git a/sage/calculus/functions.py b/sage/calculus/functions.py
    a b  
    5454    Two-by-two Wronskian of sin(x) and e^x::
    5555   
    5656        sage: wronskian(sin(x), e^x, x)
    57         e^x*sin(x) - e^x*cos(x)
     57        -cos(x)*e^x + e^x*sin(x)
    5858
    5959    Or don't put x last::
    6060   
    6161        sage: wronskian(x, sin(x), e^x)
    62         (e^x*sin(x) + e^x*cos(x))*x - 2*e^x*sin(x)
     62        (cos(x)*e^x + e^x*sin(x))*x - 2*e^x*sin(x)
    6363
    6464    Example where one of the functions is constant::
    6565   
  • sage/calculus/test_sympy.py

    diff --git a/sage/calculus/test_sympy.py b/sage/calculus/test_sympy.py
    a b  
    164164    sage: type(e)
    165165    <type 'sage.symbolic.expression.Expression'>
    166166    sage: e
    167     sin(y) + cos(x)
     167    cos(x) + sin(y)
    168168    sage: e = sage.all.cos(var("y")**3)**4+var("x")**2
    169169    sage: e = e._sympy_()
    170170    sage: e
  • sage/calculus/tests.py

    diff --git a/sage/calculus/tests.py b/sage/calculus/tests.py
    a b  
    2626::
    2727
    2828    sage: christoffel(3,3,2, [t,r,theta,phi], m)
    29     -sin(theta)*cos(theta)
     29    -cos(theta)*sin(theta)
    3030    sage: X = christoffel(1,1,1,[t,r,theta,phi],m)
    3131    sage: X
    32      1/2/((1/r - 1)*r^2)
     32    1/2/(r^2*(1/r - 1))
    3333    sage: X.rational_simplify()
    3434     -1/2/(r^2 - r)
    3535
     
    6868    sage: g(x) = cos(x) + x^3
    6969    sage: u = f(x+t) + g(x-t)
    7070    sage: u
    71     -(t - x)^3 + sin((t + x)^2) + cos(-t + x)
     71    -(t - x)^3 + cos(-t + x) + sin((t + x)^2)
    7272    sage: u.diff(t,2) - u.diff(x,2)
    7373    0
    7474
     
    9595    sage: derivative(arctan(x), x)
    9696    1/(x^2 + 1)
    9797    sage: derivative(x^n, x, 3)
    98     (n - 2)*(n - 1)*n*x^(n - 3)
     98    (n - 1)*(n - 2)*n*x^(n - 3)
    9999    sage: derivative( function('f')(x), x)
    100100    D[0](f)(x)   
    101101    sage: diff( 2*x*f(x^2), x)
    102102    4*x^2*D[0](f)(x^2) + 2*f(x^2)
    103103    sage: integrate( 1/(x^4 - a^4), x)
    104     1/4*log(-a + x)/a^3 - 1/4*log(a + x)/a^3 - 1/2*arctan(x/a)/a^3
     104    -1/2*arctan(x/a)/a^3 - 1/4*log(a + x)/a^3 + 1/4*log(-a + x)/a^3
    105105    sage: expand(integrate(log(1-x^2), x))
    106     x*log(-x^2 + 1) - 2*x - log(x - 1) + log(x + 1)
     106    x*log(-x^2 + 1) - 2*x + log(x + 1) - log(x - 1)
    107107    sage: integrate(log(1-x^2)/x, x)
    108     1/2*log(-x^2 + 1)*log(x^2) + 1/2*polylog(2, -x^2 + 1)
     108    1/2*log(x^2)*log(-x^2 + 1) + 1/2*polylog(2, -x^2 + 1)
    109109    sage: integrate(exp(1-x^2),x)
    110     1/2*sqrt(pi)*e*erf(x)
     110    1/2*sqrt(pi)*erf(x)*e
    111111    sage: integrate(sin(x^2),x)
    112     1/8*((I - 1)*sqrt(2)*erf((1/2*I - 1/2)*sqrt(2)*x) + (I + 1)*sqrt(2)*erf((1/2*I + 1/2)*sqrt(2)*x))*sqrt(pi)
     112    1/8*sqrt(pi)*((I + 1)*sqrt(2)*erf((1/2*I + 1/2)*sqrt(2)*x) + (I - 1)*sqrt(2)*erf((1/2*I - 1/2)*sqrt(2)*x))
    113113
    114114    sage: integrate((1-x^2)^n,x)
    115115    integrate((-x^2 + 1)^n, x)
    116116    sage: integrate(x^x,x)
    117117    integrate(x^x, x)
    118118    sage: integrate(1/(x^3+1),x)
    119     1/3*sqrt(3)*arctan(1/3*(2*x - 1)*sqrt(3)) + 1/3*log(x + 1) - 1/6*log(x^2 - x + 1)
     119    1/3*sqrt(3)*arctan(1/3*sqrt(3)*(2*x - 1)) - 1/6*log(x^2 - x + 1) + 1/3*log(x + 1)
    120120    sage: integrate(1/(x^3+1), x, 0, 1)
    121     1/9*pi*sqrt(3) + 1/3*log(2)
     121    1/9*sqrt(3)*pi + 1/3*log(2)
    122122
    123123::
    124124
     
    159159    sage: diff(sin(x), x, 3)
    160160    -cos(x)
    161161    sage: diff(x*sin(cos(x)), x)
    162     -x*sin(x)*cos(cos(x)) + sin(cos(x))
     162    -x*cos(cos(x))*sin(x) + sin(cos(x))
    163163    sage: diff(tan(x), x)
    164164    tan(x)^2 + 1
    165165    sage: f = function('f'); f
     
    190190::
    191191
    192192    sage: integrate( x/(x^3-1), x)
    193     1/3*sqrt(3)*arctan(1/3*(2*x + 1)*sqrt(3)) + 1/3*log(x - 1) - 1/6*log(x^2 + x + 1)
     193    1/3*sqrt(3)*arctan(1/3*sqrt(3)*(2*x + 1)) - 1/6*log(x^2 + x + 1) + 1/3*log(x - 1)
    194194    sage: integrate(exp(-x^2), x)
    195195    1/2*sqrt(pi)*erf(x)   
    196196    sage: integrate(exp(-x^2)*log(x), x)       # todo: maple can compute this exactly.
     
    208208    sage: function('f, g')
    209209    (f, g)
    210210    sage: diff(f(t)*g(t),t)
    211     f(t)*D[0](g)(t) + g(t)*D[0](f)(t)
     211    g(t)*D[0](f)(t) + f(t)*D[0](g)(t)
    212212    sage: diff(f(t)/g(t), t)
    213     -f(t)*D[0](g)(t)/g(t)^2 + D[0](f)(t)/g(t)
     213    D[0](f)(t)/g(t) - f(t)*D[0](g)(t)/g(t)^2
    214214    sage: diff(f(t) + g(t), t)
    215215    D[0](f)(t) + D[0](g)(t)   
    216216    sage: diff(c*f(t), t)
  • sage/calculus/var.pyx

    diff --git a/sage/calculus/var.pyx b/sage/calculus/var.pyx
    a b  
    220220    method to replace functions::
    221221   
    222222        sage: k.substitute_function(supersin, sin)
    223         2*sin(x)*cos(x)
     223        2*cos(x)*sin(x)
    224224    """
    225225    if len(args) > 0:
    226226        return function(s, **kwds)(*args)
     
    254254        ...
    255255        NameError: name 'x' is not defined
    256256        sage: expand((e + i)^2)
    257         2*I*e + e^2 - 1
     257        e^2 + 2*I*e - 1
    258258        sage: k
    259259        15       
    260260    """
  • sage/calculus/wester.py

    diff --git a/sage/calculus/wester.py b/sage/calculus/wester.py
    a b  
    2929
    3030    sage: # (YES) Evaluate  e^(Pi*Sqrt(163)) to 50 decimal digits
    3131    sage: a = e^(pi*sqrt(163)); a
    32     e^(pi*sqrt(163))
     32    e^(sqrt(163)*pi)
    3333    sage: print RealField(150)(a)
    3434    2.6253741264076874399999999999925007259719820e17
    3535
     
    156156
    157157    sage: # (YES) Factorize x^100-1.
    158158    sage: factor(x^100-1)
    159     (x - 1)*(x + 1)*(x^2 + 1)*(x^4 - x^3 + x^2 - x + 1)*(x^4 + x^3 + x^2 + x + 1)*(x^8 - x^6 + x^4 - x^2 + 1)*(x^20 - x^15 + x^10 - x^5 + 1)*(x^20 + x^15 + x^10 + x^5 + 1)*(x^40 - x^30 + x^20 - x^10 + 1)
     159    (x^40 - x^30 + x^20 - x^10 + 1)*(x^20 + x^15 + x^10 + x^5 + 1)*(x^20 - x^15 + x^10 - x^5 + 1)*(x^8 - x^6 + x^4 - x^2 + 1)*(x^4 + x^3 + x^2 + x + 1)*(x^4 - x^3 + x^2 - x + 1)*(x^2 + 1)*(x + 1)*(x - 1)
    160160    sage: # Also, algebraically
    161161    sage: x = polygen(QQ)
    162162    sage: factor(x^100 - 1)
     
    193193    sage: f = (x^2+2*x+3)/(x^3+4*x^2+5*x+2); f
    194194    (x^2 + 2*x + 3)/(x^3 + 4*x^2 + 5*x + 2)
    195195    sage: f.partial_fraction()
    196     -2/(x + 1) + 2/(x + 1)^2 + 3/(x + 2)
     196    3/(x + 2) - 2/(x + 1) + 2/(x + 1)^2
    197197
    198198::
    199199
     
    233233    sage: eqn = prod(x-i for i in range(1,5 +1)) < 0
    234234    sage: # but don't know how to solve
    235235    sage: eqn
    236     (x - 5)*(x - 4)*(x - 3)*(x - 2)*(x - 1) < 0
     236    (x - 1)*(x - 2)*(x - 3)*(x - 4)*(x - 5) < 0
    237237
    238238::
    239239
     
    287287
    288288    sage: # (YES) (2^(1/3) + 4^(1/3))^3 - 6*(2^(1/3) + 4^(1/3))-6 = 0
    289289    sage: a = (2^(1/3) + 4^(1/3))^3 - 6*(2^(1/3) + 4^(1/3)) - 6; a
    290     (2^(1/3) + 4^(1/3))^3 - 6*2^(1/3) - 6*4^(1/3) - 6
     290    (4^(1/3) + 2^(1/3))^3 - 6*4^(1/3) - 6*2^(1/3) - 6
    291291    sage: bool(a==0)
    292292    True
    293293    sage: abs(float(a)) < 1e-10
     
    339339    sage: assume(r>0)
    340340    sage: f = (4*r+4*sqrt(r)+1)^(sqrt(r)/(2*sqrt(r)+1))*(2*sqrt(r)+1)^(2*sqrt(r)+1)^(-1)-2*sqrt(r)-1
    341341    sage: f
    342     (2*sqrt(r) + 1)^(1/(2*sqrt(r) + 1))*(4*r + 4*sqrt(r) + 1)^(sqrt(r)/(2*sqrt(r) + 1)) - 2*sqrt(r) - 1
     342    (4*r + 4*sqrt(r) + 1)^(sqrt(r)/(2*sqrt(r) + 1))*(2*sqrt(r) + 1)^(1/(2*sqrt(r) + 1)) - 2*sqrt(r) - 1
    343343    sage: bool(f == 0)
    344344    False
    345345    sage: [abs(float(f(r=i))) < 1e-10 for i in [0.1,0.3,0.5]]
     
    362362    sage: a = tan(z); a
    363363    tan(z)
    364364    sage: a.real()
    365     tan(real_part(z))/(tan(real_part(z))^2*tan(imag_part(z))^2 + 1)
     365    tan(real_part(z))/(tan(imag_part(z))^2*tan(real_part(z))^2 + 1)
    366366    sage: a.imag()
    367     tanh(imag_part(z))/(tan(real_part(z))^2*tan(imag_part(z))^2 + 1)
     367    tanh(imag_part(z))/(tan(imag_part(z))^2*tan(real_part(z))^2 + 1)
    368368
    369369
    370370::
     
    455455    [  1   d d^2 d^3]
    456456    sage: d = m.determinant()
    457457    sage: d.factor()
    458     (c - d)*(b - d)*(b - c)*(a - d)*(a - c)*(a - b)
     458    (a - b)*(a - c)*(a - d)*(b - c)*(b - d)*(c - d)
    459459
    460460::
    461461
     
    555555    sage: # (YES) Taylor expansion of Ln(x)^a*Exp(-b*x) at x=1.
    556556    sage: a,b = var('a,b')
    557557    sage: taylor(log(x)^a*exp(-b*x), x, 1, 3)
    558     -1/48*(x - 1)^3*((6*b + 5)*(x - 1)^a*a^2 + (x - 1)^a*a^3 + 8*(x - 1)^a*b^3 + 2*(6*b^2 + 5*b + 3)*(x - 1)^a*a)*e^(-b) + 1/24*(x - 1)^2*((12*b + 5)*(x - 1)^a*a + 3*(x - 1)^a*a^2 + 12*(x - 1)^a*b^2)*e^(-b) - 1/2*(x - 1)*((x - 1)^a*a + 2*(x - 1)^a*b)*e^(-b) + (x - 1)^a*e^(-b)
     558    -1/48*(a^3*(x - 1)^a + a^2*(6*b + 5)*(x - 1)^a + 8*b^3*(x - 1)^a + 2*(6*b^2 + 5*b + 3)*a*(x - 1)^a)*(x - 1)^3*e^(-b) + 1/24*(3*a^2*(x - 1)^a + a*(12*b + 5)*(x - 1)^a + 12*b^2*(x - 1)^a)*(x - 1)^2*e^(-b) - 1/2*(a*(x - 1)^a + 2*b*(x - 1)^a)*(x - 1)*e^(-b) + (x - 1)^a*e^(-b)
    559559   
    560560::
    561561
  • sage/categories/classical_crystals.py

    diff --git a/sage/categories/classical_crystals.py b/sage/categories/classical_crystals.py
    a b  
    156156                sage: weight.reduced_word()
    157157                [2, 1]
    158158                sage: T.demazure_character(weight)
    159                 x1^2*x2 + x1^2*x3 + x1*x2^2 + x1*x2*x3 + x1*x3^2
     159                x1^2*x2 + x1*x2^2 + x1^2*x3 + x1*x2*x3 + x1*x3^2
    160160
    161161                sage: T = CrystalOfTableaux(['A',3],shape=[2,1])
    162162                sage: T.demazure_character([1,2,3])
    163                 x1^2*x2 + x1^2*x3 + x1*x2^2 + x1*x2*x3 + x2^2*x3
     163                x1^2*x2 + x1*x2^2 + x1^2*x3 + x1*x2*x3 + x2^2*x3
    164164                sage: W = WeylGroup(['A',3])
    165165                sage: w = W.from_reduced_word([1,2,3])
    166166                sage: T.demazure_character(w)
    167                 x1^2*x2 + x1^2*x3 + x1*x2^2 + x1*x2*x3 + x2^2*x3
     167                x1^2*x2 + x1*x2^2 + x1^2*x3 + x1*x2*x3 + x2^2*x3
    168168
    169169                sage: T = CrystalOfTableaux(['B',2], shape = [2])
    170170                sage: e = T.weight_lattice_realization().basis()
  • sage/coding/code_bounds.py

    diff --git a/sage/coding/code_bounds.py b/sage/coding/code_bounds.py
    a b  
    451451        sage: entropy(0, 2)
    452452        0
    453453        sage: entropy(1/5,4)
    454         -1/5*log(1/5)/log(4) - 4/5*log(4/5)/log(4) + 1/5*log(3)/log(4)
     454        1/5*log(3)/log(4) - 4/5*log(4/5)/log(4) - 1/5*log(1/5)/log(4)
    455455        sage: entropy(1, 3)
    456456        log(2)/log(3)
    457457
  • sage/combinat/partition.py

    diff --git a/sage/combinat/partition.py b/sage/combinat/partition.py
    a b  
    20882088        EXAMPLES::
    20892089
    20902090            sage: Partition([3,2,1]).hook_product(x)
    2091             (x + 2)^2*(2*x + 3)
     2091            (2*x + 3)*(x + 2)^2
    20922092            sage: Partition([2,2]).hook_product(x)
    2093             2*(x + 1)*(x + 2)
     2093            2*(x + 2)*(x + 1)
    20942094        """
    20952095
    20962096        nu = self.conjugate()
     
    36663666            abs(x)
    36673667
    36683668            sage: Partition([1]).outline()
    3669             abs(x - 1) + abs(x + 1) - abs(x)
     3669            abs(x + 1) + abs(x - 1) - abs(x)
    36703670
    36713671            sage: y=sage.symbolic.ring.var("y")
    36723672            sage: Partition([6,5,1]).outline(variable=y)
    3673             abs(y - 3) - abs(y - 2) + abs(y - 1) - abs(y + 3) + abs(y + 4) - abs(y + 5) + abs(y + 6)
     3673            abs(y + 6) - abs(y + 5) + abs(y + 4) - abs(y + 3) + abs(y - 1) - abs(y - 2) + abs(y - 3)
    36743674
    36753675        TESTS::
    36763676
  • sage/combinat/perfect_matching.py

    diff --git a/sage/combinat/perfect_matching.py b/sage/combinat/perfect_matching.py
    a b  
    725725            sage: m=PerfectMatching([(1,3),(2,4)])
    726726            sage: n=PerfectMatching([(1,2),(3,4)])
    727727            sage: factor(m.Weingarten_function(N,n))
    728             -1/((N - 1)*(N + 2)*N)
     728            -1/((N + 2)*(N - 1)*N)
    729729        """
    730730        if other is None:
    731731            other = self.parent().an_element()
  • sage/combinat/q_analogues.py

    diff --git a/sage/combinat/q_analogues.py b/sage/combinat/q_analogues.py
    a b  
    218218
    219219        sage: z = var('z')
    220220        sage: factor(q_binomial(4,2,z))
    221         (z^2 + 1)*(z^2 + z + 1)
     221        (z^2 + z + 1)*(z^2 + 1)
    222222
    223223    This also works for complex roots of unity::
    224224
  • sage/combinat/root_system/plot.py

    diff --git a/sage/combinat/root_system/plot.py b/sage/combinat/root_system/plot.py
    a b  
    12051205    Four vectors in dimension 3::
    12061206
    12071207        sage: m = barycentric_projection_matrix(3); m
    1208         [ 1/3*sqrt(2)*sqrt(3) -1/3*sqrt(2)*sqrt(3)             0   0]
    1209         [         1/3*sqrt(2)          1/3*sqrt(2)  -2/3*sqrt(2)   0]
    1210         [                 1/3                  1/3           1/3  -1]
     1208        [ 1/3*sqrt(3)*sqrt(2) -1/3*sqrt(3)*sqrt(2)                    0                    0]
     1209        [         1/3*sqrt(2)          1/3*sqrt(2)         -2/3*sqrt(2)                    0]
     1210        [                 1/3                  1/3                  1/3                   -1]
    12111211
    12121212    The columns give four vectors that sum up to zero::
    12131213
  • sage/combinat/sf/ns_macdonald.py

    diff --git a/sage/combinat/sf/ns_macdonald.py b/sage/combinat/sf/ns_macdonald.py
    a b  
    534534            sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])
    535535            sage: q,t = var('q,t')
    536536            sage: a.coeff(q,t)
    537             (t - 1)^4/((q*t^2 - 1)^2*(q^2*t^3 - 1)^2)
     537            (t - 1)^4/((q^2*t^3 - 1)^2*(q*t^2 - 1)^2)
    538538        """
    539539        res = 1
    540540        shape = self.shape()
     
    554554            sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])
    555555            sage: q,t = var('q,t')
    556556            sage: a.coeff_integral(q,t)
    557             (t - 1)^4*(q*t^2 - 1)^2*(q^2*t^3 - 1)^2
     557            (q^2*t^3 - 1)^2*(q*t^2 - 1)^2*(t - 1)^4
    558558        """
    559559        res = 1
    560560        shape = self.shape()
  • sage/combinat/sf/sfa.py

    diff --git a/sage/combinat/sf/sfa.py b/sage/combinat/sf/sfa.py
    a b  
    24472447            490/1539
    24482448            sage: (x,y) = var('x,y')
    24492449            sage: a.scalar_qt(a,q=x,t=y)
    2450             2/3*(x - 1)^3/(y - 1)^3 + 1/3*(x^3 - 1)/(y^3 - 1)
     2450            1/3*(x^3 - 1)/(y^3 - 1) + 2/3*(x - 1)^3/(y - 1)^3
    24512451            sage: Rn = QQ['q','t','y','z'].fraction_field()
    24522452            sage: (q,t,y,z) = Rn.gens()
    24532453            sage: Mac = SymmetricFunctions(Rn).macdonald(q=y,t=z)
  • sage/combinat/tutorial.py

    diff --git a/sage/combinat/tutorial.py b/sage/combinat/tutorial.py
    a b  
    518518    sage: Cf = sage.symbolic.function_factory.function('C')
    519519    sage: equadiff.substitute_function(Cf, s0)
    520520    doctest:...: DeprecationWarning:...
    521     sqrt(-4*z + 1) + (4*z - 1)/sqrt(-4*z + 1) == 0
     521    (4*z - 1)/sqrt(-4*z + 1) + sqrt(-4*z + 1) == 0
    522522    sage: bool(equadiff.substitute_function(Cf, s0))
    523523    True
    524524
     
    11771177    ::
    11781178
    11791179        sage: factor(sum( x^p.length() for p in Permutations(3) ))
    1180         (x + 1)*(x^2 + x + 1)
     1180        (x^2 + x + 1)*(x + 1)
    11811181
    11821182    ::
    11831183
  • sage/ext/fast_callable.pyx

    diff --git a/sage/ext/fast_callable.pyx b/sage/ext/fast_callable.pyx
    a b  
    3030form) at x=30:
    3131
    3232sage: wilk = prod((x-i) for i in [1 .. 20]); wilk
    33 (x - 20)*(x - 19)*(x - 18)*(x - 17)*(x - 16)*(x - 15)*(x - 14)*(x - 13)*(x - 12)*(x - 11)*(x - 10)*(x - 9)*(x - 8)*(x - 7)*(x - 6)*(x - 5)*(x - 4)*(x - 3)*(x - 2)*(x - 1)
     33(x - 1)*(x - 2)*(x - 3)*(x - 4)*(x - 5)*(x - 6)*(x - 7)*(x - 8)*(x - 9)*(x - 10)*(x - 11)*(x - 12)*(x - 13)*(x - 14)*(x - 15)*(x - 16)*(x - 17)*(x - 18)*(x - 19)*(x - 20)
    3434sage: timeit('wilk.subs(x=30)') # random, long time
    3535625 loops, best of 3: 1.43 ms per loop
    3636sage: fc_wilk = fast_callable(wilk, vars=[x])
     
    370370        sage: fp(e, pi, sqrt(2))
    371371        -98.0015640336
    372372        sage: symbolic_result = p(e, pi, sqrt(2)); symbolic_result
    373         -pi^2*e - pi^2 - 3*sqrt(2)*e - 2*e - 6*e^2
     373        -pi^2*e - pi^2 - 3*sqrt(2)*e - 6*e^2 - 2*e
    374374        sage: n(symbolic_result)
    375375        -98.0015640336293
    376376
  • sage/functions/exp_integral.py

    diff --git a/sage/functions/exp_integral.py b/sage/functions/exp_integral.py
    a b  
    609609        EXAMPLES::
    610610
    611611            sage: log_integral_offset(3)
    612             -log_integral(2) + log_integral(3)
     612            log_integral(3) - log_integral(2)
    613613
    614614        """
    615615        BuiltinFunction.__init__(self, "log_integral_offset", nargs=1,
     
    737737        x*sin_integral(x) + cos(x)
    738738
    739739        sage: integrate(sin(x)/x, x)
    740         1/2*I*Ei(-I*x) - 1/2*I*Ei(I*x)
     740        -1/2*I*Ei(I*x) + 1/2*I*Ei(-I*x)
    741741
    742742
    743743    Compare values of the functions `\operatorname{Si}(x)` and
  • sage/functions/hyperbolic.py

    diff --git a/sage/functions/hyperbolic.py b/sage/functions/hyperbolic.py
    a b  
    9595        :meth:`sage.symbolic.expression.Expression.simplify`::
    9696
    9797            sage: sinh(arccosh(x),hold=True).simplify()
    98             sqrt(x - 1)*sqrt(x + 1)
     98            sqrt(x + 1)*sqrt(x - 1)
    9999
    100100        """
    101101        GinacFunction.__init__(self, "sinh", latex_name=r"\sinh")
     
    274274            sage: bool(diff(sech(x), x) == diff(1/cosh(x), x))
    275275            True
    276276            sage: diff(sech(x), x)
    277             -tanh(x)*sech(x)
     277            -sech(x)*tanh(x)
    278278        """
    279279        x = args[0]
    280280        return -sech(x)*tanh(x)
     
    668668        EXAMPLES::
    669669       
    670670            sage: diff(acsch(x), x)
    671             -1/(sqrt(1/x^2 + 1)*x^2)
     671            -1/(x^2*sqrt(1/x^2 + 1))
    672672        """
    673673        x = args[0]
    674674        return -1/(x**2 * (1 + x**(-2)).sqrt())
  • sage/functions/orthogonal_polys.py

    diff --git a/sage/functions/orthogonal_polys.py b/sage/functions/orthogonal_polys.py
    a b  
    433433        sage: gen_legendre_P(2, 0, t) == legendre_P(2, t)
    434434        True
    435435        sage: gen_legendre_P(3, 1, t)
    436         -3/2*sqrt(-t^2 + 1)*(5*t^2 - 1)
     436        -3/2*(5*t^2 - 1)*sqrt(-t^2 + 1)
    437437        sage: gen_legendre_P(4, 3, t)
    438         105*sqrt(-t^2 + 1)*(t^2 - 1)*t
     438        105*(t^2 - 1)*sqrt(-t^2 + 1)*t
    439439        sage: gen_legendre_P(7, 3, I).expand()
    440440        -16695*sqrt(2)
    441441        sage: gen_legendre_P(4, 1, 2.5)
     
    469469        sage: gen_legendre_Q(0, 1, x)
    470470        -1/sqrt(-x^2 + 1)
    471471        sage: gen_legendre_Q(2, 4, x).factor()
    472         48*x/((x - 1)^2*(x + 1)^2)
     472        48*x/((x + 1)^2*(x - 1)^2)
    473473    """
    474474    from sage.functions.all import sqrt
    475475    if m <= n:
  • sage/functions/other.py

    diff --git a/sage/functions/other.py b/sage/functions/other.py
    a b  
    927927            sage: gamma_inc(2,0)
    928928            1
    929929            sage: gamma_inc(1/2,2)
    930             -(erf(sqrt(2)) - 1)*sqrt(pi)
     930            -sqrt(pi)*(erf(sqrt(2)) - 1)
    931931            sage: gamma_inc(1/2,1)
    932             -(erf(1) - 1)*sqrt(pi)
     932            -sqrt(pi)*(erf(1) - 1)
    933933            sage: gamma_inc(1/2,0)
    934934            sqrt(pi)
    935935            sage: gamma_inc(x,0)
     
    15061506            sage: beta(-1/2,-1/2)
    15071507            0
    15081508            sage: beta(x/2,3)
    1509             beta(1/2*x, 3)
     1509            beta(3, 1/2*x)
    15101510            sage: beta(.5,.5)
    15111511            3.14159265358979
    15121512            sage: beta(1,2.0+I)
    15131513            0.400000000000000 - 0.200000000000000*I
    15141514            sage: beta(3,x+I)
    1515             beta(x + I, 3)
     1515            beta(3, x + I)
    15161516
    15171517        Note that the order of arguments does not matter::
    15181518
    15191519            sage: beta(1/2,3*x)
    1520             beta(3*x, 1/2)
     1520            beta(1/2, 3*x)
    15211521
    15221522        The result is symbolic if exact input is given::
    15231523
    15241524            sage: beta(2,1+5*I)
    1525             beta(5*I + 1, 2)
     1525            beta(2, 5*I + 1)
    15261526            sage: beta(2, 2.)
    15271527            0.166666666666667
    15281528            sage: beta(I, 2.)
     
    20082008            sage: var('a')
    20092009            a
    20102010            sage: conjugate(a*sqrt(-2)*sqrt(-3))
    2011             conjugate(a)*conjugate(sqrt(-3))*conjugate(sqrt(-2))
     2011            conjugate(sqrt(-2))*conjugate(sqrt(-3))*conjugate(a)
    20122012
    20132013        Test pickling::
    20142014
  • sage/functions/piecewise.py

    diff --git a/sage/functions/piecewise.py b/sage/functions/piecewise.py
    a b  
    11591159            sage: f(x) = x^2
    11601160            sage: f = Piecewise([[(-1,1),f]])
    11611161            sage: f._fourier_series_helper(3, 1, lambda n: 1)
    1162             -4*cos(pi*x)/pi^2 + cos(2*pi*x)/pi^2 + 1/3
     1162            cos(2*pi*x)/pi^2 - 4*cos(pi*x)/pi^2 + 1/3
    11631163        """
    11641164        from sage.all import pi, sin, cos, srange
    11651165        x = self.default_variable()
     
    11861186            sage: f(x) = x^2
    11871187            sage: f = Piecewise([[(-1,1),f]])
    11881188            sage: f.fourier_series_partial_sum(3,1)
    1189             -4*cos(pi*x)/pi^2 + cos(2*pi*x)/pi^2 + 1/3
     1189            cos(2*pi*x)/pi^2 - 4*cos(pi*x)/pi^2 + 1/3
    11901190            sage: f1(x) = -1
    11911191            sage: f2(x) = 2
    11921192            sage: f = Piecewise([[(-pi,pi/2),f1],[(pi/2,pi),f2]])
    11931193            sage: f.fourier_series_partial_sum(3,pi)
    1194             -3*sin(2*x)/pi + 3*sin(x)/pi - 3*cos(x)/pi - 1/4
     1194            -3*cos(x)/pi - 3*sin(2*x)/pi + 3*sin(x)/pi - 1/4
    11951195        """
    11961196        return self._fourier_series_helper(N, L, lambda n: 1)
    11971197 
     
    12121212            sage: f(x) = x^2
    12131213            sage: f = Piecewise([[(-1,1),f]])
    12141214            sage: f.fourier_series_partial_sum_cesaro(3,1)
    1215             -8/3*cos(pi*x)/pi^2 + 1/3*cos(2*pi*x)/pi^2 + 1/3
     1215            1/3*cos(2*pi*x)/pi^2 - 8/3*cos(pi*x)/pi^2 + 1/3
    12161216            sage: f1(x) = -1
    12171217            sage: f2(x) = 2
    12181218            sage: f = Piecewise([[(-pi,pi/2),f1],[(pi/2,pi),f2]])
    12191219            sage: f.fourier_series_partial_sum_cesaro(3,pi)
    1220             -sin(2*x)/pi + 2*sin(x)/pi - 2*cos(x)/pi - 1/4
     1220            -2*cos(x)/pi - sin(2*x)/pi + 2*sin(x)/pi - 1/4
    12211221        """
    12221222        return self._fourier_series_helper(N, L, lambda n: 1-n/N)
    12231223
     
    12381238            sage: f(x) = x^2
    12391239            sage: f = Piecewise([[(-1,1),f]])
    12401240            sage: f.fourier_series_partial_sum_hann(3,1)
    1241             -3*cos(pi*x)/pi^2 + 1/4*cos(2*pi*x)/pi^2 + 1/3
     1241            1/4*cos(2*pi*x)/pi^2 - 3*cos(pi*x)/pi^2 + 1/3
    12421242            sage: f1(x) = -1
    12431243            sage: f2(x) = 2
    12441244            sage: f = Piecewise([[(-pi,pi/2),f1],[(pi/2,pi),f2]])
    12451245            sage: f.fourier_series_partial_sum_hann(3,pi)
    1246             -3/4*sin(2*x)/pi + 9/4*sin(x)/pi - 9/4*cos(x)/pi - 1/4
     1246            -9/4*cos(x)/pi - 3/4*sin(2*x)/pi + 9/4*sin(x)/pi - 1/4
    12471247        """
    12481248        from sage.all import cos, pi
    12491249        return self._fourier_series_helper(N, L, lambda n: (1+cos(pi*n/N))/2)
     
    12651265            sage: f(x) = x^2
    12661266            sage: f = Piecewise([[(-1,1),f]])
    12671267            sage: f.fourier_series_partial_sum_filtered(3,1,[1,1,1])
    1268             -4*cos(pi*x)/pi^2 + cos(2*pi*x)/pi^2 + 1/3
     1268            cos(2*pi*x)/pi^2 - 4*cos(pi*x)/pi^2 + 1/3
    12691269            sage: f1(x) = -1
    12701270            sage: f2(x) = 2
    12711271            sage: f = Piecewise([[(-pi,pi/2),f1],[(pi/2,pi),f2]])
    12721272            sage: f.fourier_series_partial_sum_filtered(3,pi,[1,1,1])
    1273             -3*sin(2*x)/pi + 3*sin(x)/pi - 3*cos(x)/pi - 1/4
     1273            -3*cos(x)/pi - 3*sin(2*x)/pi + 3*sin(x)/pi - 1/4
    12741274        """
    12751275        return self._fourier_series_helper(N, L, lambda n: F[n])
    12761276       
     
    15771577            sage: x, s, w = var('x, s, w')
    15781578            sage: f = Piecewise([[(0,1),1],[(1,2), 1-x]])
    15791579            sage: f.laplace(x, s)
    1580             (s + 1)*e^(-2*s)/s^2 - e^(-s)/s + 1/s - e^(-s)/s^2
     1580            -e^(-s)/s + (s + 1)*e^(-2*s)/s^2 + 1/s - e^(-s)/s^2
    15811581            sage: f.laplace(x, w)
    1582             (w + 1)*e^(-2*w)/w^2 - e^(-w)/w + 1/w - e^(-w)/w^2
     1582            -e^(-w)/w + (w + 1)*e^(-2*w)/w^2 + 1/w - e^(-w)/w^2
    15831583           
    15841584        ::
    15851585       
  • sage/functions/special.py

    diff --git a/sage/functions/special.py b/sage/functions/special.py
    a b  
    13551355   
    13561356        sage: x,y = var('x,y')
    13571357        sage: spherical_harmonic(3,2,x,y)
    1358         15/4*sqrt(7/30)*e^(2*I*y)*sin(x)^2*cos(x)/sqrt(pi)
     1358        15/4*sqrt(7/30)*cos(x)*e^(2*I*y)*sin(x)^2/sqrt(pi)
    13591359        sage: spherical_harmonic(3,2,1,2)
    1360         15/4*sqrt(7/30)*e^(4*I)*sin(1)^2*cos(1)/sqrt(pi)
     1360        15/4*sqrt(7/30)*cos(1)*e^(4*I)*sin(1)^2/sqrt(pi)
    13611361    """
    13621362    _init()
    13631363    return meval("spherical_harmonic(%s,%s,%s,%s)"%(ZZ(m),ZZ(n),x,y))
     
    14751475        sage: z = var("z")
    14761476        sage: # this is still wrong: must be abs(sin(z)) + 2*round(z/pi)
    14771477        sage: elliptic_e(z, 1)
    1478         sin(z) + 2*round(z/pi)
     1478        2*round(z/pi) + sin(z)
    14791479        sage: elliptic_e(z, 0)
    14801480        z
    14811481        sage: elliptic_e(0.5, 0.1)
  • sage/functions/trig.py

    diff --git a/sage/functions/trig.py b/sage/functions/trig.py
    a b  
    204204            sage: bool(diff(sec(x), x) == diff(1/cos(x), x))
    205205            True
    206206            sage: diff(sec(x), x)
    207             tan(x)*sec(x)
     207            sec(x)*tan(x)
    208208        """
    209209        return sec(x)*tan(x)
    210210       
     
    296296            sage: bool(diff(csc(x), x) == diff(1/sin(x), x))
    297297            True
    298298            sage: diff(csc(x), x)
    299             -csc(x)*cot(x)
     299            -cot(x)*csc(x)
    300300        """
    301301        return -csc(x)*cot(x)
    302302   
     
    687687        EXAMPLES::
    688688
    689689            sage: diff(acsc(x), x)
    690             -1/(sqrt(-1/x^2 + 1)*x^2)
     690            -1/(x^2*sqrt(-1/x^2 + 1))
    691691        """
    692692        return -1/(x**2 * (1 - x**(-2)).sqrt())
    693693
     
    750750        EXAMPLES::
    751751       
    752752            sage: diff(asec(x), x)
    753             1/(sqrt(-1/x^2 + 1)*x^2)
     753            1/(x^2*sqrt(-1/x^2 + 1))
    754754        """
    755755        return 1/(x**2 * (1 - x**(-2)).sqrt())
    756756   
  • sage/functions/wigner.py

    diff --git a/sage/functions/wigner.py b/sage/functions/wigner.py
    a b  
    243243        sage: clebsch_gordan(1.5,0.5,1, 1.5,-0.5,1)
    244244        1/2*sqrt(3)
    245245        sage: clebsch_gordan(3/2,1/2,1, -1/2,1/2,0)
    246         -sqrt(1/6)*sqrt(3)
     246        -sqrt(3)*sqrt(1/6)
    247247
    248248    NOTES:
    249249
  • sage/graphs/generic_graph.py

    diff --git a/sage/graphs/generic_graph.py b/sage/graphs/generic_graph.py
    a b  
    13141314            [-1 -1  3 -1]
    13151315            [-1  0 -1  2]
    13161316            sage: M = G.laplacian_matrix(normalized=True); M
    1317             [                   1 -1/6*sqrt(2)*sqrt(3) -1/6*sqrt(2)*sqrt(3)         -1/3*sqrt(3)]
    1318             [-1/6*sqrt(2)*sqrt(3)                    1                 -1/2                    0]
    1319             [-1/6*sqrt(2)*sqrt(3)                 -1/2                    1                    0]
     1317            [                   1 -1/6*sqrt(3)*sqrt(2) -1/6*sqrt(3)*sqrt(2)         -1/3*sqrt(3)]
     1318            [-1/6*sqrt(3)*sqrt(2)                    1                 -1/2                    0]
     1319            [-1/6*sqrt(3)*sqrt(2)                 -1/2                    1                    0]
    13201320            [        -1/3*sqrt(3)                    0                    0                    1]
     1321
    13211322            sage: Graph({0:[],1:[2]}).laplacian_matrix(normalized=True)
    13221323            [ 0  0  0]
    13231324            [ 0  1 -1]
  • sage/gsl/dft.py

    diff --git a/sage/gsl/dft.py b/sage/gsl/dft.py
    a b  
    391391            sage: s = IndexedSequence(A,J)
    392392            sage: s.dct()
    393393            <BLANKLINE>
    394             Indexed sequence: [1/4*(sqrt(5) - 1)*e^(-8/5*I*pi) + 1/4*(sqrt(5) - 1)*e^(-2/5*I*pi) - 1/4*(sqrt(5) + 1)*e^(-6/5*I*pi) - 1/4*(sqrt(5) + 1)*e^(-4/5*I*pi) + 1, 1/4*(sqrt(5) - 1)*e^(-8/5*I*pi) + 1/4*(sqrt(5) - 1)*e^(-2/5*I*pi) - 1/4*(sqrt(5) + 1)*e^(-6/5*I*pi) - 1/4*(sqrt(5) + 1)*e^(-4/5*I*pi) + 1, 1/4*(sqrt(5) - 1)*e^(-8/5*I*pi) + 1/4*(sqrt(5) - 1)*e^(-2/5*I*pi) - 1/4*(sqrt(5) + 1)*e^(-6/5*I*pi) - 1/4*(sqrt(5) + 1)*e^(-4/5*I*pi) + 1, 1/4*(sqrt(5) - 1)*e^(-8/5*I*pi) + 1/4*(sqrt(5) - 1)*e^(-2/5*I*pi) - 1/4*(sqrt(5) + 1)*e^(-6/5*I*pi) - 1/4*(sqrt(5) + 1)*e^(-4/5*I*pi) + 1, 1/4*(sqrt(5) - 1)*e^(-8/5*I*pi) + 1/4*(sqrt(5) - 1)*e^(-2/5*I*pi) - 1/4*(sqrt(5) + 1)*e^(-6/5*I*pi) - 1/4*(sqrt(5) + 1)*e^(-4/5*I*pi) + 1]
     394            Indexed sequence: [1/4*(sqrt(5) - 1)*e^(-2/5*I*pi) - 1/4*(sqrt(5) + 1)*e^(-4/5*I*pi) - 1/4*(sqrt(5) + 1)*e^(-6/5*I*pi) + 1/4*(sqrt(5) - 1)*e^(-8/5*I*pi) + 1, 1/4*(sqrt(5) - 1)*e^(-2/5*I*pi) - 1/4*(sqrt(5) + 1)*e^(-4/5*I*pi) - 1/4*(sqrt(5) + 1)*e^(-6/5*I*pi) + 1/4*(sqrt(5) - 1)*e^(-8/5*I*pi) + 1, 1/4*(sqrt(5) - 1)*e^(-2/5*I*pi) - 1/4*(sqrt(5) + 1)*e^(-4/5*I*pi) - 1/4*(sqrt(5) + 1)*e^(-6/5*I*pi) + 1/4*(sqrt(5) - 1)*e^(-8/5*I*pi) + 1, 1/4*(sqrt(5) - 1)*e^(-2/5*I*pi) - 1/4*(sqrt(5) + 1)*e^(-4/5*I*pi) - 1/4*(sqrt(5) + 1)*e^(-6/5*I*pi) + 1/4*(sqrt(5) - 1)*e^(-8/5*I*pi) + 1, 1/4*(sqrt(5) - 1)*e^(-2/5*I*pi) - 1/4*(sqrt(5) + 1)*e^(-4/5*I*pi) - 1/4*(sqrt(5) + 1)*e^(-6/5*I*pi) + 1/4*(sqrt(5) - 1)*e^(-8/5*I*pi) + 1]
    395395            indexed by [0, 1, 2, 3, 4]
    396396        """
    397397        from sage.symbolic.constants import pi
  • sage/interfaces/maxima_abstract.py

    diff --git a/sage/interfaces/maxima_abstract.py b/sage/interfaces/maxima_abstract.py
    a b  
    11931193        We illustrate an automatic coercion::
    11941194       
    11951195            sage: c = b + sqrt(3); c
    1196             sqrt(2) + sqrt(3) + 2.5
     1196            sqrt(3) + sqrt(2) + 2.5
    11971197            sage: type(c)
    11981198            <type 'sage.symbolic.expression.Expression'>
    11991199            sage: d = sqrt(3) + b; d
    1200             sqrt(2) + sqrt(3) + 2.5
     1200            sqrt(3) + sqrt(2) + 2.5
    12011201            sage: type(d)
    12021202            <type 'sage.symbolic.expression.Expression'>
    12031203       
  • sage/interfaces/maxima_lib.py

    diff --git a/sage/interfaces/maxima_lib.py b/sage/interfaces/maxima_lib.py
    a b  
    655655            Is  a  positive or negative?
    656656            sage: assume(a>0)
    657657            sage: integrate(1/(x^3 *(a+b*x)^(1/3)),x)
    658             2/9*sqrt(3)*b^2*arctan(1/3*(2*(b*x + a)^(1/3) + a^(1/3))*sqrt(3)/a^(1/3))/a^(7/3) + 2/9*b^2*log((b*x + a)^(1/3) - a^(1/3))/a^(7/3) - 1/9*b^2*log((b*x + a)^(2/3) + (b*x + a)^(1/3)*a^(1/3) + a^(2/3))/a^(7/3) + 1/6*(4*(b*x + a)^(5/3)*b^2 - 7*(b*x + a)^(2/3)*a*b^2)/((b*x + a)^2*a^2 - 2*(b*x + a)*a^3 + a^4)
     658            2/9*sqrt(3)*b^2*arctan(1/3*sqrt(3)*(2*(b*x + a)^(1/3) + a^(1/3))/a^(1/3))/a^(7/3) - 1/9*b^2*log((b*x + a)^(2/3) + (b*x + a)^(1/3)*a^(1/3) + a^(2/3))/a^(7/3) + 2/9*b^2*log((b*x + a)^(1/3) - a^(1/3))/a^(7/3) + 1/6*(4*(b*x + a)^(5/3)*b^2 - 7*(b*x + a)^(2/3)*a*b^2)/((b*x + a)^2*a^2 - 2*(b*x + a)*a^3 + a^4)
    659659            sage: var('x, n')
    660660            (x, n)
    661661            sage: integral(x^n,x)
     
    688688        ::
    689689
    690690            sage: integrate(1 / (1 + abs(x-5)), x, -5, 6)
    691             log(2) + log(11)
     691            log(11) + log(2)
    692692
    693693        ::
    694694
    695695            sage: integrate(1/(1 + abs(x)), x)
    696             1/2*(log(-x + 1) + log(x + 1))*sgn(x) - 1/2*log(-x + 1) + 1/2*log(x + 1)
     696            1/2*(log(x + 1) + log(-x + 1))*sgn(x) + 1/2*log(x + 1) - 1/2*log(-x + 1)
    697697
    698698        ::
    699699
    700700            sage: integrate(cos(x + abs(x)), x)
    701             1/4*(sgn(x) + 1)*sin(2*x) - 1/2*x*sgn(x) + 1/2*x
     701            -1/2*x*sgn(x) + 1/4*(sgn(x) + 1)*sin(2*x) + 1/2*x
    702702
    703703        An example from sage-support thread e641001f8b8d1129::
    704704
     
    714714        ::
    715715
    716716            sage: integrate(sqrt(x + sqrt(x)), x).simplify_full()
    717             1/12*sqrt(sqrt(x) + 1)*((8*x - 3)*x^(1/4) + 2*x^(3/4)) - 1/8*log(sqrt(sqrt(x) + 1) - x^(1/4)) + 1/8*log(sqrt(sqrt(x) + 1) + x^(1/4))
     717            1/12*((8*x - 3)*x^(1/4) + 2*x^(3/4))*sqrt(sqrt(x) + 1) + 1/8*log(sqrt(sqrt(x) + 1) + x^(1/4)) - 1/8*log(sqrt(sqrt(x) + 1) - x^(1/4))
    718718
    719719        And :trac:`11594`::
    720720
  • sage/matrix/matrix2.pyx

    diff --git a/sage/matrix/matrix2.pyx b/sage/matrix/matrix2.pyx
    a b  
    304304            (3, 5)
    305305            sage: soln=A.solve_right(result)
    306306            sage: soln
    307             (-(3*c/a - 5)*b/((b*c/a - d)*a) + 3/a, (3*c/a - 5)/(b*c/a - d))
     307            (-b*(3*c/a - 5)/(a*(b*c/a - d)) + 3/a, (3*c/a - 5)/(b*c/a - d))
    308308            sage: (a*x+b*y).subs(x=soln[0],y=soln[1]).simplify_full()
    309309            3
    310310            sage: (c*x+d*y).subs(x=soln[0],y=soln[1]).simplify_full()
     
    47574757            sage: S = matrix([[x, y], [y, 3*x^2]])
    47584758            sage: em = S.eigenmatrix_left()
    47594759            sage: eigenvalues = em[0]; eigenvalues
    4760             [-1/2*sqrt(9*x^4 - 6*x^3 + x^2 + 4*y^2) + 3/2*x^2 + 1/2*x                                                        0]
    4761             [                                                       0 3/2*x^2 + 1/2*x + 1/2*sqrt(9*x^4 - 6*x^3 + x^2 + 4*y^2)]
     4760            [3/2*x^2 + 1/2*x - 1/2*sqrt(9*x^4 - 6*x^3 + x^2 + 4*y^2)                                                       0]
     4761            [                                                      0 3/2*x^2 + 1/2*x + 1/2*sqrt(9*x^4 - 6*x^3 + x^2 + 4*y^2)]
    47624762            sage: eigenvectors = em[1]; eigenvectors
    4763             [                                                     1  1/2*(3*x^2 - x - sqrt(9*x^4 - 6*x^3 + x^2 + 4*y^2))/y]
    4764             [                                                     1 -1/2*(x - sqrt(9*x^4 - 6*x^3 + x^2 + 4*y^2) - 3*x^2)/y]
     4763            [                                                    1 1/2*(3*x^2 - x - sqrt(9*x^4 - 6*x^3 + x^2 + 4*y^2))/y]
     4764            [                                                    1 1/2*(3*x^2 - x + sqrt(9*x^4 - 6*x^3 + x^2 + 4*y^2))/y]
     4765
    47654766
    47664767        A request for ``'all'`` the eigenvalues, when it is not
    47674768        possible, will raise an error.  Using the ``'galois'``
     
    50255026            sage: S = matrix([[x, y], [y, 3*x^2]])
    50265027            sage: em = S.eigenmatrix_right()
    50275028            sage: eigenvalues = em[0]; eigenvalues
    5028             [-1/2*sqrt(9*x^4 - 6*x^3 + x^2 + 4*y^2) + 3/2*x^2 + 1/2*x                                                        0]
    5029             [                                                       0  3/2*x^2 + 1/2*x + 1/2*sqrt(9*x^4 - 6*x^3 + x^2 + 4*y^2)]
     5029            [3/2*x^2 + 1/2*x - 1/2*sqrt(9*x^4 - 6*x^3 + x^2 + 4*y^2)                                                       0]
     5030            [                                                      0 3/2*x^2 + 1/2*x + 1/2*sqrt(9*x^4 - 6*x^3 + x^2 + 4*y^2)]
     5031
    50305032            sage: eigenvectors = em[1]; eigenvectors
    5031             [                                                     1                                                      1]
    5032             [ 1/2*(3*x^2 - x - sqrt(9*x^4 - 6*x^3 + x^2 + 4*y^2))/y -1/2*(x - sqrt(9*x^4 - 6*x^3 + x^2 + 4*y^2) - 3*x^2)/y]
     5033            [                                                    1                                                     1]
     5034            [1/2*(3*x^2 - x - sqrt(9*x^4 - 6*x^3 + x^2 + 4*y^2))/y 1/2*(3*x^2 - x + sqrt(9*x^4 - 6*x^3 + x^2 + 4*y^2))/y]
     5035
    50335036
    50345037        TESTS::
    50355038
     
    1157511578       
    1157611579            sage: a=matrix([[1,2],[3,4]])
    1157711580            sage: a.exp()
    11578             [-1/22*((sqrt(33) - 11)*e^sqrt(33) - sqrt(33) - 11)*e^(-1/2*sqrt(33) + 5/2)              2/33*(sqrt(33)*e^sqrt(33) - sqrt(33))*e^(-1/2*sqrt(33) + 5/2)]
    11579             [             1/11*(sqrt(33)*e^sqrt(33) - sqrt(33))*e^(-1/2*sqrt(33) + 5/2)  1/22*((sqrt(33) + 11)*e^sqrt(33) - sqrt(33) + 11)*e^(-1/2*sqrt(33) + 5/2)]
     11581            [-1/22*(e^sqrt(33)*(sqrt(33) - 11) - sqrt(33) - 11)*e^(-1/2*sqrt(33) + 5/2)              2/33*(sqrt(33)*e^sqrt(33) - sqrt(33))*e^(-1/2*sqrt(33) + 5/2)]
     11582            [             1/11*(sqrt(33)*e^sqrt(33) - sqrt(33))*e^(-1/2*sqrt(33) + 5/2)  1/22*(e^sqrt(33)*(sqrt(33) + 11) - sqrt(33) + 11)*e^(-1/2*sqrt(33) + 5/2)]
     11583
    1158011584            sage: type(a.exp())
    1158111585            <type 'sage.matrix.matrix_symbolic_dense.Matrix_symbolic_dense'>
    1158211586
    1158311587            sage: a=matrix([[1/2,2/3],[3/4,4/5]])
    1158411588            sage: a.exp()
    11585             [-1/418*((3*sqrt(209) - 209)*e^(1/10*sqrt(209)) - 3*sqrt(209) - 209)*e^(-1/20*sqrt(209) + 13/20)                   20/627*(sqrt(209)*e^(1/10*sqrt(209)) - sqrt(209))*e^(-1/20*sqrt(209) + 13/20)]
    11586             [                  15/418*(sqrt(209)*e^(1/10*sqrt(209)) - sqrt(209))*e^(-1/20*sqrt(209) + 13/20)  1/418*((3*sqrt(209) + 209)*e^(1/10*sqrt(209)) - 3*sqrt(209) + 209)*e^(-1/20*sqrt(209) + 13/20)]
     11589            [-1/418*(e^(1/10*sqrt(209))*(3*sqrt(209) - 209) - 3*sqrt(209) - 209)*e^(-1/20*sqrt(209) + 13/20)                   20/627*(sqrt(209)*e^(1/10*sqrt(209)) - sqrt(209))*e^(-1/20*sqrt(209) + 13/20)]
     11590            [                  15/418*(sqrt(209)*e^(1/10*sqrt(209)) - sqrt(209))*e^(-1/20*sqrt(209) + 13/20)  1/418*(e^(1/10*sqrt(209))*(3*sqrt(209) + 209) - 3*sqrt(209) + 209)*e^(-1/20*sqrt(209) + 13/20)]
    1158711591
    1158811592            sage: a=matrix(RR,[[1,pi.n()],[1e2,1e-2]])
    1158911593            sage: a.exp()
    11590             [ 1/11882424341266*((11*sqrt(227345670387496707609) + 5941212170633)*e^(3/1275529100*sqrt(227345670387496707609)) - 11*sqrt(227345670387496707609) + 5941212170633)*e^(-3/2551058200*sqrt(227345670387496707609) + 101/200)                            445243650/75781890129165569203*(sqrt(227345670387496707609)*e^(3/1275529100*sqrt(227345670387496707609)) - sqrt(227345670387496707609))*e^(-3/2551058200*sqrt(227345670387496707609) + 101/200)]
    11591             [                                     10000/53470909535697*(sqrt(227345670387496707609)*e^(3/1275529100*sqrt(227345670387496707609)) - sqrt(227345670387496707609))*e^(-3/2551058200*sqrt(227345670387496707609) + 101/200) -1/11882424341266*((11*sqrt(227345670387496707609) - 5941212170633)*e^(3/1275529100*sqrt(227345670387496707609)) - 11*sqrt(227345670387496707609) - 5941212170633)*e^(-3/2551058200*sqrt(227345670387496707609) + 101/200)]
     11594            [ 1/11882424341266*(e^(3/1275529100*sqrt(227345670387496707609))*(11*sqrt(227345670387496707609) + 5941212170633) - 11*sqrt(227345670387496707609) + 5941212170633)*e^(-3/2551058200*sqrt(227345670387496707609) + 101/200)                            445243650/75781890129165569203*(sqrt(227345670387496707609)*e^(3/1275529100*sqrt(227345670387496707609)) - sqrt(227345670387496707609))*e^(-3/2551058200*sqrt(227345670387496707609) + 101/200)]
     11595            [                                     10000/53470909535697*(sqrt(227345670387496707609)*e^(3/1275529100*sqrt(227345670387496707609)) - sqrt(227345670387496707609))*e^(-3/2551058200*sqrt(227345670387496707609) + 101/200) -1/11882424341266*(e^(3/1275529100*sqrt(227345670387496707609))*(11*sqrt(227345670387496707609) - 5941212170633) - 11*sqrt(227345670387496707609) - 5941212170633)*e^(-3/2551058200*sqrt(227345670387496707609) + 101/200)]
    1159211596            sage: a.change_ring(RDF).exp()
    1159311597            [42748127.3153 7368259.24416]
    1159411598            [234538976.138 40426191.4516]
  • sage/matrix/matrix_symbolic_dense.pyx

    diff --git a/sage/matrix/matrix_symbolic_dense.pyx b/sage/matrix/matrix_symbolic_dense.pyx
    a b  
    4040
    4141    sage: M = matrix(SR, 2, var('a,b,c,d'))
    4242    sage: ~M
    43     [-b*c/((b*c/a - d)*a^2) + 1/a            b/((b*c/a - d)*a)]
    44     [           c/((b*c/a - d)*a)               -1/(b*c/a - d)]
     43    [1/a - b*c/(a^2*(b*c/a - d))           b/(a*(b*c/a - d))]
     44    [          c/(a*(b*c/a - d))              -1/(b*c/a - d)]
    4545    sage: (~M*M).simplify_rational()
    4646    [1 0]
    4747    [0 1]
     
    103103    sage: t = var('t')
    104104    sage: M = matrix(SR, 2, 2, [cos(t), sin(t), -sin(t), cos(t)])
    105105    sage: M.det()
    106     sin(t)^2 + cos(t)^2
     106    cos(t)^2 + sin(t)^2
    107107
    108108Permanents::
    109109
     
    206206            [3 4 5]
    207207            [6 7 8]
    208208            sage: es = A.eigenvectors_left(); es
    209             [(-3*sqrt(6) + 6, [(1, -1/5*sqrt(6) + 4/5, -2/5*sqrt(2)*sqrt(3) + 3/5)], 1), (3*sqrt(6) + 6, [(1, 1/5*sqrt(6) + 4/5, 2/5*sqrt(2)*sqrt(3) + 3/5)], 1), (0, [(1, -2, 1)], 1)]
     209            [(-3*sqrt(6) + 6, [(1, -1/5*sqrt(6) + 4/5, -2/5*sqrt(3)*sqrt(2) + 3/5)], 1), (3*sqrt(6) + 6, [(1, 1/5*sqrt(6) + 4/5, 2/5*sqrt(3)*sqrt(2) + 3/5)], 1), (0, [(1, -2, 1)], 1)]
    210210            sage: eval, [evec], mult = es[0]
    211211            sage: delta = eval*evec - evec*A
    212212            sage: abs(abs(delta)) < 1e-10
    213             abs(sqrt(144/25*(sqrt(2)*sqrt(3) - sqrt(6))^2 + 1/25*(3*(sqrt(6) - 2)*(2*sqrt(2)*sqrt(3) - 3) + 16*sqrt(2)*sqrt(3) + 5*sqrt(6) - 54)^2 + 1/25*(3*(sqrt(6) - 4)*(sqrt(6) - 2) + 14*sqrt(2)*sqrt(3) + 4*sqrt(6) - 42)^2)) < (1.00000000000000e-10)
     213            abs(sqrt(1/25*(3*(2*sqrt(3)*sqrt(2) - 3)*(sqrt(6) - 2) + 16*sqrt(3)*sqrt(2) + 5*sqrt(6) - 54)^2 + 1/25*(3*(sqrt(6) - 2)*(sqrt(6) - 4) + 14*sqrt(3)*sqrt(2) + 4*sqrt(6) - 42)^2 + 144/25*(sqrt(3)*sqrt(2) - sqrt(6))^2)) < (1.00000000000000e-10)
    214214            sage: abs(abs(delta)).n() < 1e-10
    215215            True
    216216
     
    218218
    219219            sage: A = matrix(SR, 2, 2, var('a,b,c,d'))
    220220            sage: A.eigenvectors_left()
    221             [(1/2*a + 1/2*d - 1/2*sqrt(a^2 - 2*a*d + 4*b*c + d^2), [(1, -1/2*(a - d + sqrt(a^2 - 2*a*d + 4*b*c + d^2))/c)], 1), (1/2*a + 1/2*d + 1/2*sqrt(a^2 - 2*a*d + 4*b*c + d^2), [(1, -1/2*(a - d - sqrt(a^2 - 2*a*d + 4*b*c + d^2))/c)], 1)]
     221            [(1/2*a + 1/2*d - 1/2*sqrt(a^2 + 4*b*c - 2*a*d + d^2), [(1, -1/2*(a - d + sqrt(a^2 + 4*b*c - 2*a*d + d^2))/c)], 1), (1/2*a + 1/2*d + 1/2*sqrt(a^2 + 4*b*c - 2*a*d + d^2), [(1, -1/2*(a - d - sqrt(a^2 + 4*b*c - 2*a*d + d^2))/c)], 1)]
    222222            sage: es = A.eigenvectors_left(); es
    223             [(1/2*a + 1/2*d - 1/2*sqrt(a^2 - 2*a*d + 4*b*c + d^2), [(1, -1/2*(a - d + sqrt(a^2 - 2*a*d + 4*b*c + d^2))/c)], 1), (1/2*a + 1/2*d + 1/2*sqrt(a^2 - 2*a*d + 4*b*c + d^2), [(1, -1/2*(a - d - sqrt(a^2 - 2*a*d + 4*b*c + d^2))/c)], 1)]
     223            [(1/2*a + 1/2*d - 1/2*sqrt(a^2 + 4*b*c - 2*a*d + d^2), [(1, -1/2*(a - d + sqrt(a^2 + 4*b*c - 2*a*d + d^2))/c)], 1), (1/2*a + 1/2*d + 1/2*sqrt(a^2 + 4*b*c - 2*a*d + d^2), [(1, -1/2*(a - d - sqrt(a^2 + 4*b*c - 2*a*d + d^2))/c)], 1)]
    224224            sage: eval, [evec], mult = es[0]
    225225            sage: delta = eval*evec - evec*A
    226226            sage: delta.apply_map(lambda x: x.full_simplify())
     
    400400
    401401            sage: M = matrix(SR, 2, 2, var('a,b,c,d'))
    402402            sage: M.charpoly('t')
    403             t^2 + (-a - d)*t + a*d - b*c
     403            t^2 + (-a - d)*t - b*c + a*d
    404404            sage: matrix(SR, 5, [1..5^2]).charpoly()
    405405            x^5 - 65*x^4 - 250*x^3
    406406
     
    525525            sage: theta = var('theta')
    526526            sage: M = matrix(SR, 2, 2, [cos(theta), sin(theta), -sin(theta), cos(theta)])
    527527            sage: ~M
    528             [-sin(theta)^2/((sin(theta)^2/cos(theta) + cos(theta))*cos(theta)^2) + 1/cos(theta)                    -sin(theta)/((sin(theta)^2/cos(theta) + cos(theta))*cos(theta))]
    529             [                    sin(theta)/((sin(theta)^2/cos(theta) + cos(theta))*cos(theta))                                           1/(sin(theta)^2/cos(theta) + cos(theta))]
     528            [1/cos(theta) - sin(theta)^2/((sin(theta)^2/cos(theta) + cos(theta))*cos(theta)^2)                   -sin(theta)/((sin(theta)^2/cos(theta) + cos(theta))*cos(theta))]
     529            [                   sin(theta)/((sin(theta)^2/cos(theta) + cos(theta))*cos(theta))                                          1/(sin(theta)^2/cos(theta) + cos(theta))]
    530530            sage: (~M).simplify_trig()
    531531            [ cos(theta) -sin(theta)]
    532532            [ sin(theta)  cos(theta)]
     
    539539       
    540540            sage: M = matrix(SR, 3, 3, range(9)) - var('t')
    541541            sage: (~M*M)[0,0]
    542             -(3*((6/t + 7)/((t - 3/t - 4)*t) + 2/t)*((6/t + 5)/((t - 3/t - 4)*t) + 2/t)/((6/t + 5)*(6/t + 7)/(t - 3/t - 4) - t + 12/t + 8) - 1/t - 3/((t - 3/t - 4)*t^2))*t + 3*(6/t + 7)*((6/t + 5)/((t - 3/t - 4)*t) + 2/t)/((t - 3/t - 4)*((6/t + 5)*(6/t + 7)/(t - 3/t - 4) - t + 12/t + 8)) + 6*((6/t + 5)/((t - 3/t - 4)*t) + 2/t)/((6/t + 5)*(6/t + 7)/(t - 3/t - 4) - t + 12/t + 8) - 3/((t - 3/t - 4)*t)
     542            t*(3*(2/t + (6/t + 7)/((t - 3/t - 4)*t))*(2/t + (6/t + 5)/((t - 3/t
     543            - 4)*t))/(t - (6/t + 7)*(6/t + 5)/(t - 3/t - 4) - 12/t - 8) + 1/t +
     544            3/((t - 3/t - 4)*t^2)) - 6*(2/t + (6/t + 5)/((t - 3/t - 4)*t))/(t -
     545            (6/t + 7)*(6/t + 5)/(t - 3/t - 4) - 12/t - 8) - 3*(6/t + 7)*(2/t +
     546            (6/t + 5)/((t - 3/t - 4)*t))/((t - (6/t + 7)*(6/t + 5)/(t - 3/t -
     547            4) - 12/t - 8)*(t - 3/t - 4)) - 3/((t - 3/t - 4)*t)
    543548            sage: expand((~M*M)[0,0])
    544549            1
    545550            sage: (~M * M).simplify_rational()
     
    646651            sage: M = MatrixSpace(SR,2,2)
    647652            sage: h = M(sin(x)+cos(x))
    648653            sage: h
    649             [sin(x) + cos(x)               0]
    650             [              0 sin(x) + cos(x)]
     654            [cos(x) + sin(x)               0]
     655            [              0 cos(x) + sin(x)]
    651656            sage: h(x=1)
    652             [sin(1) + cos(1)               0]
    653             [              0 sin(1) + cos(1)]
     657            [cos(1) + sin(1)               0]
     658            [              0 cos(1) + sin(1)]
    654659            sage: h(x=x)
    655             [sin(x) + cos(x)               0]
    656             [              0 sin(x) + cos(x)]
     660            [cos(x) + sin(x)               0]
     661            [              0 cos(x) + sin(x)]
    657662
    658663            sage: h = M((sin(x)+cos(x)).function(x))
    659664            sage: h
    660             [sin(x) + cos(x)               0]
    661             [              0 sin(x) + cos(x)]
     665            [cos(x) + sin(x)               0]
     666            [              0 cos(x) + sin(x)]
    662667            sage: h(1)
    663668            doctest:...: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...)
    664669            See http://trac.sagemath.org/4513 for details.
    665670            doctest:...: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...)
    666671            See http://trac.sagemath.org/5930 for details.
    667             [sin(1) + cos(1)               0]
    668             [              0 sin(1) + cos(1)]
     672            [cos(1) + sin(1)               0]
     673            [              0 cos(1) + sin(1)]
    669674            sage: h(x)
    670             [sin(x) + cos(x)               0]
    671             [              0 sin(x) + cos(x)]
     675            [cos(x) + sin(x)               0]
     676            [              0 cos(x) + sin(x)]
    672677
    673678            sage: f = M([0,x,y,z]); f
    674679            [0 x]
  • sage/misc/functional.py

    diff --git a/sage/misc/functional.py b/sage/misc/functional.py
    a b  
    578578    ::
    579579
    580580        sage: sum(k * binomial(n, k), k, 1, n)
    581         n*2^(n - 1)
     581        2^(n - 1)*n
    582582
    583583    ::
    584584
     
    707707        sage: integral(sin(x)^2, x, algorithm='maxima')
    708708        1/2*x - 1/4*sin(2*x)
    709709        sage: integral(sin(x)^2, x, algorithm='sympy')
    710         -1/2*sin(x)*cos(x) + 1/2*x
     710        -1/2*cos(x)*sin(x) + 1/2*x
    711711
    712712    TESTS:
    713713
  • sage/misc/parser.pyx

    diff --git a/sage/misc/parser.pyx b/sage/misc/parser.pyx
    a b  
    451451
    452452            sage: p = Parser(make_var=var)
    453453            sage: p.parse("a*b^c - 3a")
    454             b^c*a - 3*a
     454            a*b^c - 3*a
    455455           
    456456            sage: R.<x> = QQ[]
    457457            sage: p = Parser(make_var = {'x': x })
     
    752752            sage: p.p_term(Tokenizer("-a * b + c"))
    753753            -a*b
    754754            sage: p.p_term(Tokenizer("a*(b-c)^2"))
    755             (b - c)^2*a
     755            a*(b - c)^2
    756756            sage: p.p_term(Tokenizer("-3a"))
    757757            -3*a
    758758        """
  • sage/modules/free_module_element.pyx

    diff --git a/sage/modules/free_module_element.pyx b/sage/modules/free_module_element.pyx
    a b  
    17751775       
    17761776            sage: x = var('x')
    17771777            sage: v = vector([x/(2*x)+sqrt(2)+var('theta')^3,x/(2*x)]); v
    1778             (sqrt(2) + theta^3 + 1/2, 1/2)
     1778            (theta^3 + sqrt(2) + 1/2, 1/2)
    17791779            sage: v._repr_()
    1780             '(sqrt(2) + theta^3 + 1/2, 1/2)'
     1780            '(theta^3 + sqrt(2) + 1/2, 1/2)'
    17811781        """
    17821782        d = self.degree()
    17831783        if d == 0: return "()"
     
    33313331            [   (r, theta) |--> cos(theta) (r, theta) |--> -r*sin(theta)]
    33323332            [   (r, theta) |--> sin(theta)  (r, theta) |--> r*cos(theta)]
    33333333            sage: T.diff().det() # Jacobian
    3334             (r, theta) |--> r*sin(theta)^2 + r*cos(theta)^2
     3334            (r, theta) |--> r*cos(theta)^2 + r*sin(theta)^2
    33353335        """
    33363336        if var is None:
    33373337            if sage.symbolic.callable.is_CallableSymbolicExpressionRing(self.base_ring()):
  • sage/modules/vector_callable_symbolic_dense.py

    diff --git a/sage/modules/vector_callable_symbolic_dense.py b/sage/modules/vector_callable_symbolic_dense.py
    a b  
    1818    sage: 3*f
    1919    (r, theta, z) |--> (3*r*cos(theta), 3*r*sin(theta), 3*z)
    2020    sage: f*f # dot product
    21     (r, theta, z) |--> r^2*sin(theta)^2 + r^2*cos(theta)^2 + z^2
     21    (r, theta, z) |--> r^2*cos(theta)^2 + r^2*sin(theta)^2 + z^2
    2222    sage: f.diff()(0,1,2) # the matrix derivative
    2323    [cos(1)      0      0]
    2424    [sin(1)      0      0]
  • sage/modules/vector_symbolic_dense.py

    diff --git a/sage/modules/vector_symbolic_dense.py b/sage/modules/vector_symbolic_dense.py
    a b  
    1313
    1414    sage: x, y = var('x, y')
    1515    sage: u = vector([sin(x)^2 + cos(x)^2, log(2*y) + log(3*y)]); u
    16     (sin(x)^2 + cos(x)^2, log(2*y) + log(3*y))
     16    (cos(x)^2 + sin(x)^2, log(3*y) + log(2*y))
    1717    sage: type(u)
    1818    <class 'sage.modules.vector_symbolic_dense.Vector_symbolic_dense'>
    1919    sage: u.simplify_full()
     
    8484            sage: v.simplify_trig()
    8585            (1, log(x*y), sin(1/(x + 1)), factorial(x + 1)/factorial(x))
    8686            sage: v.simplify_radical()
    87             (sin(x)^2 + cos(x)^2, log(x) + log(y), sin(1/(x + 1)), factorial(x + 1)/factorial(x))
     87            (cos(x)^2 + sin(x)^2, log(x) + log(y), sin(1/(x + 1)), factorial(x + 1)/factorial(x))
    8888            sage: v.simplify_rational()
    89             (sin(x)^2 + cos(x)^2, log(x*y), sin(1/(x + 1)), factorial(x + 1)/factorial(x))
     89            (cos(x)^2 + sin(x)^2, log(x*y), sin(1/(x + 1)), factorial(x + 1)/factorial(x))
    9090            sage: v.simplify_factorial()
    91             (sin(x)^2 + cos(x)^2, log(x*y), sin(x/(x^2 + x)), x + 1)
     91            (cos(x)^2 + sin(x)^2, log(x*y), sin(x/(x^2 + x)), x + 1)
    9292            sage: v.simplify_full()
    9393            (1, log(x*y), sin(1/(x + 1)), x + 1)
    9494
    9595            sage: v = vector([sin(2*x), sin(3*x)])
    9696            sage: v.simplify_trig()
    97             (2*sin(x)*cos(x), (4*cos(x)^2 - 1)*sin(x))
     97            (2*cos(x)*sin(x), (4*cos(x)^2 - 1)*sin(x))
    9898            sage: v.simplify_trig(False)
    9999            (sin(2*x), sin(3*x))
    100100            sage: v.simplify_trig(expand=False)
  • sage/plot/plot3d/plot3d.py

    diff --git a/sage/plot/plot3d/plot3d.py b/sage/plot/plot3d/plot3d.py
    a b  
    416416
    417417        sage: r, phi, theta = var('r phi theta')
    418418        sage: T.transform(radius=r, azimuth=theta, inclination=phi)
    419         (r*sin(phi)*cos(theta), r*sin(phi)*sin(theta), r*cos(phi))
     419        (r*cos(theta)*sin(phi), r*sin(phi)*sin(theta), r*cos(phi))
    420420   
    421421    We can plot with this transform.  Remember that the dependent
    422422    variable is the radius, and the independent variables are the
     
    442442       
    443443            sage: T = Spherical('radius', ['azimuth', 'inclination'])
    444444            sage: T.transform(radius=var('r'), azimuth=var('theta'), inclination=var('phi'))
    445             (r*sin(phi)*cos(theta), r*sin(phi)*sin(theta), r*cos(phi))
     445            (r*cos(theta)*sin(phi), r*sin(phi)*sin(theta), r*cos(phi))
    446446        """
    447447        return (radius * sin(inclination) * cos(azimuth),
    448448                radius * sin(inclination) * sin(azimuth),
     
    471471        sage: T = SphericalElevation('radius', ['azimuth', 'elevation'])
    472472        sage: r, theta, phi = var('r theta phi')
    473473        sage: T.transform(radius=r, azimuth=theta, elevation=phi)
    474         (r*cos(phi)*cos(theta), r*sin(theta)*cos(phi), r*sin(phi))
     474        (r*cos(phi)*cos(theta), r*cos(phi)*sin(theta), r*sin(phi))
    475475
    476476    We can plot with this transform.  Remember that the dependent
    477477    variable is the radius, and the independent variables are the
     
    519519
    520520            sage: T = SphericalElevation('radius', ['azimuth', 'elevation'])
    521521            sage: T.transform(radius=var('r'), azimuth=var('theta'), elevation=var('phi'))
    522             (r*cos(phi)*cos(theta), r*sin(theta)*cos(phi), r*sin(phi))
     522            (r*cos(phi)*cos(theta), r*cos(phi)*sin(theta), r*sin(phi))
    523523        """
    524524        return (radius * cos(elevation) * cos(azimuth),
    525525                radius * cos(elevation) * sin(azimuth),
  • sage/rings/integer.pyx

    diff --git a/sage/rings/integer.pyx b/sage/rings/integer.pyx
    a b  
    19281928            sage: 2^I                # complex number
    19291929            2^I
    19301930            sage: f = 2^(sin(x)-cos(x)); f
    1931             2^(sin(x) - cos(x))
     1931            2^(-cos(x) + sin(x))
    19321932            sage: f(x=3)
    1933             2^(sin(3) - cos(3))
     1933            2^(-cos(3) + sin(3))
    19341934       
    19351935        A symbolic sum::
    19361936       
  • sage/rings/number_field/number_field_element.pyx

    diff --git a/sage/rings/number_field/number_field_element.pyx b/sage/rings/number_field/number_field_element.pyx
    a b  
    20712071       
    20722072            sage: K.<a> = NumberField(x^3 + x - 1, embedding=0.68)
    20732073            sage: b = SR(a); b # indirect doctest
    2074             1/3*(3*(1/18*sqrt(3)*sqrt(31) + 1/2)^(2/3) - 1)/(1/18*sqrt(3)*sqrt(31) + 1/2)^(1/3)
     2074            1/3*(3*(1/18*sqrt(31)*sqrt(3) + 1/2)^(2/3) - 1)/(1/18*sqrt(31)*sqrt(3) + 1/2)^(1/3)
    20752075
    20762076            sage: (b^3 + b - 1).simplify_radical()
    20772077            0
  • sage/rings/polynomial/polynomial_element.pyx

    diff --git a/sage/rings/polynomial/polynomial_element.pyx b/sage/rings/polynomial/polynomial_element.pyx
    a b  
    46674667       
    46684668            sage: X = var('X')
    46694669            sage: f = expand((X-1)*(X-I)^3*(X^2 - sqrt(2))); f
    4670             -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
     4670            X^6 - (3*I + 1)*X^5 - sqrt(2)*X^4 + (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 + I*sqrt(2)
    46714671            sage: print f.roots()
    46724672            [(I, 3), (-2^(1/4), 1), (2^(1/4), 1), (1, 1)]
    46734673       
  • sage/rings/power_series_ring.py

    diff --git a/sage/rings/power_series_ring.py b/sage/rings/power_series_ring.py
    a b  
    5555    sage: a, b, c = var('a,b,c')
    5656    sage: f = a + b*t + c*t^2 + O(t^3)
    5757    sage: f*f
    58     a^2 + 2*a*b*t + (2*a*c + b^2)*t^2 + O(t^3)
     58    a^2 + 2*a*b*t + (b^2 + 2*a*c)*t^2 + O(t^3)
    5959    sage: f = sqrt(2) + sqrt(3)*t + O(t^3)
    6060    sage: f^2
    61     2 + 2*sqrt(2)*sqrt(3)*t + 3*t^2 + O(t^3)
     61    2 + 2*sqrt(3)*sqrt(2)*t + 3*t^2 + O(t^3)
    6262
    6363Elements are first coerced to constants in base_ring, then coerced
    6464into the PowerSeriesRing::
  • sage/rings/qqbar.py

    diff --git a/sage/rings/qqbar.py b/sage/rings/qqbar.py
    a b  
    619619
    620620            sage: x = polygen(SR)
    621621            sage: p = (x - sqrt(-5)) * (x - sqrt(3)); p
    622             x^2 + (-sqrt(-5) - sqrt(3))*x + sqrt(-5)*sqrt(3)
     622            x^2 + (-sqrt(3) - sqrt(-5))*x + sqrt(3)*sqrt(-5)
    623623            sage: p = QQbar.common_polynomial(p)
    624624            sage: a = QQbar.polynomial_root(p, CIF(RIF(-0.1, 0.1), RIF(2, 3))); a
    625625            0.?e-18 + 2.236067977499790?*I
  • sage/schemes/elliptic_curves/ell_generic.py

    diff --git a/sage/schemes/elliptic_curves/ell_generic.py b/sage/schemes/elliptic_curves/ell_generic.py
    a b  
    424424            0
    425425
    426426            sage: 2*w
    427             (-2*pi + (2*pi - 3*pi^2 + 10)^2/(-40*pi + 4*pi^3 - 4*pi^2 - 79) + 1 : (2*pi - 3*pi^2 + 10)*(3*pi - (2*pi - 3*pi^2 + 10)^2/(-40*pi + 4*pi^3 - 4*pi^2 - 79) - 1)/sqrt(-40*pi + 4*pi^3 - 4*pi^2 - 79) + 1/2*sqrt(-40*pi + 4*pi^3 - 4*pi^2 - 79) - 1/2 : 1)
     427            (-2*pi + (2*pi - 3*pi^2 + 10)^2/(-40*pi + 4*pi^3 - 4*pi^2 - 79) + 1 : (3*pi - (2*pi - 3*pi^2 + 10)^2/(-40*pi + 4*pi^3 - 4*pi^2 - 79) - 1)*(2*pi - 3*pi^2 + 10)/sqrt(-40*pi + 4*pi^3 - 4*pi^2 - 79) + 1/2*sqrt(-40*pi + 4*pi^3 - 4*pi^2 - 79) - 1/2 : 1)
    428428           
    429429            sage: x, y, z = 2*w; temp = ((y^2 + y) - (x^3 - x^2 - 10*x - 20))
    430430
  • sage/stats/basic_stats.py

    diff --git a/sage/stats/basic_stats.py b/sage/stats/basic_stats.py
    a b  
    165165        sage: std([])
    166166        NaN
    167167        sage: std([I, sqrt(2), 3/5])
    168         sqrt(1/450*(5*sqrt(2) + 5*I - 6)^2 + 1/450*(5*sqrt(2) - 10*I + 3)^2 + 1/450*(10*sqrt(2) - 5*I - 3)^2)
     168        sqrt(1/450*(10*sqrt(2) - 5*I - 3)^2 + 1/450*(5*sqrt(2) - 10*I + 3)^2 + 1/450*(5*sqrt(2) + 5*I - 6)^2)
    169169        sage: std([RIF(1.0103, 1.0103), RIF(2)])
    170170        0.6998235813403261?
    171171        sage: import numpy
     
    230230        sage: variance([])
    231231        NaN
    232232        sage: variance([I, sqrt(2), 3/5])
    233         1/450*(5*sqrt(2) + 5*I - 6)^2 + 1/450*(5*sqrt(2) - 10*I + 3)^2 + 1/450*(10*sqrt(2) - 5*I - 3)^2
     233        1/450*(10*sqrt(2) - 5*I - 3)^2 + 1/450*(5*sqrt(2) - 10*I + 3)^2 + 1/450*(5*sqrt(2) + 5*I - 6)^2
    234234        sage: variance([RIF(1.0103, 1.0103), RIF(2)])
    235235        0.4897530450000000?
    236236        sage: import numpy
  • sage/symbolic/callable.py

    diff --git a/sage/symbolic/callable.py b/sage/symbolic/callable.py
    a b  
    1515    sage: f(x, y, z) = sin(x+y+z)
    1616    sage: g(w, t) = cos(w - t)
    1717    sage: f + g
    18     (t, w, x, y, z) |--> sin(x + y + z) + cos(-t + w)
     18    (t, w, x, y, z) |--> cos(-t + w) + sin(x + y + z)
    1919
    2020::
    2121
  • sage/symbolic/constants.py

    diff --git a/sage/symbolic/constants.py b/sage/symbolic/constants.py
    a b  
    130130    sage: f^2
    131131    (I*e + I)^2
    132132    sage: _.expand()
    133     -2*e - e^2 - 1
     133    -e^2 - 2*e - 1
    134134   
    135135::
    136136
     
    180180floating point rings::
    181181
    182182    sage: a = pi + e + golden_ratio + log2 + euler_gamma + catalan + khinchin + twinprime + mertens; a
    183     pi + euler_gamma + catalan + golden_ratio + log2 + khinchin + twinprime + mertens + e
     183    mertens + twinprime + khinchin + log2 + golden_ratio + catalan + euler_gamma + pi + e
    184184    sage: parent(a)
    185185    Symbolic Ring
    186     sage: RR(a)
     186    sage: RR(a) #abstol 1e11
    187187    13.2713479401972
    188188    sage: RealField(212)(a)
    189189    13.2713479401972493100988191995758139408711068200030748178329712
    190190    sage: RealField(230)(a)
    191191    13.271347940197249310098819199575813940871106820003074817832971189555
    192     sage: CC(a)
     192    sage: CC(a) #abstol 1e11
    193193    13.2713479401972
    194194    sage: CDF(a)
    195195    13.2713479402
  • sage/symbolic/expression.pyx

    diff --git a/sage/symbolic/expression.pyx b/sage/symbolic/expression.pyx
    a b  
    7878    sage: var('a,b,c')
    7979    (a, b, c)
    8080    sage: expand((u + v + a + b + c)^2)
    81     a^2 + 2*a*b + 2*a*c + 2*a*u + 2*a*v + b^2 + 2*b*c + 2*b*u + 2*b*v + c^2 + 2*c*u + 2*c*v + u^2 + 2*u*v + v^2
     81    a^2 + 2*a*b + b^2 + 2*a*c + 2*b*c + c^2 + 2*a*u + 2*b*u + 2*c*u + u^2 + 2*a*v + 2*b*v + 2*c*v + 2*u*v + v^2
    8282
    8383TESTS:
    8484
     
    108108    sage: t*u
    109109    1
    110110    sage: t + u
    111     e^sqrt(x) + e^(-sqrt(x))
     111    e^(-sqrt(x)) + e^sqrt(x)
    112112    sage: t
    113113    e^sqrt(x)
    114114
     
    120120    sage: a.real_part()
    121121    4*sqrt(3)/(sqrt(3) + 5)
    122122    sage: a.imag_part()
    123     sqrt(abs(4*(sqrt(3) - 5)*(sqrt(3) + 5) + 48))/(sqrt(3) + 5)
     123    sqrt(abs(4*(sqrt(3) + 5)*(sqrt(3) - 5) + 48))/(sqrt(3) + 5)
    124124"""
    125125
    126126###############################################################################
     
    327327            sage: t = 2*x*y^z+3
    328328            sage: u = loads(dumps(t)) # indirect doctest
    329329            sage: u
    330             2*y^z*x + 3
     330            2*x*y^z + 3
    331331            sage: bool(t == u)
    332332            True
    333333            sage: u.subs(x=z)
     
    529529        EXAMPLES::
    530530       
    531531            sage: gap(e + pi^2 + x^3)
    532             pi^2 + x^3 + e
     532            x^3 + pi^2 + e
    533533        """
    534534        return '"%s"'%repr(self)
    535535
     
    541541        EXAMPLES::
    542542       
    543543            sage: singular(e + pi^2 + x^3)
    544             pi^2 + x^3 + e
     544            x^3 + pi^2 + e
    545545        """
    546546        return '"%s"'%repr(self)
    547547
     
    557557            sage: x = var('x')                     
    558558            sage: f = sin(cos(x^2) + log(x))
    559559            sage: f._magma_init_(magma)
    560             '"sin(log(x) + cos(x^2))"'
     560            '"sin(cos(x^2) + log(x))"'
    561561            sage: magma(f)                         # optional - magma
    562562            sin(log(x) + cos(x^2))
    563563            sage: magma(f).Type()                  # optional - magma
     
    576576            sage: latex(y + 3*(x^(-1)))
    577577            y + \frac{3}{x}
    578578            sage: latex(x^(y+z^(1/y)))
    579             x^{z^{\left(\frac{1}{y}\right)} + y}
     579            x^{y + z^{\left(\frac{1}{y}\right)}}
    580580            sage: latex(1/sqrt(x+y))
    581581            \frac{1}{\sqrt{x + y}}
    582582            sage: latex(sin(x*(z+y)^x))
    583             \sin\left({\left(y + z\right)}^{x} x\right)
     583            \sin\left(x {\left(y + z\right)}^{x}\right)
    584584            sage: latex(3/2*(x+y)/z/y)
    585585            \frac{3 \, {\left(x + y\right)}}{2 \, y z}
    586586            sage: latex((2^(x^y)))
     
    590590            sage: latex((x*y).conjugate())
    591591            \overline{x} \overline{y}
    592592            sage: latex(x*(1/(x^2)+sqrt(x^7)))
    593             {\left(\sqrt{x^{7}} + \frac{1}{x^{2}}\right)} x
     593            x {\left(\sqrt{x^{7}} + \frac{1}{x^{2}}\right)}
    594594
    595595        Check spacing of coefficients of mul expressions (#3202)::
    596596
     
    653653            sage: latex((x+2)/(x^3+1))
    654654            \frac{x + 2}{x^{3} + 1}
    655655            sage: latex((x+2)*(x+1)/(x^3+1))
    656             \frac{{\left(x + 1\right)} {\left(x + 2\right)}}{x^{3} + 1}
     656            \frac{{\left(x + 2\right)} {\left(x + 1\right)}}{x^{3} + 1}
    657657            sage: latex((x+2)/(x^3+1)/(x+1))
    658             \frac{x + 2}{{\left(x + 1\right)} {\left(x^{3} + 1\right)}}
     658            \frac{x + 2}{{\left(x^{3} + 1\right)} {\left(x + 1\right)}}
    659659
    660660        Check that the sign is correct (#9086)::
    661661
     
    12361236            sage: x^3 -y == y + x
    12371237            x^3 - y == x + y
    12381238            sage: x^3 - y^10 >= y + x^10
    1239             x^3 - y^10 >= x^10 + y
     1239            -y^10 + x^3 >= x^10 + y
    12401240            sage: x^2 > x
    12411241            x^2 > x
    12421242
     
    13911391            sage: v,c = var('v,c')
    13921392            sage: assume(c != 0)
    13931393            sage: integral((1+v^2/c^2)^3/(1-v^2/c^2)^(3/2),v)
    1394             -17/8*v^3/(sqrt(-v^2/c^2 + 1)*c^2) - 1/4*v^5/(sqrt(-v^2/c^2 + 1)*c^4) + 83/8*v/sqrt(-v^2/c^2 + 1) - 75/8*arcsin(v/(c^2*sqrt(c^(-2))))/sqrt(c^(-2))
     1394            83/8*v/sqrt(-v^2/c^2 + 1) - 17/8*v^3/(c^2*sqrt(-v^2/c^2 + 1)) - 1/4*v^5/(c^4*sqrt(-v^2/c^2 + 1)) - 75/8*arcsin(v/(c^2*sqrt(c^(-2))))/sqrt(c^(-2))
    13951395            sage: forget()
    13961396        """
    13971397        from sage.symbolic.assumptions import _assumptions
     
    25082508
    25092509            # check if comparison of constant terms in Pynac add objects work
    25102510            sage: (y-1)*(y-2)
    2511             (y - 2)*(y - 1)
     2511            (y - 1)*(y - 2)
    25122512
    25132513        Check if Pynac can compute inverses of Python longs (:trac:`13107`)::
    25142514
     
    27572757       
    27582758            sage: x,y = var('x,y')
    27592759            sage: x.__cmp__(y)
    2760             -1
     2760            1
    27612761            sage: x < y
    27622762            x < y
    27632763            sage: cmp(x,y)
    2764             -1
     2764            1
    27652765            sage: cmp(SR(0.5), SR(0.7))
    27662766            -1
    27672767            sage: SR(0.5) < SR(0.7)
     
    30283028       
    30293029            sage: h = sin(x)/cos(x)
    30303030            sage: derivative(h,x,x,x)
    3031             6*sin(x)^4/cos(x)^4 + 8*sin(x)^2/cos(x)^2 + 2
     3031            8*sin(x)^2/cos(x)^2 + 6*sin(x)^4/cos(x)^4 + 2
    30323032            sage: derivative(h,x,3)
    3033             6*sin(x)^4/cos(x)^4 + 8*sin(x)^2/cos(x)^2 + 2
     3033            8*sin(x)^2/cos(x)^2 + 6*sin(x)^4/cos(x)^4 + 2
    30343034
    30353035        ::
    30363036       
     
    30383038            (x, y)
    30393039            sage: u = (sin(x) + cos(y))*(cos(x) - sin(y))
    30403040            sage: derivative(u,x,y)
    3041             sin(x)*sin(y) - cos(x)*cos(y)           
     3041            -cos(x)*cos(y) + sin(x)*sin(y)
    30423042            sage: f = ((x^2+1)/(x^2-1))^(1/4)
    30433043            sage: g = derivative(f, x); g # this is a complex expression
    3044             1/2*(x/(x^2 - 1) - (x^2 + 1)*x/(x^2 - 1)^2)/((x^2 + 1)/(x^2 - 1))^(3/4)
     3044            -1/2*((x^2 + 1)*x/(x^2 - 1)^2 - x/(x^2 - 1))/((x^2 + 1)/(x^2 - 1))^(3/4)
    30453045            sage: g.factor()
    3046             -x/((x - 1)^2*(x + 1)^2*((x^2 + 1)/(x^2 - 1))^(3/4))
     3046            -x/((x + 1)^2*(x - 1)^2*((x^2 + 1)/(x^2 - 1))^(3/4))
    30473047 
    30483048        ::
    30493049       
    30503050            sage: y = var('y')
    30513051            sage: f = y^(sin(x))
    30523052            sage: derivative(f, x)
    3053             y^sin(x)*log(y)*cos(x)
     3053            y^sin(x)*cos(x)*log(y)
    30543054       
    30553055        ::
    30563056       
     
    30683068       
    30693069            sage: g = 1/(sqrt((x^2-1)*(x+5)^6))
    30703070            sage: derivative(g, x)
    3071             -((x + 5)^6*x + 3*(x + 5)^5*(x^2 - 1))/((x + 5)^6*(x^2 - 1))^(3/2)
     3071            -((x + 5)^6*x + 3*(x^2 - 1)*(x + 5)^5)/((x^2 - 1)*(x + 5)^6)^(3/2)
    30723072
    30733073        TESTS::
    30743074       
     
    32423242            sage: g = f.series(x==1, 4); g
    32433243            (-sin(y) - 1) + (-2*sin(y) - 2)*(x - 1) + (-sin(y) + 3)*(x - 1)^2 + 1*(x - 1)^3
    32443244            sage: h = g.truncate(); h
    3245             -(sin(y) - 3)*(x - 1)^2 + (x - 1)^3 - 2*(sin(y) + 1)*(x - 1) - sin(y) - 1
     3245            (x - 1)^3 - (x - 1)^2*(sin(y) - 3) - 2*(x - 1)*(sin(y) + 1) - sin(y) - 1
    32463246            sage: h.expand()
    32473247            x^3 - x^2*sin(y) - 5*x + 3
    32483248
     
    32523252            sage: f.series(x,7)
    32533253            1*x^(-1) + (-1/6)*x + 1/120*x^3 + (-1/5040)*x^5 + Order(x^7)
    32543254            sage: f.series(x==1,3)
    3255             (sin(1)) + (-2*sin(1) + cos(1))*(x - 1) + (5/2*sin(1) - 2*cos(1))*(x - 1)^2 + Order((x - 1)^3)
     3255            (sin(1)) + (cos(1) - 2*sin(1))*(x - 1) + (-2*cos(1) + 5/2*sin(1))*(x - 1)^2 + Order((x - 1)^3)
    32563256            sage: f.series(x==1,3).truncate().expand()
    3257             5/2*x^2*sin(1) - 2*x^2*cos(1) - 7*x*sin(1) + 5*x*cos(1) + 11/2*sin(1) - 3*cos(1)
     3257            -2*x^2*cos(1) + 5/2*x^2*sin(1) + 5*x*cos(1) - 7*x*sin(1) - 3*cos(1) + 11/2*sin(1)
    32583258
    32593259        Following the GiNaC tutorial, we use John Machin's amazing
    32603260        formula `\pi = 16 \tan^{-1}(1/5) - 4 \tan^{-1}(1/239)` to compute
     
    33053305            sage: var('a, x, z')
    33063306            (a, x, z)
    33073307            sage: taylor(a*log(z), z, 2, 3)
    3308             1/24*(z - 2)^3*a - 1/8*(z - 2)^2*a + 1/2*(z - 2)*a + a*log(2)
     3308            1/24*a*(z - 2)^3 - 1/8*a*(z - 2)^2 + 1/2*a*(z - 2) + a*log(2)
    33093309
    33103310        ::
    33113311
     
    33423342        Check that ticket #7472 is fixed (Taylor polynomial in more variables)::
    33433343 
    33443344            sage: x,y=var('x y'); taylor(x*y^3,(x,1),(y,1),4)
    3345             (y - 1)^3*(x - 1) + (y - 1)^3 + 3*(y - 1)^2*(x - 1) + 3*(y - 1)^2 + 3*(y - 1)*(x - 1) + x + 3*y - 3
     3345            (x - 1)*(y - 1)^3 + 3*(x - 1)*(y - 1)^2 + (y - 1)^3 + 3*(x - 1)*(y - 1) + 3*(y - 1)^2 + x + 3*y - 3
    33463346            sage: expand(_)
    33473347            x*y^3
    33483348
     
    33873387            sage: f.series(x,7).truncate()
    33883388            -1/5040*x^5 + 1/120*x^3 - 1/6*x + 1/x
    33893389            sage: f.series(x==1,3).truncate().expand()
    3390             5/2*x^2*sin(1) - 2*x^2*cos(1) - 7*x*sin(1) + 5*x*cos(1) + 11/2*sin(1) - 3*cos(1)
     3390            -2*x^2*cos(1) + 5/2*x^2*sin(1) + 5*x*cos(1) - 7*x*sin(1) - 3*cos(1) + 11/2*sin(1)
    33913391        """
    33923392        if not is_a_series(self._gobj):
    33933393            return self
     
    34383438            sage: ((x + (2/3)*y)^3).expand()
    34393439            x^3 + 2*x^2*y + 4/3*x*y^2 + 8/27*y^3
    34403440            sage: expand( (x*sin(x) - cos(y)/x)^2 )
    3441             x^2*sin(x)^2 - 2*sin(x)*cos(y) + cos(y)^2/x^2
     3441            x^2*sin(x)^2 - 2*cos(y)*sin(x) + cos(y)^2/x^2
    34423442            sage: f = (x-y)*(x+y); f
    3443             (x - y)*(x + y)
     3443            (x + y)*(x - y)
    34443444            sage: f.expand()
    34453445            x^2 - y^2
    34463446        """
     
    34973497        EXAMPLES::
    34983498       
    34993499            sage: sin(5*x).expand_trig()
    3500             sin(x)^5 - 10*sin(x)^3*cos(x)^2 + 5*sin(x)*cos(x)^4
     3500            5*cos(x)^4*sin(x) - 10*cos(x)^2*sin(x)^3 + sin(x)^5
    35013501            sage: cos(2*x + var('y')).expand_trig()
    3502             -sin(2*x)*sin(y) + cos(2*x)*cos(y)
     3502            cos(2*x)*cos(y) - sin(2*x)*sin(y)
    35033503       
    35043504        We illustrate various options to this function::
    35053505       
    35063506            sage: f = sin(sin(3*cos(2*x))*x)
    35073507            sage: f.expand_trig()
    3508             sin(-(sin(cos(2*x))^3 - 3*sin(cos(2*x))*cos(cos(2*x))^2)*x)
     3508            sin((3*cos(cos(2*x))^2*sin(cos(2*x)) - sin(cos(2*x))^3)*x)
    35093509            sage: f.expand_trig(full=True)
    3510             sin(((sin(sin(x)^2)*cos(cos(x)^2) - sin(cos(x)^2)*cos(sin(x)^2))^3 - 3*(sin(sin(x)^2)*cos(cos(x)^2) - sin(cos(x)^2)*cos(sin(x)^2))*(sin(sin(x)^2)*sin(cos(x)^2) + cos(sin(x)^2)*cos(cos(x)^2))^2)*x)
     3510            sin((3*(cos(cos(x)^2)*cos(sin(x)^2) + sin(cos(x)^2)*sin(sin(x)^2))^2*(cos(sin(x)^2)*sin(cos(x)^2) - cos(cos(x)^2)*sin(sin(x)^2)) - (cos(sin(x)^2)*sin(cos(x)^2) - cos(cos(x)^2)*sin(sin(x)^2))^3)*x)
    35113511            sage: sin(2*x).expand_trig(times=False)
    35123512            sin(2*x)
    35133513            sage: sin(2*x).expand_trig(times=True)
    3514             2*sin(x)*cos(x)
     3514            2*cos(x)*sin(x)
    35153515            sage: sin(2 + x).expand_trig(plus=False)
    35163516            sin(x + 2)
    35173517            sage: sin(2 + x).expand_trig(plus=True)
    3518             sin(2)*cos(x) + sin(x)*cos(2)
     3518            cos(x)*sin(2) + cos(2)*sin(x)
    35193519            sage: sin(x/2).expand_trig(half_angles=False)
    35203520            sin(1/2*x)
    35213521            sage: sin(x/2).expand_trig(half_angles=True)
    3522             sqrt(-1/2*cos(x) + 1/2)*(-1)^floor(1/2*x/pi)
     3522            (-1)^floor(1/2*x/pi)*sqrt(-1/2*cos(x) + 1/2)
    35233523
    35243524        ALIASES:
    35253525
     
    35603560            sage: y=var('y')
    35613561            sage: f=sin(x)*cos(x)^3+sin(y)^2
    35623562            sage: f.reduce_trig()
    3563             1/4*sin(2*x) + 1/8*sin(4*x) - 1/2*cos(2*y) + 1/2
     3563            -1/2*cos(2*y) + 1/8*sin(4*x) + 1/4*sin(2*x) + 1/2
    35643564
    35653565        To reduce only the expressions involving x we use optional parameter::
    35663566
    35673567            sage: f.reduce_trig(x)
    3568             sin(y)^2 + 1/4*sin(2*x) + 1/8*sin(4*x)
     3568            sin(y)^2 + 1/8*sin(4*x) + 1/4*sin(2*x)
    35693569
    35703570        ALIASES: :meth:`trig_reduce` and :meth:`reduce_trig` are the same
    35713571        """
     
    36213621            {$0: x + y}
    36223622            sage: t = ((a+b)*(a+c)).match((a+w0)*(a+w1))
    36233623            sage: t[w0], t[w1]
    3624             (b, c)
     3624            (c, b)
    36253625            sage: ((a+b)*(a+c)).match((w0+b)*(w0+c))
    36263626            {$0: a}
    3627             sage: print ((a+b)*(a+c)).match((w0+w1)*(w0+w2))    # surprising?
     3627            sage: t = ((a+b)*(a+c)).match((w0+w1)*(w0+w2))
     3628            sage: t[w0], t[w1], t[w2]
     3629            (a, c, b)
     3630            sage: print ((a+b)*(a+c)).match((w0+w1)*(w1+w2))
    36283631            None
    36293632            sage: t = (a*(x+y)+a*z+b).match(a*w0+w1)
    36303633            sage: t[w0], t[w1]
     
    36903693            sage: w0 = SR.wild(0); w1 = SR.wild(1)
    36913694
    36923695            sage: (sin(x)*sin(y)).find(sin(w0))
    3693             [sin(x), sin(y)]
     3696            [sin(y), sin(x)]
    36943697
    36953698            sage: ((sin(x)+sin(y))*(a+b)).expand().find(sin(w0))
    3696             [sin(x), sin(y)]
     3699            [sin(y), sin(x)]
    36973700
    36983701            sage: (1+x+x^2+x^3).find(x)
    36993702            [x]
    37003703            sage: (1+x+x^2+x^3).find(x^w0)
    3701             [x^3, x^2]
     3704            [x^2, x^3]
    37023705
    37033706            sage: (1+x+x^2+x^3).find(y)
    37043707            []
     
    37153718        while itr.is_not_equal(found.end()):
    37163719            res.append(new_Expression_from_GEx(self._parent, itr.obj()))
    37173720            itr.inc()
     3721        res.sort(cmp)
    37183722        return res
    37193723
    37203724    def has(self, pattern):
     
    37853789            (x + y)^3 + b^2 + c
    37863790
    37873791            sage: t.subs({w0^2: w0^3})
    3788             (x + y)^3 + a^3 + b^3
     3792            a^3 + b^3 + (x + y)^3
    37893793
    37903794            # substitute with a relational expression
    37913795            sage: t.subs(w0^2 == w0^3)
    3792             (x + y)^3 + a^3 + b^3
     3796            a^3 + b^3 + (x + y)^3
    37933797
    37943798            sage: t.subs(w0==w0^2)
    37953799            (x^2 + y^2)^18 + a^16 + b^16           
     
    39073911            (x, y, z, a, b, c, d, f)
    39083912            sage: w0 = SR.wild(0); w1 = SR.wild(1)
    39093913            sage: (a^2 + b^2 + (x+y)^2)._subs_expr(w0^2 == w0^3)
    3910             (x + y)^3 + a^3 + b^3
     3914            a^3 + b^3 + (x + y)^3
    39113915            sage: (a^4 + b^4 + (x+y)^4)._subs_expr(w0^2 == w0^3)
    3912             (x + y)^4 + a^4 + b^4
     3916            a^4 + b^4 + (x + y)^4
    39133917            sage: (a^2 + b^4 + (x+y)^4)._subs_expr(w0^2 == w0^3)
    3914             (x + y)^4 + a^3 + b^4
     3918            b^4 + (x + y)^4 + a^3
    39153919            sage: ((a+b+c)^2)._subs_expr(a+b == x)
    39163920            (a + b + c)^2
    39173921            sage: ((a+b+c)^2)._subs_expr(a+b+w0 == x+w0)
     
    39353939            sage: (sin(x)^2 + cos(x)^2)._subs_expr(sin(w0)^2+cos(w0)^2==1)
    39363940            1
    39373941            sage: (1 + sin(x)^2 + cos(x)^2)._subs_expr(sin(w0)^2+cos(w0)^2==1)
    3938             sin(x)^2 + cos(x)^2 + 1
     3942            cos(x)^2 + sin(x)^2 + 1
    39393943            sage: (17*x + sin(x)^2 + cos(x)^2)._subs_expr(w1 + sin(w0)^2+cos(w0)^2 == w1 + 1)
    39403944            17*x + 1
    39413945            sage: ((x-1)*(sin(x)^2 + cos(x)^2)^2)._subs_expr(sin(w0)^2+cos(w0)^2 == 1)
     
    39823986            x^4 + x
    39833987            sage: f = cos(x^2) + sin(x^2)
    39843988            sage: f.subs_expr(x^2 == x)
    3985             sin(x) + cos(x)
     3989            cos(x) + sin(x)
    39863990       
    39873991        ::
    39883992       
    39893993            sage: f(x,y,t) = cos(x) + sin(y) + x^2 + y^2 + t
    39903994            sage: f.subs_expr(y^2 == t)
    3991             (x, y, t) |--> x^2 + 2*t + sin(y) + cos(x)
     3995            (x, y, t) |--> x^2 + 2*t + cos(x) + sin(y)
    39923996       
    39933997        The following seems really weird, but it *is* what Maple does::
    39943998       
    39953999            sage: f.subs_expr(x^2 + y^2 == t)
    3996             (x, y, t) |--> x^2 + y^2 + t + sin(y) + cos(x)
     4000            (x, y, t) |--> x^2 + y^2 + t + cos(x) + sin(y)
    39974001            sage: maple.eval('subs(x^2 + y^2 = t, cos(x) + sin(y) + x^2 + y^2 + t)')          # optional - maple
    39984002            'cos(x)+sin(y)+x^2+y^2+t'
    39994003            sage: maxima.quit()
     
    40424046            sage: var('x,y,z')
    40434047            (x, y, z)
    40444048            sage: (x+y)(x=z^2, y=x^y)
    4045             x^y + z^2
     4049            z^2 + x^y
    40464050        """
    40474051        return self._parent._call_element_(self, *args, **kwds)
    40484052
     
    41804184            sage: var('a,b,c,x,y')
    41814185            (a, b, c, x, y)
    41824186            sage: (a^2 + b^2 + (x+y)^2).operands()
    4183             [(x + y)^2, a^2, b^2]
     4187            [a^2, b^2, (x + y)^2]
    41844188            sage: (a^2).operands()
    41854189            [a, 2]
    41864190            sage: (a*b^2*c).operands()
     
    45564560            sage: f
    45574561            (x, y) |--> x^n + y^n
    45584562            sage: f(2,3)
    4559             2^n + 3^n
     4563            3^n + 2^n
    45604564        """
    45614565        # we override type checking in CallableSymbolicExpressionRing,
    45624566        # since it checks for old SymbolicVariable's
     
    46134617            sage: x.add(x, hold=True)
    46144618            x + x
    46154619            sage: x.add(x, (2+x), hold=True)
    4616             x + x + (x + 2)
     4620            (x + 2) + x + x
    46174621            sage: x.add(x, (2+x), x, hold=True)
    4618             x + x + (x + 2) + x
     4622            (x + 2) + x + x + x
    46194623            sage: x.add(x, (2+x), x, 2*x, hold=True)
    4620             x + x + (x + 2) + x + 2*x
     4624            (x + 2) + 2*x + x + x + x
    46214625
    46224626        To then evaluate again, we currently must use Maxima via
    46234627        :meth:`simplify`::
     
    46464650            sage: x.mul(x, hold=True)
    46474651            x*x
    46484652            sage: x.mul(x, (2+x), hold=True)
    4649             x*x*(x + 2)
     4653            (x + 2)*x*x
    46504654            sage: x.mul(x, (2+x), x, hold=True)
    4651             x*x*(x + 2)*x
     4655            (x + 2)*x*x*x
    46524656            sage: x.mul(x, (2+x), x, 2*x, hold=True)
    4653             x*x*(x + 2)*x*(2*x)
     4657            (2*x)*(x + 2)*x*x*x
    46544658
    46554659        To then evaluate again, we currently must use Maxima via
    46564660        :meth:`simplify`::
     
    47104714            sage: f.coefficient(sin(x*y))
    47114715            x^3 + 2/x
    47124716            sage: f.collect(sin(x*y))
    4713             (x^3 + 2/x)*sin(x*y) + a*x + x*y + x/y + 100
     4717            a*x + x*y + (x^3 + 2/x)*sin(x*y) + x/y + 100
    47144718
    47154719            sage: var('a, x, y, z')
    47164720            (a, x, y, z)
     
    48974901            sage: bool(p.poly(a) == (x-a*sqrt(2))^2 + x + 1)
    48984902            True           
    48994903            sage: p.poly(x)
    4900             -(2*sqrt(2)*a - 1)*x + 2*a^2 + x^2 + 1
     4904            2*a^2 - (2*sqrt(2)*a - 1)*x + x^2 + 1
    49014905        """
    49024906        from sage.symbolic.ring import SR
    49034907        f = self._maxima_()
     
    50435047            sage: R = SR[x]
    50445048            sage: a = R(sqrt(2) + x^3 + y)
    50455049            sage: a
    5046             y + sqrt(2) + x^3
     5050            x^3 + y + sqrt(2)
    50475051            sage: type(a)
    50485052            <class 'sage.rings.polynomial.polynomial_element_generic.Polynomial_generic_dense_field'>
    50495053            sage: a.degree()
     
    52135217            sage: lcm(x^100-y^100, x^10-y^10)
    52145218            -x^100 + y^100
    52155219            sage: lcm(expand( (x^2+17*x+3/7*y)*(x^5 - 17*y + 2/3) ), expand((x^13+17*x+3/7*y)*(x^5 - 17*y + 2/3)) )
    5216             1/21*(21*x^7 + 357*x^6 + 9*x^5*y - 357*x^2*y + 14*x^2 - 6069*x*y - 153*y^2 + 238*x + 6*y)*(21*x^18 - 357*x^13*y + 14*x^13 + 357*x^6 + 9*x^5*y - 6069*x*y - 153*y^2 + 238*x + 6*y)/(3*x^5 - 51*y + 2)
     5220             1/21*(21*x^18 - 357*x^13*y + 14*x^13 + 357*x^6 + 9*x^5*y -
     5221                     6069*x*y - 153*y^2 + 238*x + 6*y)*(21*x^7 + 357*x^6 +
     5222                             9*x^5*y - 357*x^2*y + 14*x^2 - 6069*x*y -
     5223                             153*y^2 + 238*x + 6*y)/(3*x^5 - 51*y + 2)
    52175224           
    52185225        TESTS:
    52195226       
     
    52685275            sage: x,y,z = var('x,y,z')
    52695276            sage: f = 4*x*y + x*z + 20*y^2 + 21*y*z + 4*z^2 + x^2*y^2*z^2
    52705277            sage: f.collect(x)
    5271             x^2*y^2*z^2 + (4*y + z)*x + 20*y^2 + 21*y*z + 4*z^2
     5278            x^2*y^2*z^2 + x*(4*y + z) + 20*y^2 + 21*y*z + 4*z^2
    52725279
    52735280        Here we do the same thing for `y` and `z`; however, note that
    52745281        we don't factor the `y^{2}` and `z^{2}` terms before
     
    52775284            sage: f.collect(y)
    52785285            (x^2*z^2 + 20)*y^2 + (4*x + 21*z)*y + x*z + 4*z^2
    52795286            sage: f.collect(z)
    5280             (x^2*y^2 + 4)*z^2 + (x + 21*y)*z + 4*x*y + 20*y^2
     5287            (x^2*y^2 + 4)*z^2 + 4*x*y + 20*y^2 + (x + 21*y)*z
    52815288
    52825289        Sometimes, we do have to call :meth:`expand()` on the
    52835290        expression first to achieve the desired result::
     
    52865293            sage: f.collect(x)
    52875294            x^2 + x*y - x*z - y*z
    52885295            sage: f.expand().collect(x)
    5289             (y - z)*x + x^2 - y*z
     5296            x^2 + x*(y - z) - y*z
    52905297
    52915298        TESTS:
    52925299
     
    56675674            (a, b)
    56685675            sage: f = log(a + b*I)
    56695676            sage: f.imag_part()
    5670             arctan2(real_part(b) + imag_part(a), real_part(a) - imag_part(b))
     5677            arctan2(imag_part(a) + real_part(b), -imag_part(b) + real_part(a))
    56715678
    56725679        Using the ``hold`` parameter it is possible to prevent automatic
    56735680        evaluation::
     
    62036210        To prevent automatic evaluation use the ``hold`` argument::
    62046211
    62056212            sage: arccosh(x).sinh()
    6206             sqrt(x - 1)*sqrt(x + 1)
     6213            sqrt(x + 1)*sqrt(x - 1)
    62076214            sage: arccosh(x).sinh(hold=True)
    62086215            sinh(arccosh(x))
    62096216
     
    62126219            sage: sinh(arccosh(x),hold=True)
    62136220            sinh(arccosh(x))
    62146221            sage: sinh(arccosh(x))
    6215             sqrt(x - 1)*sqrt(x + 1)
     6222            sqrt(x + 1)*sqrt(x - 1)
    62166223
    62176224        To then evaluate again, we currently must use Maxima via
    62186225        :meth:`simplify`::
    62196226
    62206227            sage: a = arccosh(x).sinh(hold=True); a.simplify()
    6221             sqrt(x - 1)*sqrt(x + 1)
     6228            sqrt(x + 1)*sqrt(x - 1)
    62226229
    62236230        TESTS::
    62246231
     
    66926699            sage: x.factorial()
    66936700            factorial(x)
    66946701            sage: (x^2+y^3).factorial()
    6695             factorial(x^2 + y^3)
     6702            factorial(y^3 + x^2)
    66966703
    66976704        To prevent automatic evaluation use the ``hold`` argument::
    66986705
     
    69866993
    69876994            sage: f = x*(x-1)/(x^2 - 7) + y^2/(x^2-7) + 1/(x+1) + b/a + c/a
    69886995            sage: f.normalize()
    6989             (a*x^3 + a*x*y^2 + b*x^3 + c*x^3 + a*x^2 + a*y^2 + b*x^2 + c*x^2 - a*x - 7*b*x - 7*c*x - 7*a - 7*b - 7*c)/((x + 1)*(x^2 - 7)*a)
     6996            (a*x^3 + b*x^3 + c*x^3 + a*x*y^2 + a*x^2 + b*x^2 + c*x^2 +
     6997                    a*y^2 - a*x - 7*b*x - 7*c*x - 7*a - 7*b - 7*c)/((x^2 -
     6998                        7)*a*(x + 1))
    69906999
    69917000        ALGORITHM: Uses GiNaC.
    69927001
     
    71087117            sage: f.numerator()
    71097118            sqrt(x) + sqrt(y) + sqrt(z)
    71107119            sage: f.denominator()
    7111             -sqrt(theta) + x^10 - y^10
     7120            x^10 - y^10 - sqrt(theta)
    71127121
    71137122            sage: f.numerator(normalize=False)
    7114             -(sqrt(x) + sqrt(y) + sqrt(z))
     7123            (sqrt(x) + sqrt(y) + sqrt(z))
    71157124            sage: f.denominator(normalize=False)
    7116             sqrt(theta) - x^10 + y^10
     7125            x^10 - y^10 - sqrt(theta)
    71177126
    71187127            sage: y = var('y')
    71197128            sage: g = x + y/(x + 2); g
     
    73217330        EXAMPLES::
    73227331
    73237332            sage: t = log(sqrt(2) - 1) + log(sqrt(2) + 1); t
    7324             log(sqrt(2) - 1) + log(sqrt(2) + 1)
     7333            log(sqrt(2) + 1) + log(sqrt(2) - 1)
    73257334            sage: res = t.maxima_methods().logcontract(); res
    7326             log((sqrt(2) - 1)*(sqrt(2) + 1))
     7335            log((sqrt(2) + 1)*(sqrt(2) - 1))
    73277336            sage: type(res)
    73287337            <type 'sage.symbolic.expression.Expression'>
    73297338        """
     
    73837392
    73847393            sage: f = e^(I*x)
    73857394            sage: f.rectform()
    7386             I*sin(x) + cos(x)
     7395            cos(x) + I*sin(x)
    73877396
    73887397        TESTS:
    73897398
     
    75107519        EXAMPLES::
    75117520       
    75127521            sage: f = sin(x)^2 + cos(x)^2; f
    7513             sin(x)^2 + cos(x)^2
     7522            cos(x)^2 + sin(x)^2
    75147523            sage: f.simplify()
    7515             sin(x)^2 + cos(x)^2
     7524            cos(x)^2 + sin(x)^2
    75167525            sage: f.simplify_trig()
    75177526            1
    75187527            sage: h = sin(x)*csc(x)
     
    75837592        ::
    75847593       
    75857594            sage: f = ((x - 1)^(3/2) - (x + 1)*sqrt(x - 1))/sqrt((x - 1)*(x + 1)); f
    7586             ((x - 1)^(3/2) - sqrt(x - 1)*(x + 1))/sqrt((x - 1)*(x + 1))
     7595            -((x + 1)*sqrt(x - 1) - (x - 1)^(3/2))/sqrt((x + 1)*(x - 1))
    75877596            sage: f.simplify_rational()
    75887597            -2*sqrt(x - 1)/sqrt(x^2 - 1)
    75897598
     
    76077616            sage: y = var('y')
    76087617            sage: g = (x^(y/2) + 1)^2*(x^(y/2) - 1)^2/(x^y - 1)
    76097618            sage: g.simplify_rational(algorithm='simple')
    7610             -(2*x^y - x^(2*y) - 1)/(x^y - 1)
     7619            (x^(2*y) - 2*x^y + 1)/(x^y - 1)
    76117620            sage: g.simplify_rational()
    76127621            x^y - 1
    76137622
     
    76187627            sage: f.simplify_rational()
    76197628            (2*x^2 + 5*x + 4)/(x^3 + 5*x^2 + 8*x + 4)
    76207629            sage: f.simplify_rational(algorithm='noexpand')
    7621             ((x + 1)*x + (x + 2)^2)/((x + 1)*(x + 2)^2)
    7622 
     7630            ((x + 2)^2 + (x + 1)*x)/((x + 2)^2*(x + 1))
    76237631        """
    76247632        self_m = self._maxima_()
    76257633        if algorithm == 'full':
     
    76717679        ::
    76727680
    76737681            sage: f = binomial(n, k)*factorial(k)*factorial(n-k); f
    7674             factorial(-k + n)*factorial(k)*binomial(n, k)
     7682            binomial(n, k)*factorial(k)*factorial(-k + n)
    76757683            sage: f.simplify_factorial()
    76767684            factorial(n)
    76777685       
    76787686        A more complicated example, which needs further processing::
    76797687
    76807688            sage: f = factorial(x)/factorial(x-2)/2 + factorial(x+1)/factorial(x)/2; f
    7681             1/2*factorial(x)/factorial(x - 2) + 1/2*factorial(x + 1)/factorial(x)
     7689            1/2*factorial(x + 1)/factorial(x) + 1/2*factorial(x)/factorial(x - 2)
    76827690            sage: g = f.simplify_factorial(); g
    76837691            1/2*(x - 1)*x + 1/2*x + 1/2
    76847692            sage: g.simplify_rational()
     
    77657773            sage: e1 = 1/(sqrt(5)+sqrt(2))
    77667774            sage: e2 = (sqrt(5)-sqrt(2))/3
    77677775            sage: e1.simplify_radical()
    7768             1/(sqrt(2) + sqrt(5))
     7776            1/(sqrt(5) + sqrt(2))
    77697777            sage: e2.simplify_radical()
    7770             -1/3*sqrt(2) + 1/3*sqrt(5)
     7778            1/3*sqrt(5) - 1/3*sqrt(2)
    77717779            sage: (e1-e2).simplify_radical()
    77727780            0
    77737781        """
     
    78647872
    78657873            sage: f = log(x)+log(y)-1/3*log((x+1))
    78667874            sage: f.simplify_log()
    7867             -1/3*log(x + 1) + log(x*y)
     7875            log(x*y) - 1/3*log(x + 1)
    78687876
    78697877            sage: f.simplify_log('ratios')
    78707878            log(x*y/(x + 1)^(1/3))
     
    78907898
    78917899            sage: log_expr = (log(sqrt(2)-1)+log(sqrt(2)+1))
    78927900            sage: log_expr.simplify_log('all')
    7893             log((sqrt(2) - 1)*(sqrt(2) + 1))
     7901            log((sqrt(2) + 1)*(sqrt(2) - 1))
    78947902            sage: _.simplify_rational()
    78957903            0
    78967904            sage: log_expr.simplify_full()   # applies both simplify_log and simplify_rational
     
    79857993        To expand also log(3/4) use ``algorithm='all'``::
    79867994
    79877995            sage: (log(3/4*x^pi)).log_expand('all')
    7988             pi*log(x) + log(3) - log(4)
     7996            pi*log(x) - log(4) + log(3)
    79897997
    79907998        To expand only the power use ``algorithm='powers'``.::
    79917999
     
    80088016            pi*log(x) + log(3/4)
    80098017
    80108018            sage: (log(3/4*x^pi)).log_expand('all')
    8011             pi*log(x) + log(3) - log(4)
     8019            pi*log(x) - log(4) + log(3)
    80128020
    80138021            sage: (log(3/4*x^pi)).log_expand()
    80148022            pi*log(x) + log(3/4)
     
    80798087       
    80808088            sage: x,y,z = var('x, y, z')
    80818089            sage: (x^3-y^3).factor()
    8082             (x - y)*(x^2 + x*y + y^2)
     8090            (x^2 + x*y + y^2)*(x - y)
    80838091            sage: factor(-8*y - 4*x + z^2*(2*y + x))
    8084             (z - 2)*(z + 2)*(x + 2*y)
     8092            (x + 2*y)*(z + 2)*(z - 2)
    80858093            sage: f = -1 - 2*x - x^2 + y^2 + 2*x*y^2 + x^2*y^2
    80868094            sage: F = factor(f/(36*(1 + 2*y + y^2)), dontfactor=[x]); F
    8087             1/36*(y - 1)*(x^2 + 2*x + 1)/(y + 1)
     8095            1/36*(x^2 + 2*x + 1)*(y - 1)/(y + 1)
    80888096
    80898097        If you are factoring a polynomial with rational coefficients (and
    80908098        dontfactor is empty) the factorization is done using Singular
     
    80948102            sage: var('x,y')
    80958103            (x, y)
    80968104            sage: (x^99 + y^99).factor()
    8097             (x + y)*(x^2 - x*y + y^2)*(x^6 - x^3*y^3 + y^6)*...
     8105            (x^60 + x^57*y^3 - x^51*y^9 - x^48*y^12 + x^42*y^18 + x^39*y^21 -
     8106            x^33*y^27 - x^30*y^30 - x^27*y^33 + x^21*y^39 + x^18*y^42 -
     8107            x^12*y^48 - x^9*y^51 + x^3*y^57 + y^60)*(x^20 + x^19*y -
     8108            x^17*y^3 - x^16*y^4 + x^14*y^6 + x^13*y^7 - x^11*y^9 -
     8109            x^10*y^10 - x^9*y^11 + x^7*y^13 + x^6*y^14 - x^4*y^16 -
     8110            x^3*y^17 + x*y^19 + y^20)*(x^10 - x^9*y + x^8*y^2 - x^7*y^3 +
     8111            x^6*y^4 - x^5*y^5 + x^4*y^6 - x^3*y^7 + x^2*y^8 - x*y^9 +
     8112            y^10)*(x^6 - x^3*y^3 + y^6)*(x^2 - x*y + y^2)*(x + y)
    80988113        """
    80998114        from sage.calculus.calculus import symbolic_expression_from_maxima_string, symbolic_expression_from_string
    81008115        if len(dontfactor) > 0:
     
    81358150            (x, y, z)
    81368151            sage: f = x^3-y^3
    81378152            sage: f.factor()
    8138             (x - y)*(x^2 + x*y + y^2)
     8153            (x^2 + x*y + y^2)*(x - y)
    81398154       
    81408155        Notice that the -1 factor is separated out::
    81418156       
    81428157            sage: f.factor_list()
    8143             [(x - y, 1), (x^2 + x*y + y^2, 1)]
     8158            [(x^2 + x*y + y^2, 1), (x - y, 1)]
    81448159       
    81458160        We factor a fairly straightforward expression::
    81468161       
    81478162            sage: factor(-8*y - 4*x + z^2*(2*y + x)).factor_list()
    8148             [(z - 2, 1), (z + 2, 1), (x + 2*y, 1)]
     8163            [(x + 2*y, 1), (z + 2, 1), (z - 2, 1)]
    81498164
    81508165        A more complicated example::
    81518166       
     
    81538168            (x, u, v)
    81548169            sage: f = expand((2*u*v^2-v^2-4*u^3)^2 * (-u)^3 * (x-sin(x))^3)
    81558170            sage: f.factor()
    8156             -(x - sin(x))^3*(4*u^3 - 2*u*v^2 + v^2)^2*u^3
     8171            -(4*u^3 - 2*u*v^2 + v^2)^2*u^3*(x - sin(x))^3
    81578172            sage: g = f.factor_list(); g                     
    8158             [(x - sin(x), 3), (4*u^3 - 2*u*v^2 + v^2, 2), (u, 3), (-1, 1)]
     8173            [(4*u^3 - 2*u*v^2 + v^2, 2), (u, 3), (x - sin(x), 3), (-1, 1)]
    81598174
    81608175        This function also works for quotients::
    81618176       
     
    81638178            sage: g = f/(36*(1 + 2*y + y^2)); g
    81648179            1/36*(x^2*y^2 + 2*x*y^2 - x^2 + y^2 - 2*x - 1)/(y^2 + 2*y + 1)
    81658180            sage: g.factor(dontfactor=[x])
    8166             1/36*(y - 1)*(x^2 + 2*x + 1)/(y + 1)
     8181            1/36*(x^2 + 2*x + 1)*(y - 1)/(y + 1)
    81678182            sage: g.factor_list(dontfactor=[x])
    8168             [(y - 1, 1), (y + 1, -1), (x^2 + 2*x + 1, 1), (1/36, 1)]
     8183            [(x^2 + 2*x + 1, 1), (y + 1, -1), (y - 1, 1), (1/36, 1)]
    81698184                   
    81708185        This example also illustrates that the exponents do not have to be
    81718186        integers::
     
    81888203        EXAMPLES::
    81898204       
    81908205            sage: g = factor(x^3 - 1); g
    8191             (x - 1)*(x^2 + x + 1)
     8206            (x^2 + x + 1)*(x - 1)
    81928207            sage: v = g._factor_list(); v
    8193             [(x - 1, 1), (x^2 + x + 1, 1)]
     8208            [(x^2 + x + 1, 1), (x - 1, 1)]
    81948209            sage: type(v)
    81958210            <type 'list'>
    81968211        """
     
    83738388            sage: var('a,b,c,x')
    83748389            (a, b, c, x)
    83758390            sage: (a*x^2 + b*x + c).roots(x)
    8376             [(-1/2*(b + sqrt(-4*a*c + b^2))/a, 1), (-1/2*(b - sqrt(-4*a*c + b^2))/a, 1)]
     8391            [(-1/2*(b + sqrt(b^2 - 4*a*c))/a, 1), (-1/2*(b - sqrt(b^2 - 4*a*c))/a, 1)]
    83778392
    83788393        By default, all the roots are required to be explicit rather than
    83798394        implicit. To get implicit roots, pass ``explicit_solutions=False``
     
    83878402            ...
    83888403            RuntimeError: no explicit roots found
    83898404            sage: f.roots(explicit_solutions=False)
    8390             [((2^(8/9) - 2^(1/9) + x^(8/9) - x^(1/9))/(2^(8/9) - 2^(1/9)), 1)]
     8405            [((2^(8/9) + x^(8/9) - 2^(1/9) - x^(1/9))/(2^(8/9) - 2^(1/9)), 1)]
    83918406
    83928407        Another example, but involving a degree 5 poly whose roots don't
    83938408        get computed explicitly::
     
    84338448            (f6, f5, f4, x)
    84348449            sage: e=15*f6*x^2 + 5*f5*x + f4
    84358450            sage: res = e.roots(x); res
    8436             [(-1/30*(5*f5 + sqrt(-60*f4*f6 + 25*f5^2))/f6, 1), (-1/30*(5*f5 - sqrt(-60*f4*f6 + 25*f5^2))/f6, 1)]
     8451            [(-1/30*(5*f5 + sqrt(25*f5^2 - 60*f4*f6))/f6, 1), (-1/30*(5*f5 - sqrt(25*f5^2 - 60*f4*f6))/f6, 1)]
    84378452            sage: e.subs(x=res[0][0]).is_zero()
    84388453            True
    84398454        """
     
    88818896            sage: a.solve(t)
    88828897            []
    88838898            sage: b = a.simplify_radical(); b
    8884             -23040*(25.0*e^(900*t) - 2.0*e^(1800*t) - 32.0)*e^(-2400*t)
     8899            -23040*(-2.0*e^(1800*t) + 25.0*e^(900*t) - 32.0)*e^(-2400*t)
    88858900            sage: b.solve(t)
    88868901            []
    88878902            sage: b.solve(t, to_poly_solve=True)
     
    92619276        ::
    92629277
    92639278            sage: (k * binomial(n, k)).sum(k, 1, n)
    9264             n*2^(n - 1)
     9279            2^(n - 1)*n
    92659280
    92669281        ::
    92679282
     
    95309545            sage: f*(-2/3)
    95319546            -2/3*x - 2 < -2/3*y + 4/3
    95329547            sage: f*(-pi)
    9533             -(x + 3)*pi < -(y - 2)*pi
     9548            -pi*(x + 3) < -pi*(y - 2)
    95349549
    95359550        Since the direction of the inequality never changes when doing
    95369551        arithmetic with equations, you can multiply or divide the
  • sage/symbolic/expression_conversions.py

    diff --git a/sage/symbolic/expression_conversions.py b/sage/symbolic/expression_conversions.py
    a b  
    232232            sage: c.get_fake_div(-x)
    233233            FakeExpression([x], <built-in function neg>)
    234234            sage: c.get_fake_div((2*x^3+2*x-1)/((x-2)*(x+1)))
    235             FakeExpression([2*x^3 + 2*x - 1, FakeExpression([x - 2, x + 1], <built-in function mul>)], <built-in function div>)
     235            FakeExpression([2*x^3 + 2*x - 1, FakeExpression([x + 1, x - 2], <built-in function mul>)], <built-in function div>)
    236236
    237237        Check if #8056 is fixed, i.e., if numerator is 1.::
    238238
     
    14251425
    14261426        sage: f = (2*x^3+2*x-1)/((x-2)*(x+1))
    14271427        sage: f._fast_callable_(etb)
    1428         div(add(add(mul(ipow(v_0, 3), 2), mul(v_0, 2)), -1), mul(add(v_0, -2), add(v_0, 1)))
     1428        div(add(add(mul(ipow(v_0, 3), 2), mul(v_0, 2)), -1), mul(add(v_0, 1), add(v_0, -2)))
    14291429
    14301430    """
    14311431    return FastCallableConverter(ex, etb)()
  • sage/symbolic/function.pyx

    diff --git a/sage/symbolic/function.pyx b/sage/symbolic/function.pyx
    a b  
    10381038        Test pickling expressions with symbolic functions::
    10391039           
    10401040            sage: u = loads(dumps(foo(x)^2 + foo(y) + x^y)); u
    1041             x^y + foo(x)^2 + foo(y)
     1041            foo(x)^2 + x^y + foo(y)
    10421042            sage: u.subs(y=0)
    10431043            foo(x)^2 + foo(0) + 1
    10441044            sage: u.subs(y=0).n()
  • sage/symbolic/function_factory.py

    diff --git a/sage/symbolic/function_factory.py b/sage/symbolic/function_factory.py
    a b  
    185185        -b*sin(a)
    186186
    187187        sage: g.substitute_function(cr, (sin(x) + cos(x)).function(x))
    188         -(sin(a) - cos(a))*b
     188        b*(cos(a) - sin(a))
    189189
    190190    In Sage 4.0, basic arithmetic with unevaluated functions is no
    191191    longer supported::
  • sage/symbolic/getitem.pyx

    diff --git a/sage/symbolic/getitem.pyx b/sage/symbolic/getitem.pyx
    a b  
    6464
    6565        sage: x,y,z = var('x,y,z')
    6666        sage: e = x + x*y + z^y + 3*y*z; e
    67         x*y + 3*y*z + z^y + x
     67        x*y + 3*y*z + x + z^y
    6868        sage: e.op[1]
    6969        3*y*z
    7070        sage: e.op[1,1]
    7171        z
    7272        sage: e.op[-1]
    73         x
     73        z^y
    7474        sage: e.op[1:]
    75         [3*y*z, z^y, x]
     75        [3*y*z, x, z^y]
    7676        sage: e.op[:2]
    7777        [x*y, 3*y*z]
    7878        sage: e.op[-2:]
    79         [z^y, x]
     79        [x, z^y]
    8080        sage: e.op[:-2]
    8181        [x*y, 3*y*z]
    8282        sage: e.op[-5]
  • sage/symbolic/integration/integral.py

    diff --git a/sage/symbolic/integration/integral.py b/sage/symbolic/integration/integral.py
    a b  
    456456                 x y  + Sqrt[--] FresnelS[Sqrt[--] x]
    457457                             2                 Pi
    458458        sage: print f.integral(x)
    459         y^z*x + 1/8*((I - 1)*sqrt(2)*erf((1/2*I - 1/2)*sqrt(2)*x) + (I + 1)*sqrt(2)*erf((1/2*I + 1/2)*sqrt(2)*x))*sqrt(pi)
     459        x*y^z + 1/8*sqrt(pi)*((I + 1)*sqrt(2)*erf((1/2*I + 1/2)*sqrt(2)*x) + (I - 1)*sqrt(2)*erf((1/2*I - 1/2)*sqrt(2)*x))
    460460
    461461    Alternatively, just use algorithm='mathematica_free' to integrate via Mathematica
    462462    over the internet (does NOT require a Mathematica license!)::
     
    489489    ::
    490490
    491491        sage: A = integral(1/ ((x-4) * (x^3+2*x+1)), x); A
    492         1/73*log(x - 4) - 1/73*integrate((x^2 + 4*x + 18)/(x^3 + 2*x + 1), x)
     492        -1/73*integrate((x^2 + 4*x + 18)/(x^3 + 2*x + 1), x) + 1/73*log(x - 4)
    493493
    494494    We now show that floats are not converted to rationals
    495495    automatically since we by default have keepfloat: true in maxima.
     
    519519
    520520        sage: assume(a>0)
    521521        sage: integrate(1/(x^3 *(a+b*x)^(1/3)), x)
    522         2/9*sqrt(3)*b^2*arctan(1/3*(2*(b*x + a)^(1/3) + a^(1/3))*sqrt(3)/a^(1/3))/a^(7/3) + 2/9*b^2*log((b*x + a)^(1/3) - a^(1/3))/a^(7/3) - 1/9*b^2*log((b*x + a)^(2/3) + (b*x + a)^(1/3)*a^(1/3) + a^(2/3))/a^(7/3) + 1/6*(4*(b*x + a)^(5/3)*b^2 - 7*(b*x + a)^(2/3)*a*b^2)/((b*x + a)^2*a^2 - 2*(b*x + a)*a^3 + a^4)
     522        2/9*sqrt(3)*b^2*arctan(1/3*sqrt(3)*(2*(b*x + a)^(1/3) + a^(1/3))/a^(1/3))/a^(7/3) - 1/9*b^2*log((b*x + a)^(2/3) + (b*x + a)^(1/3)*a^(1/3) + a^(2/3))/a^(7/3) + 2/9*b^2*log((b*x + a)^(1/3) - a^(1/3))/a^(7/3) + 1/6*(4*(b*x + a)^(5/3)*b^2 - 7*(b*x + a)^(2/3)*a*b^2)/((b*x + a)^2*a^2 - 2*(b*x + a)*a^3 + a^4)
    523523
    524524    TESTS:
    525525
     
    527527    see #3013::
    528528
    529529        sage: integrate(sin(x)*cos(10*x)*log(x), x)
    530         1/198*(11*cos(9*x) - 9*cos(11*x))*log(x) + 1/44*Ei(-11*I*x) - 1/36*Ei(-9*I*x) - 1/36*Ei(9*I*x) + 1/44*Ei(11*I*x)
     530        -1/198*(9*cos(11*x) - 11*cos(9*x))*log(x) + 1/44*Ei(11*I*x) - 1/36*Ei(9*I*x) - 1/36*Ei(-9*I*x) + 1/44*Ei(-11*I*x)
    531531
    532532    It is no longer possible to use certain functions without an
    533533    explicit variable.  Instead, evaluate the function at a variable,
     
    554554        Is  50015104*y^2-50015103  positive, negative, or zero?
    555555        sage: assume(y>1)
    556556        sage: res = integral(f,x,0.0001414, 1.); res
    557         2*y*arctan(1/y) - 2*y*arctan(0.0001414/y) - 0.0001414*log(y^2 + 1.999396e-08) + log(y^2 + 1.0) - 1.9997172
     557        -2*y*arctan(0.0001414/y) + 2*y*arctan(1/y) + log(y^2 + 1.0) - 0.0001414*log(y^2 + 1.999396e-08) - 1.9997172
    558558        sage: nres = numerical_integral(f.subs(y=2), 0.0001414, 1.); nres
    559559        (1.4638323264144..., 1.6251803529759...e-14)
    560560        sage: res.subs(y=2).n()
     
    592592        sage: integrate(t*cos(-theta*t),(t,-oo,oo))
    593593        integrate(t*cos(t*theta), t, -Infinity, +Infinity)
    594594
    595     Check if #6189 is fixed (which, by the way, also
    596     demonstrates it's not always good to expand)::
     595    Check if #6189 is fixed::
    597596
    598597        sage: n = N; n
    599598        <function numerical_approx at ...>
     
    603602        0.000000000000000
    604603        sage: integrate( ((F(x)-G(x))^2).expand(), x, -infinity, infinity).n()
    605604        -6.26376265908397e-17
    606         sage: integrate( (F(x)-G(x))^2, x, -infinity, infinity).n()
    607         -6.26376265908397e-17
     605        sage: integrate( (F(x)-G(x))^2, x, -infinity, infinity).n()# abstol 1e-6
     606        0
    608607
    609608    This was broken before Maxima 5.20::
    610609
     
    641640
    642641        sage: actual_result = integral(e^(-1/x^2), x, 0, 1)
    643642        sage: actual_result.full_simplify()
    644         ((e*erf(1) - e)*sqrt(pi) + 1)*e^(-1)
     643        (sqrt(pi)*(erf(1)*e - e) + 1)*e^(-1)
    645644        sage: ideal_result = 1/2*gamma(-1/2, 1)
    646645        sage: error = actual_result - ideal_result
    647646        sage: error.numerical_approx() # abs tol 1e-10
  • sage/symbolic/maxima_wrapper.py

    diff --git a/sage/symbolic/maxima_wrapper.py b/sage/symbolic/maxima_wrapper.py
    a b  
    1717        EXAMPLES::
    1818
    1919            sage: t = sin(x)^2 + cos(x)^2; t
    20             sin(x)^2 + cos(x)^2
     20            cos(x)^2 + sin(x)^2
    2121            sage: res = t.maxima_methods().trigsimp(); res
    2222            1
    2323            sage: type(res)
     
    3838        EXAMPLES::
    3939
    4040            sage: t = log(sqrt(2) - 1) + log(sqrt(2) + 1); t
    41             log(sqrt(2) - 1) + log(sqrt(2) + 1)
     41            log(sqrt(2) + 1) + log(sqrt(2) - 1)
    4242            sage: u = t.maxima_methods(); u
    43             MaximaWrapper(log(sqrt(2) - 1) + log(sqrt(2) + 1))
     43            MaximaWrapper(log(sqrt(2) + 1) + log(sqrt(2) - 1))
    4444            sage: type(u)
    4545            <class 'sage.symbolic.maxima_wrapper.MaximaWrapper'>
    4646            sage: u.logcontract()
    47             log((sqrt(2) - 1)*(sqrt(2) + 1))
     47            log((sqrt(2) + 1)*(sqrt(2) - 1))
    4848            sage: u.logcontract().parent()
    4949            Symbolic Ring
    5050
     
    7070        EXAMPLES::
    7171
    7272            sage: t = sin(x)^2 + cos(x)^2; t
    73             sin(x)^2 + cos(x)^2
     73            cos(x)^2 + sin(x)^2
    7474            sage: u = t.maxima_methods()
    7575            sage: import sagenb.misc.support as s
    7676            sage: s.completions('u.airy_',globals(),system='python')
     
    7878            sage: type(u.airy_ai)
    7979            <class 'sage.symbolic.maxima_wrapper.MaximaFunctionElementWrapper'>
    8080            sage: u.airy_ai()
    81             airy_ai(sin(x)^2 + cos(x)^2)
     81            airy_ai(cos(x)^2 + sin(x)^2)
    8282        """
    8383        if self._maxima_exp is None:
    8484            self._maxima_exp = self._exp._maxima_()
     
    9696        EXAMPLES::
    9797
    9898            sage: t = log(sqrt(2) - 1) + log(sqrt(2) + 1); t
    99             log(sqrt(2) - 1) + log(sqrt(2) + 1)
     99            log(sqrt(2) + 1) + log(sqrt(2) - 1)
    100100            sage: u = t.maxima_methods().sage()
    101101            sage: u is t
    102102            True
     
    108108        EXAMPLES::
    109109
    110110            sage: t = log(sqrt(2) - 1) + log(sqrt(2) + 1); t
    111             log(sqrt(2) - 1) + log(sqrt(2) + 1)
     111            log(sqrt(2) + 1) + log(sqrt(2) - 1)
    112112            sage: u = t.maxima_methods()
    113113            sage: SR(u) is t # indirect doctest
    114114            True
     
    120120        EXAMPLES::
    121121
    122122            sage: t = log(sqrt(2) - 1) + log(sqrt(2) + 1); t
    123             log(sqrt(2) - 1) + log(sqrt(2) + 1)
     123            log(sqrt(2) + 1) + log(sqrt(2) - 1)
    124124            sage: u = t.maxima_methods(); u
    125             MaximaWrapper(log(sqrt(2) - 1) + log(sqrt(2) + 1))
     125            MaximaWrapper(log(sqrt(2) + 1) + log(sqrt(2) - 1))
    126126            sage: loads(dumps(u))
    127             MaximaWrapper(log(sqrt(2) - 1) + log(sqrt(2) + 1))
     127            MaximaWrapper(log(sqrt(2) + 1) + log(sqrt(2) - 1))
    128128        """
    129129        return (MaximaWrapper, (self._exp,))
    130130
     
    133133        EXAMPLES::
    134134
    135135            sage: t = log(sqrt(2) - 1) + log(sqrt(2) + 1); t
    136             log(sqrt(2) - 1) + log(sqrt(2) + 1)
     136            log(sqrt(2) + 1) + log(sqrt(2) - 1)
    137137            sage: u = t.maxima_methods(); u
    138             MaximaWrapper(log(sqrt(2) - 1) + log(sqrt(2) + 1))
     138            MaximaWrapper(log(sqrt(2) + 1) + log(sqrt(2) - 1))
    139139            sage: u._repr_()
    140             'MaximaWrapper(log(sqrt(2) - 1) + log(sqrt(2) + 1))'
     140            'MaximaWrapper(log(sqrt(2) + 1) + log(sqrt(2) - 1))'
    141141        """
    142142        return "MaximaWrapper(%s)"%(self._exp)
  • sage/symbolic/random_tests.py

    diff --git a/sage/symbolic/random_tests.py b/sage/symbolic/random_tests.py
    a b  
    335335        sage: for i,j in CartesianProduct(range(0,3),range(0,3)):
    336336        ...       cmp[i,j] = x[i].__cmp__(x[j])
    337337        sage: cmp
    338         [ 0  1  1]
    339         [-1  0 -1]
    340         [-1  1  0]
     338        [ 0 -1 -1]
     339        [ 1  0 -1]
     340        [ 1  1  0]
    341341    """
    342342    from sage.matrix.constructor import matrix
    343343    from sage.combinat.cartesian_product import CartesianProduct
  • sage/symbolic/relation.py

    diff --git a/sage/symbolic/relation.py b/sage/symbolic/relation.py
    a b  
    1010    a*x^2 + b*x + c == 0
    1111    sage: print solve(qe, x)
    1212    [
    13     x == -1/2*(b + sqrt(-4*a*c + b^2))/a,
    14     x == -1/2*(b - sqrt(-4*a*c + b^2))/a
     13    x == -1/2*(b + sqrt(b^2 - 4*a*c))/a,
     14    x == -1/2*(b - sqrt(b^2 - 4*a*c))/a
    1515    ]
    1616
    1717
     
    238238    sage: var('x,y,z,w')
    239239    (x, y, z, w)
    240240    sage: f =  (x+y+w) == (x^2 - y^2 - z^3);   f
    241     w + x + y == x^2 - y^2 - z^3
     241    w + x + y == -z^3 + x^2 - y^2
    242242    sage: f.variables()
    243243    (w, x, y, z)
    244244
     
    276276    x == y - 5
    277277    sage: h =  x^3 + sqrt(2) == x*y*sin(x)
    278278    sage: h
    279     sqrt(2) + x^3 == x*y*sin(x)
     279    x^3 + sqrt(2) == x*y*sin(x)
    280280    sage: h - sqrt(2)
    281281    x^3 == x*y*sin(x) - sqrt(2)
    282282    sage: h + f
    283     x + sqrt(2) + x^3 + 3 == x*y*sin(x) + y - 2
     283    x^3 + x + sqrt(2) + 3 == x*y*sin(x) + y - 2
    284284    sage: f = x + 3 < y - 2
    285285    sage: g = 2 < x+10
    286286    sage: f - g
     
    648648
    649649       sage: x,y=var('x y'); c1(x,y)=(x-5)^2+y^2-16; c2(x,y)=(y-3)^2+x^2-9
    650650       sage: solve([c1(x,y),c2(x,y)],[x,y])                               
    651        [[x == -9/68*sqrt(55) + 135/68, y == -15/68*sqrt(5)*sqrt(11) + 123/68], [x == 9/68*sqrt(55) + 135/68, y == 15/68*sqrt(5)*sqrt(11) + 123/68]]
     651       [[x == -9/68*sqrt(55) + 135/68, y == -15/68*sqrt(11)*sqrt(5) + 123/68], [x == 9/68*sqrt(55) + 135/68, y == 15/68*sqrt(11)*sqrt(5) + 123/68]]
    652652       
    653653    TESTS::
    654654
  • sage/symbolic/ring.pyx

    diff --git a/sage/symbolic/ring.pyx b/sage/symbolic/ring.pyx
    a b  
    318318            sage: x,y = var('x,y')
    319319            sage: w0 = SR.wild(0); w1 = SR.wild(1)
    320320            sage: pattern = sin(x)*w0*w1^2; pattern
    321             $0*$1^2*sin(x)
     321            $1^2*$0*sin(x)
    322322            sage: f = atan(sin(x)*3*x^2); f
    323323            arctan(3*x^2*sin(x))
    324324            sage: f.has(pattern)
  • sage/symbolic/units.py

    diff --git a/sage/symbolic/units.py b/sage/symbolic/units.py
    a b  
    12781278    You can also convert quantities of units::
    12791279
    12801280        sage: sage.symbolic.units.convert(cos(50) * units.angles.radian, units.angles.degree)
    1281         (180*cos(50)/pi)*degree
     1281        degree*(180*cos(50)/pi)
    12821282        sage: sage.symbolic.units.convert(cos(30) * units.angles.radian, units.angles.degree).polynomial(RR)
    12831283        8.83795706233228*degree
    12841284        sage: sage.symbolic.units.convert(50 * units.length.light_year / units.time.year, units.length.foot / units.time.second)
     
    12871287    Quantities may contain variables (not for temperature conversion, though)::
    12881288
    12891289        sage: sage.symbolic.units.convert(50 * x * units.area.square_meter, units.area.acre)
    1290         (1953125/158080329*x)*acre
     1290        acre*(1953125/158080329*x)
    12911291    """
    12921292    base_target = target
    12931293    z = {}
  • sage/tensor/differential_form_element.py

    diff --git a/sage/tensor/differential_form_element.py b/sage/tensor/differential_form_element.py
    a b  
    13101310        sage: g[1] = sin(y); g
    13111311        sin(y)*dy
    13121312        sage: wedge(f, g)
    1313         -sin(y)*cos(x)*dy/\dz
     1313        -cos(x)*sin(y)*dy/\dz
    13141314        sage: f.wedge(g)
    1315         -sin(y)*cos(x)*dy/\dz
     1315        -cos(x)*sin(y)*dy/\dz
    13161316        sage: wedge(f, g) == f.wedge(g)
    13171317        True
    13181318    """
  • sage/tests/french_book/polynomes.py

    diff --git a/sage/tests/french_book/polynomes.py b/sage/tests/french_book/polynomes.py
    a b  
    77
    88  sage: x = var('x'); p = (2*x+1)*(x+2)*(x^4-1)
    99  sage: print p, "est de degré", p.degree(x)
    10   (x + 2)*(2*x + 1)*(x^4 - 1) est de degré 6
     10  (x^4 - 1)*(2*x + 1)*(x + 2) est de degré 6
    1111
    1212Sage example in ./polynomes.tex, line 69::
    1313
  • sage/tests/french_book/recequadiff.py

    diff --git a/sage/tests/french_book/recequadiff.py b/sage/tests/french_book/recequadiff.py
    a b  
    6868
    6969  sage: DE = diff(y,x)+2*y == x**2-2*x+3
    7070  sage: desolve(DE, y)
    71   -1/4*(2*(2*x - 1)*e^(2*x) - (2*x^2 - 2*x + 1)*e^(2*x) - 4*c
    72   - 6*e^(2*x))*e^(-2*x)
     71  1/4*((2*x^2 - 2*x + 1)*e^(2*x) - 2*(2*x - 1)*e^(2*x) + 4*c
     72  + 6*e^(2*x))*e^(-2*x)
    7373
    7474Sage example in ./recequadiff.tex, line 305::
    7575
    7676  sage: desolve(DE, y).expand()
    77   c*e^(-2*x) + 1/2*x^2 - 3/2*x + 9/4
     77  1/2*x^2 + c*e^(-2*x) - 3/2*x + 9/4
    7878
    7979Sage example in ./recequadiff.tex, line 321::
    8080
     
    190190Sage example in ./recequadiff.tex, line 575::
    191191
    192192  sage: Sol(x) = solve(sol, y)[0]; Sol(x)
    193   log(y(x)) == (c + x)*a + log(b*y(x) - a)
     193  log(y(x)) == a*(c + x) + log(b*y(x) - a)
    194194
    195195Sage example in ./recequadiff.tex, line 582::
    196196
    197197  sage: Sol(x) = Sol(x).lhs()-Sol(x).rhs(); Sol(x)
    198   -(c + x)*a - log(b*y(x) - a) + log(y(x))
     198  -a*(c + x) - log(b*y(x) - a) + log(y(x))
    199199  sage: Sol = Sol.simplify_log(); Sol(x)
    200   -(c + x)*a + log(y(x)/(b*y(x) - a))
     200  -a*(c + x) + log(y(x)/(b*y(x) - a))
    201201  sage: solve(Sol, y)[0].simplify()
    202202  y(x) == a*e^(a*c + a*x)/(b*e^(a*c + a*x) - 1)
    203203
     
    206206  sage: x = var('x'); y = function('y', x)
    207207  sage: DE = diff(y,x,2)+3*y == x^2-7*x+31
    208208  sage: desolve(DE, y).expand()
    209   k1*sin(sqrt(3)*x) + k2*cos(sqrt(3)*x) + 1/3*x^2 - 7/3*x + 91/9
     209  1/3*x^2 + k2*cos(sqrt(3)*x) + k1*sin(sqrt(3)*x) - 7/3*x + 91/9
    210210
    211211Sage example in ./recequadiff.tex, line 611::
    212212
     
    217217Sage example in ./recequadiff.tex, line 621::
    218218
    219219  sage: desolve(DE, y, ics=[0,1,-1,0]).expand()
    220   1/3*x^2 - 7/3*x - 82/9*sin(sqrt(3)*x)*cos(sqrt(3))/sin(sqrt(3))
     220  1/3*x^2 - 7/3*x - 82/9*cos(sqrt(3))*sin(sqrt(3)*x)/sin(sqrt(3))
    221221  + 115/9*sin(sqrt(3)*x)/sin(sqrt(3)) - 82/9*cos(sqrt(3)*x) + 91/9
    222222
    223223Sage example in ./recequadiff.tex, line 674::
     
    265265
    266266  sage: X(s) = 1/(s^2-3*s-4)/(s^2+1) + (s-4)/(s^2-3*s-4)
    267267  sage: X(s).inverse_laplace(s, x)
    268   9/10*e^(-x) + 1/85*e^(4*x) - 5/34*sin(x) + 3/34*cos(x)
     268  3/34*cos(x) + 1/85*e^(4*x) + 9/10*e^(-x) - 5/34*sin(x)
    269269
    270270Sage example in ./recequadiff.tex, line 807::
    271271
    272272  sage: X(s).partial_fraction()
    273   1/34*(3*s - 5)/(s^2 + 1) + 1/85/(s - 4) + 9/10/(s + 1)
     273  1/34*(3*s - 5)/(s^2 + 1) + 9/10/(s + 1) + 1/85/(s - 4)
    274274
    275275Sage example in ./recequadiff.tex, line 818::
    276276
    277277  sage: x = var('x'); y = function('y',x)
    278278  sage: eq = diff(y,x,x) - 3*diff(y,x) - 4*y - sin(x) == 0
    279279  sage: desolve_laplace(eq, y)
    280   1/10*(8*y(0) - 2*D[0](y)(0) - 1)*e^(-x) + 1/85*(17*y(0) +
    281   17*D[0](y)(0) + 1)*e^(4*x) - 5/34*sin(x) + 3/34*cos(x)
     280  1/85*(17*y(0) + 17*D[0](y)(0) + 1)*e^(4*x) + 1/10*(8*y(0)
     281  - 2*D[0](y)(0) - 1)*e^(-x) + 3/34*cos(x) - 5/34*sin(x)
    282282  sage: desolve_laplace(eq, y, ics=[0,1,-1])
    283   9/10*e^(-x) + 1/85*e^(4*x) - 5/34*sin(x) + 3/34*cos(x)
     283  3/34*cos(x) + 1/85*e^(4*x) + 9/10*e^(-x) - 5/34*sin(x)
    284284
    285285Sage example in ./recequadiff.tex, line 869::
    286286
     
    290290  sage: A = matrix([[2,-2,0],[-2,0,2],[0,2,2]])
    291291  sage: system = [diff(y[i], x) - (A * y)[i] for i in range(3)]
    292292  sage: desolve_system(system, [y1, y2, y3], ics=[0,2,1,-2])
    293   [y1(x) ==   e^(-2*x) + e^(4*x),
    294    y2(x) == 2*e^(-2*x) - e^(4*x),
    295    y3(x) ==  -e^(-2*x) - e^(4*x)]
     293  [y1(x) == e^(4*x) + e^(-2*x),
     294   y2(x) == -e^(4*x) + 2*e^(-2*x),
     295   y3(x) == -e^(4*x) - e^(-2*x)]
    296296
    297297Sage example in ./recequadiff.tex, line 913::
    298298
     
    301301  sage: A = matrix([[3,-4],[1,3]])
    302302  sage: system = [diff(y[i], x) - (A * y)[i] for i in range(2)]
    303303  sage: desolve_system(system, [y1, y2], ics=[0,2,0])
    304   [y1(x) == 2*e^(3*x)*cos(2*x), y2(x) == e^(3*x)*sin(2*x)]
     304  [y1(x) == 2*cos(2*x)*e^(3*x), y2(x) == e^(3*x)*sin(2*x)]
    305305
    306306Sage example in ./recequadiff.tex, line 966::
    307307
     
    315315Sage example in ./recequadiff.tex, line 977::
    316316
    317317  sage: sol[0]
    318   u1(x) == 1/24*(2*u1(0) - 6*u2(0) - u3(0) + 3*u4(0))*e^(-4*x)
    319           + 1/12*(2*u1(0) - 6*u2(0) + 5*u3(0) + 3*u4(0))*e^(2*x)
    320           + 3/4*u1(0) + 3/4*u2(0) - 3/8*u3(0) - 3/8*u4(0)
     318  u1(x) == 1/12*(2*u1(0) - 6*u2(0) + 5*u3(0) + 3*u4(0))*e^(2*x)
     319           + 1/24*(2*u1(0) - 6*u2(0) - u3(0) + 3*u4(0))*e^(-4*x)
     320           + 3/4*u1(0) + 3/4*u2(0) - 3/8*u3(0) - 3/8*u4(0)
     321
    321322  sage: sol[1]
    322323  u2(x) == -1/12*(2*u1(0) - 6*u2(0) - u3(0) - 3*u4(0))*e^(2*x)
    323324           - 1/24*(2*u1(0) - 6*u2(0) - u3(0) + 3*u4(0))*e^(-4*x)