Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Trac 16908: fix doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
pjbruin committed Sep 5, 2014
1 parent 3a9e645 commit 0fd6543
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 32 deletions.
4 changes: 2 additions & 2 deletions src/doc/de/tutorial/tour_algebra.rst
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Lösung: Berechnen Sie die Laplace-Transformierte der ersten Gleichung

sage: de1 = maxima("2*diff(x(t),t, 2) + 6*x(t) - 2*y(t)")
sage: lde1 = de1.laplace("t","s"); lde1
2*(-?%at('diff(x(t),t,1),t=0)+s^2*'laplace(x(t),t,s)-x(0)*s)-2*'laplace(y(t),t,s)+6*'laplace(x(t),t,s)
2*(-%at('diff(x(t),t,1),t=0)+s^2*'laplace(x(t),t,s)-x(0)*s)-2*'laplace(y(t),t,s)+6*'laplace(x(t),t,s)

Das ist schwierig zu lesen, es besagt jedoch, dass

Expand All @@ -228,7 +228,7 @@ Laplace-Transformierte der zweiten Gleichung:

sage: de2 = maxima("diff(y(t),t, 2) + 2*y(t) - 2*x(t)")
sage: lde2 = de2.laplace("t","s"); lde2
-?%at('diff(y(t),t,1),t=0)+s^2*'laplace(y(t),t,s)+2*'laplace(y(t),t,s)-2*'laplace(x(t),t,s)-y(0)*s
-%at('diff(y(t),t,1),t=0)+s^2*'laplace(y(t),t,s)+2*'laplace(y(t),t,s)-2*'laplace(x(t),t,s)-y(0)*s

Dies besagt

Expand Down
2 changes: 1 addition & 1 deletion src/doc/en/constructions/calculus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ The Maclaurin and power series of
sage: [bernoulli(2*i) for i in range(1,7)]
[1/6, -1/30, 1/42, -1/30, 5/66, -691/2730]
sage: maxima(f).powerseries(x,0) # TODO: write this without maxima
'sum((-1)^i2*2^(2*i2-1)*bern(2*i2)*_SAGE_VAR_x^(2*i2)/(i2*factorial(2*i2)),i2,1,inf)
'sum((-1)^i3*2^(2*i3-1)*bern(2*i3)*_SAGE_VAR_x^(2*i3)/(i3*factorial(2*i3)),i3,1,inf)

.. index::
pair: calculus; integration
Expand Down
4 changes: 2 additions & 2 deletions src/doc/en/tutorial/tour_algebra.rst
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ the notation :math:`x=x_{1}`, :math:`y=x_{2}`):

sage: de1 = maxima("2*diff(x(t),t, 2) + 6*x(t) - 2*y(t)")
sage: lde1 = de1.laplace("t","s"); lde1
2*(-?%at('diff(x(t),t,1),t=0)+s^2*'laplace(x(t),t,s)-x(0)*s)-2*'laplace(y(t),t,s)+6*'laplace(x(t),t,s)
2*(-%at('diff(x(t),t,1),t=0)+s^2*'laplace(x(t),t,s)-x(0)*s)-2*'laplace(y(t),t,s)+6*'laplace(x(t),t,s)

This is hard to read, but it says that

Expand All @@ -221,7 +221,7 @@ Laplace transform of the second equation:

sage: de2 = maxima("diff(y(t),t, 2) + 2*y(t) - 2*x(t)")
sage: lde2 = de2.laplace("t","s"); lde2
-?%at('diff(y(t),t,1),t=0)+s^2*'laplace(y(t),t,s)+2*'laplace(y(t),t,s)-2*'laplace(x(t),t,s)-y(0)*s
-%at('diff(y(t),t,1),t=0)+s^2*'laplace(y(t),t,s)+2*'laplace(y(t),t,s)-2*'laplace(x(t),t,s)-y(0)*s

This says

Expand Down
4 changes: 2 additions & 2 deletions src/doc/fr/tutorial/tour_algebra.rst
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Solution : Considérons la transformée de Laplace de la première équation

sage: de1 = maxima("2*diff(x(t),t, 2) + 6*x(t) - 2*y(t)")
sage: lde1 = de1.laplace("t","s"); lde1
2*(-?%at('diff(x(t),t,1),t=0)+s^2*'laplace(x(t),t,s)-x(0)*s)-2*'laplace(y(t),t,s)+6*'laplace(x(t),t,s)
2*(-%at('diff(x(t),t,1),t=0)+s^2*'laplace(x(t),t,s)-x(0)*s)-2*'laplace(y(t),t,s)+6*'laplace(x(t),t,s)

La réponse n'est pas très lisible, mais elle signifie que

Expand All @@ -198,7 +198,7 @@ la seconde équation :

sage: de2 = maxima("diff(y(t),t, 2) + 2*y(t) - 2*x(t)")
sage: lde2 = de2.laplace("t","s"); lde2
-?%at('diff(y(t),t,1),t=0)+s^2*'laplace(y(t),t,s)+2*'laplace(y(t),t,s)-2*'laplace(x(t),t,s)-y(0)*s
-%at('diff(y(t),t,1),t=0)+s^2*'laplace(y(t),t,s)+2*'laplace(y(t),t,s)-2*'laplace(x(t),t,s)-y(0)*s

Ceci signifie

Expand Down
4 changes: 2 additions & 2 deletions src/doc/ru/tutorial/tour_algebra.rst
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ Sage может использоваться для решения диффер

sage: de1 = maxima("2*diff(x(t),t, 2) + 6*x(t) - 2*y(t)")
sage: lde1 = de1.laplace("t","s"); lde1
2*(-?%at('diff(x(t),t,1),t=0)+s^2*'laplace(x(t),t,s)-x(0)*s)-2*'laplace(y(t),t,s)+6*'laplace(x(t),t,s)
2*(-%at('diff(x(t),t,1),t=0)+s^2*'laplace(x(t),t,s)-x(0)*s)-2*'laplace(y(t),t,s)+6*'laplace(x(t),t,s)

Данный результат тяжело читаем, однако должен быть понят как

Expand All @@ -212,7 +212,7 @@ Sage может использоваться для решения диффер

sage: de2 = maxima("diff(y(t),t, 2) + 2*y(t) - 2*x(t)")
sage: lde2 = de2.laplace("t","s"); lde2
-?%at('diff(y(t),t,1),t=0)+s^2*'laplace(y(t),t,s)+2*'laplace(y(t),t,s)-2*'laplace(x(t),t,s)-y(0)*s
-%at('diff(y(t),t,1),t=0)+s^2*'laplace(y(t),t,s)+2*'laplace(y(t),t,s)-2*'laplace(x(t),t,s)-y(0)*s

Результат:

Expand Down
2 changes: 1 addition & 1 deletion src/sage/calculus/calculus.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ def nintegral(ex, x, a, b,
Now numerically integrating, we see why the answer is wrong::
sage: f.nintegrate(x,0,1)
(-480.00000000000006, 5.329070518200754e-12, 21, 0)
(-480.0000000000001, 5.329070518200754e-12, 21, 0)
It is just because every floating point evaluation of return -480.0
in floating point.
Expand Down
2 changes: 1 addition & 1 deletion src/sage/calculus/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
sage: integrate(exp(1-x^2),x)
1/2*sqrt(pi)*erf(x)*e
sage: integrate(sin(x^2),x)
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))
1/16*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) - (I - 1)*sqrt(2)*erf(sqrt(-I)*x) + (I + 1)*sqrt(2)*erf((-1)^(1/4)*x))
sage: integrate((1-x^2)^n,x)
integrate((-x^2 + 1)^n, x)
Expand Down
6 changes: 3 additions & 3 deletions src/sage/functions/special.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,11 @@ def _maxima_init_evaled_(self, *args):
TESTS:
Check if complex numbers in the arguments are converted to maxima
correctly :trac:`7557`::
correctly (see :trac:`7557`)::
sage: t = f(1.2+2*I*elliptic_kc(1-.5),.5)
sage: t._maxima_init_(maxima)
'0.88771548861927...*%i'
sage: t._maxima_init_(maxima) # abs tol 1e-13
'0.88771548861928029 - 1.7301614091485560e-15*%i'
sage: t.n() # abs tol 1e-13
0.887715488619280 - 1.79195288804672e-15*I
Expand Down
2 changes: 1 addition & 1 deletion src/sage/interfaces/maxima.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
::
sage: maxima("laplace(diff(x(t),t,2),t,s)")
-?%at('diff(x(t),t,1),t=0)+s^2*'laplace(x(t),t,s)-x(0)*s
-%at('diff(x(t),t,1),t=0)+s^2*'laplace(x(t),t,s)-x(0)*s
It is difficult to read some of these without the 2d
representation::
Expand Down
12 changes: 4 additions & 8 deletions src/sage/interfaces/maxima_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,16 +709,12 @@ def sr_integral(self,*args):
::
sage: integrate(cos(x + abs(x)), x)
-1/4*(2*x - sin(2*x))*real_part(sgn(x)) + 1/2*x + 1/4*sin(2*x)
-1/2*x*sgn(x) + 1/4*(sgn(x) + 1)*sin(2*x) + 1/2*x
Note that the last example yielded the same answer in a
simpler form in earlier versions of Maxima (<= 5.29.1), namely
``-1/2*x*sgn(x) + 1/4*(sgn(x) + 1)*sin(2*x) + 1/2*x``. This
is because Maxima no longer simplifies ``realpart(signum(x))``
to ``signum(x)``::
The last example relies on the following simplification::
sage: maxima("realpart(signum(x))")
'realpart(signum(x))
signum(x)
An example from sage-support thread e641001f8b8d1129::
Expand Down Expand Up @@ -1067,7 +1063,7 @@ def to_poly_solve(self,vars,options=""):
sage: from sage.interfaces.maxima_lib import maxima_lib
sage: sol = maxima_lib(sin(x) == 0).to_poly_solve(x)
sage: sol.sage()
[[x == pi*z54]]
[[x == pi*z62]]
"""
if options.find("use_grobner=true") != -1:
cmd=EclObject([[max_to_poly_solve], self.ecl(), sr_to_max(vars),
Expand Down
2 changes: 1 addition & 1 deletion src/sage/symbolic/expression.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -9349,7 +9349,7 @@ cdef class Expression(CommutativeRingElement):
sage: from sage.calculus.calculus import maxima
sage: sol = maxima(cos(x)==0).to_poly_solve(x)
sage: sol.sage()
[[x == 1/2*pi + pi*z82]]
[[x == 1/2*pi + pi*z90]]
If a returned unsolved expression has a denominator, but the
original one did not, this may also be true::
Expand Down
11 changes: 4 additions & 7 deletions src/sage/symbolic/integration/integral.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,6 @@ def _print_latex_(self, f, x, a, b):
sage: f = function('f')
sage: print_latex(f(x),x,0,1)
'\\int_{0}^{1} f\\left(x\\right)\\,{d x}'
sage: latex(integrate(1/(1+sqrt(x)),x,0,1))
\int_{0}^{1} \frac{1}{\sqrt{x} + 1}\,{d x}
"""
from sage.misc.latex import latex
if not is_SymbolicVariable(x):
Expand Down Expand Up @@ -456,7 +454,7 @@ def integrate(expression, v=None, a=None, b=None, algorithm=None):
x y + Sqrt[--] FresnelS[Sqrt[--] x]
2 Pi
sage: print f.integral(x)
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))
x*y^z + 1/16*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) - (I - 1)*sqrt(2)*erf(sqrt(-I)*x) + (I + 1)*sqrt(2)*erf((-1)^(1/4)*x))
Alternatively, just use algorithm='mathematica_free' to integrate via Mathematica
over the internet (does NOT require a Mathematica license!)::
Expand Down Expand Up @@ -590,12 +588,11 @@ def integrate(expression, v=None, a=None, b=None, algorithm=None):
...
ValueError: invalid input (x, 1, 2, 3) - please use variable, with or without two endpoints
Note that this used to be the test, but it is
actually divergent (though Maxima as yet does
not say so)::
Note that this used to be the test, but it is actually divergent
(though Maxima currently returns the principal value)::
sage: integrate(t*cos(-theta*t),(t,-oo,oo))
integrate(t*cos(t*theta), t, -Infinity, +Infinity)
0
Check if :trac:`6189` is fixed::
Expand Down
2 changes: 1 addition & 1 deletion src/sage/symbolic/relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def solve(f, *args, **kwds):
be implicitly an integer (hence the ``z``)::
sage: solve([cos(x)*sin(x) == 1/2, x+y == 0],x,y)
[[x == 1/4*pi + pi*z80, y == -1/4*pi - pi*z80]]
[[x == 1/4*pi + pi*z88, y == -1/4*pi - pi*z88]]
Expressions which are not equations are assumed to be set equal
to zero, as with `x` in the following example::
Expand Down

0 comments on commit 0fd6543

Please sign in to comment.