diff --git a/src/sage/calculus/functional.py b/src/sage/calculus/functional.py index 109de21a5d9..d457c448dd1 100644 --- a/src/sage/calculus/functional.py +++ b/src/sage/calculus/functional.py @@ -215,8 +215,8 @@ def integral(f, *args, **kwds): symbolically:: sage: f(x) = 1/(sqrt(2*pi)) * e^(-x^2/2) - sage: P = plot(f, -4, 4, hue=0.8, thickness=2) - sage: P.show(ymin=0, ymax=0.4) + sage: P = plot(f, -4, 4, hue=0.8, thickness=2) # needs sage.plot + sage: P.show(ymin=0, ymax=0.4) # needs sage.plot sage: numerical_integral(f, -4, 4) # random output (0.99993665751633376, 1.1101527003413533e-14) sage: integrate(f, x) diff --git a/src/sage/calculus/interpolators.pyx b/src/sage/calculus/interpolators.pyx index 0e1f5fc7209..221b52369e2 100644 --- a/src/sage/calculus/interpolators.pyx +++ b/src/sage/calculus/interpolators.pyx @@ -50,13 +50,14 @@ def polygon_spline(pts): sage: ps = polygon_spline(pts) sage: fx = lambda x: ps.value(x).real sage: fy = lambda x: ps.value(x).imag - sage: show(parametric_plot((fx, fy), (0, 2*pi))) # needs sage.plot + sage: show(parametric_plot((fx, fy), (0, 2*pi))) # needs sage.plot sage.symbolic sage: m = Riemann_Map([lambda x: ps.value(real(x))], ....: [lambda x: ps.derivative(real(x))], 0) sage: show(m.plot_colored() + m.plot_spiderweb()) # needs sage.plot Polygon approximation of a circle:: + sage: # needs sage.symbolic sage: pts = [e^(I*t / 25) for t in range(25)] sage: ps = polygon_spline(pts) sage: ps.derivative(2) diff --git a/src/sage/calculus/riemann.pyx b/src/sage/calculus/riemann.pyx index a4f9545bffb..9527736872d 100644 --- a/src/sage/calculus/riemann.pyx +++ b/src/sage/calculus/riemann.pyx @@ -408,7 +408,7 @@ cdef class Riemann_Map: sage: m = Riemann_Map([f], [fprime], 0) sage: sz = m.get_szego(boundary=0) sage: points = m.get_szego(absolute_value=True) - sage: list_plot(points) + sage: list_plot(points) # needs sage.plot Graphics object consisting of 1 graphics primitive Extending the points by a spline:: @@ -416,7 +416,7 @@ cdef class Riemann_Map: sage: s = spline(points) sage: s(3*pi / 4) 0.0012158... - sage: plot(s,0,2*pi) # plot the kernel + sage: plot(s,0,2*pi) # plot the kernel # needs sage.plot Graphics object consisting of 1 graphics primitive The unit circle with a small hole:: @@ -483,7 +483,7 @@ cdef class Riemann_Map: sage: fprime(t) = I*e^(I*t) + 0.5*I*e^(-I*t) sage: m = Riemann_Map([f], [fprime], 0) sage: points = m.get_theta_points() - sage: list_plot(points) + sage: list_plot(points) # needs sage.plot Graphics object consisting of 1 graphics primitive Extending the points by a spline:: @@ -740,12 +740,12 @@ cdef class Riemann_Map: Default plot:: - sage: m.plot_boundaries() + sage: m.plot_boundaries() # needs sage.plot Graphics object consisting of 1 graphics primitive Big blue collocation points:: - sage: m.plot_boundaries(plotjoined=False, rgbcolor=[0,0,1], thickness=6) + sage: m.plot_boundaries(plotjoined=False, rgbcolor=[0,0,1], thickness=6) # needs sage.plot Graphics object consisting of 1 graphics primitive """ from sage.plot.all import list_plot @@ -905,17 +905,18 @@ cdef class Riemann_Map: Default plot:: - sage: m.plot_spiderweb() + sage: m.plot_spiderweb() # needs sage.plot Graphics object consisting of 21 graphics primitives Simplified plot with many discrete points:: - sage: m.plot_spiderweb(spokes=4, circles=1, pts=400, linescale=0.95, plotjoined=False) + sage: m.plot_spiderweb(spokes=4, circles=1, pts=400, # needs sage.plot + ....: linescale=0.95, plotjoined=False) Graphics object consisting of 6 graphics primitives Plot with thick, red lines:: - sage: m.plot_spiderweb(rgbcolor=[1,0,0], thickness=3) + sage: m.plot_spiderweb(rgbcolor=[1,0,0], thickness=3) # needs sage.plot Graphics object consisting of 21 graphics primitives To generate the unit circle map, it's helpful to see what the @@ -924,7 +925,7 @@ cdef class Riemann_Map: sage: f(t) = e^(I*t) sage: fprime(t) = I*e^(I*t) sage: m = Riemann_Map([f], [fprime], 0, 1000) - sage: m.plot_spiderweb() + sage: m.plot_spiderweb() # needs sage.plot Graphics object consisting of 21 graphics primitives A multiply connected region with corners. We set ``min_mag`` higher @@ -934,8 +935,10 @@ cdef class Riemann_Map: sage: z1 = lambda t: ps.value(t); z1p = lambda t: ps.derivative(t) sage: z2(t) = -2+exp(-I*t); z2p(t) = -I*exp(-I*t) sage: z3(t) = 2+exp(-I*t); z3p(t) = -I*exp(-I*t) - sage: m = Riemann_Map([z1,z2,z3],[z1p,z2p,z3p],0,ncorners=4) # long time - sage: p = m.plot_spiderweb(withcolor=True,plot_points=500, thickness = 2.0, min_mag=0.1) # long time + sage: m = Riemann_Map([z1,z2,z3], [z1p,z2p,z3p], 0, # long time + ....: ncorners=4) + sage: p = m.plot_spiderweb(withcolor=True, plot_points=500, # long time, needs sage.plot + ....: thickness=2.0, min_mag=0.1) """ from sage.plot.complex_plot import ComplexPlot from sage.plot.all import list_plot, Graphics @@ -1028,17 +1031,17 @@ cdef class Riemann_Map: sage: f(t) = e^(I*t) - 0.5*e^(-I*t) sage: fprime(t) = I*e^(I*t) + 0.5*I*e^(-I*t) sage: m = Riemann_Map([f], [fprime], 0) - sage: m.plot_colored() + sage: m.plot_colored() # needs sage.plot Graphics object consisting of 1 graphics primitive Plot zoomed in on a specific spot:: - sage: m.plot_colored(plot_range=[0,1,.25,.75]) + sage: m.plot_colored(plot_range=[0,1,.25,.75]) # needs sage.plot Graphics object consisting of 1 graphics primitive High resolution plot:: - sage: m.plot_colored(plot_points=1000) # long time (29s on sage.math, 2012) + sage: m.plot_colored(plot_points=1000) # long time (29s on sage.math, 2012), needs sage.plot Graphics object consisting of 1 graphics primitive To generate the unit circle map, it's helpful to see what the @@ -1047,7 +1050,7 @@ cdef class Riemann_Map: sage: f(t) = e^(I*t) sage: fprime(t) = I*e^(I*t) sage: m = Riemann_Map([f], [fprime], 0, 1000) - sage: m.plot_colored() + sage: m.plot_colored() # needs sage.plot Graphics object consisting of 1 graphics primitive """ from sage.plot.complex_plot import ComplexPlot @@ -1081,7 +1084,7 @@ cdef comp_pt(clist, loop=True): sage: f(t) = e^(I*t) - 0.5*e^(-I*t) sage: fprime(t) = I*e^(I*t) + 0.5*I*e^(-I*t) sage: m = Riemann_Map([f], [fprime], 0) - sage: m.plot_spiderweb() + sage: m.plot_spiderweb() # needs sage.plot Graphics object consisting of 21 graphics primitives """ list2 = [(c.real, c.imag) for c in clist] diff --git a/src/sage/calculus/transforms/dft.py b/src/sage/calculus/transforms/dft.py index 1b165fa6503..cd0c76bfc07 100644 --- a/src/sage/calculus/transforms/dft.py +++ b/src/sage/calculus/transforms/dft.py @@ -294,13 +294,15 @@ def dft(self, chi=None): Indexed sequence: [6, 0, 0, 0, 0, 0] indexed by [0, 1, 2, 3, 4, 5] - sage: # needs sage.groups + sage: # needs sage.combinat sage.groups sage: G = SymmetricGroup(3) sage: J = G.conjugacy_classes_representatives() sage: s = IndexedSequence([1,2,3], J) # 1,2,3 are the values of a class fcn on G sage: s.dft() # the "scalar-valued Fourier transform" of this class fcn Indexed sequence: [8, 2, 2] indexed by [(), (1,2), (1,2,3)] + + sage: # needs sage.rings.number_field sage: J = AbelianGroup(2, [2,3], names='ab') sage: s = IndexedSequence([1,2,3,4,5,6], J) sage: s.dft() # the precision of output is somewhat random and architecture dependent. @@ -311,6 +313,8 @@ def dft(self, chi=None): -0.00000000000000976996261670137 - 0.0000000000000159872115546022*I, -0.00000000000000621724893790087 - 0.0000000000000106581410364015*I] indexed by Multiplicative Abelian group isomorphic to C2 x C3 + + sage: # needs sage.groups sage.rings.number_field sage: J = CyclicPermutationGroup(6) sage: s = IndexedSequence([1,2,3,4,5,6], J) sage: s.dft() # the precision of output is somewhat random and architecture dependent. diff --git a/src/sage/calculus/transforms/fft.pyx b/src/sage/calculus/transforms/fft.pyx index 363fa65a836..ca7fd73cb64 100644 --- a/src/sage/calculus/transforms/fft.pyx +++ b/src/sage/calculus/transforms/fft.pyx @@ -243,7 +243,7 @@ cdef class FastFourierTransform_complex(FastFourierTransform_base): EXAMPLES:: sage: a = FastFourierTransform(4) - sage: a._plot_polar(0,2) # needs sage.plot + sage: a._plot_polar(0,2) # needs sage.plot sage.symbolic Graphics object consisting of 2 graphics primitives """ @@ -304,9 +304,9 @@ cdef class FastFourierTransform_complex(FastFourierTransform_base): - ``style`` -- Style of the plot, options are ``"rect"`` or ``"polar"`` - - ``rect`` -- height represents real part, color represents + - ``"rect"`` -- height represents real part, color represents imaginary part. - - ``polar`` -- height represents absolute value, color + - ``"polar"`` -- height represents absolute value, color represents argument. - ``xmin`` -- The lower bound of the slice to plot. 0 by default. @@ -319,13 +319,14 @@ cdef class FastFourierTransform_complex(FastFourierTransform_base): EXAMPLES:: + sage: # needs sage.plot sage: a = FastFourierTransform(16) sage: for i in range(16): a[i] = (random(),random()) - sage: A = plot(a) # needs sage.plot - sage: B = plot(a, style='polar') # needs sage.plot - sage: type(A) # needs sage.plot + sage: A = plot(a) + sage: B = plot(a, style='polar') # needs sage.symbolic + sage: type(A) - sage: type(B) # needs sage.plot + sage: type(B) # needs sage.symbolic sage: a = FastFourierTransform(125) sage: b = FastFourierTransform(125) @@ -333,7 +334,7 @@ cdef class FastFourierTransform_complex(FastFourierTransform_base): sage: for i in range(1, 60): b[i]=1 sage: a.forward_transform() sage: a.inverse_transform() - sage: a.plot() + b.plot() # needs sage.plot + sage: a.plot() + b.plot() Graphics object consisting of 250 graphics primitives """ diff --git a/src/sage/functions/error.py b/src/sage/functions/error.py index 76509ce5ef0..db6312af807 100644 --- a/src/sage/functions/error.py +++ b/src/sage/functions/error.py @@ -265,7 +265,7 @@ def _evalf_(self, x, parent=None, algorithm=None): sage: gp.set_real_precision(59) # random # needs sage.libs.pari 38 - sage: print(gp.eval("1 - erfc(1)")); print(erf(1).n(200)) # needs sage.libs.pari + sage: print(gp.eval("1 - erfc(1)")); print(erf(1).n(200)) # needs mpmath sage.libs.pari 0.84270079294971486934122063508260925929606699796630290845994 0.84270079294971486934122063508260925929606699796630290845994 diff --git a/src/sage/functions/exp_integral.py b/src/sage/functions/exp_integral.py index 913cb577bef..b5638f8d35f 100644 --- a/src/sage/functions/exp_integral.py +++ b/src/sage/functions/exp_integral.py @@ -1470,7 +1470,7 @@ def exponential_integral_1(x, n=0): EXAMPLES:: - sage: # needs sage.libs.pari + sage: # needs sage.libs.pari sage.rings.real_mpfr sage: exponential_integral_1(2) 0.0489005107080611 sage: exponential_integral_1(2, 4) # abs tol 1e-18 @@ -1519,7 +1519,7 @@ def exponential_integral_1(x, n=0): ....: if e >= c: ....: print("exponential_integral_1(%s, %s)[%s] with precision %s has error of %s >= %s"%(a, n, i, prec, e, c)) - ALGORITHM: use the PARI C-library function ``eint1``. + ALGORITHM: use the PARI C-library function :pari:`eint1`. REFERENCE: diff --git a/src/sage/functions/gamma.py b/src/sage/functions/gamma.py index 0af99e5dc20..be2d60d0861 100644 --- a/src/sage/functions/gamma.py +++ b/src/sage/functions/gamma.py @@ -40,9 +40,9 @@ def __init__(self): EXAMPLES:: sage: from sage.functions.gamma import gamma1 - sage: gamma1(CDF(0.5, 14)) # needs sage.libs.pari + sage: gamma1(CDF(0.5, 14)) # needs sage.libs.pari sage.rings.complex_double -4.0537030780372815e-10 - 5.773299834553605e-10*I - sage: gamma1(CDF(I)) # needs sage.libs.pari sage.symbolic + sage: gamma1(CDF(I)) # needs sage.libs.pari sage.rings.complex_double sage.symbolic -0.15494982830181067 - 0.49801566811835607*I Recall that `\Gamma(n)` is `n-1` factorial:: @@ -99,7 +99,7 @@ def __init__(self): 1*x^(-2) + (-2*euler_gamma)*x^(-1) + (2*euler_gamma^2 + 1/6*pi^2) + Order(x) - To prevent automatic evaluation use the ``hold`` argument:: + To prevent automatic evaluation, use the ``hold`` argument:: sage: gamma1(1/2, hold=True) # needs sage.symbolic gamma(1/2) @@ -138,9 +138,9 @@ def __init__(self): Infinity sage: (-1.).gamma() # needs sage.rings.real_mpfr NaN - sage: CC(-1).gamma() # needs sage.libs.pari + sage: CC(-1).gamma() # needs sage.libs.pari sage.rings.real_mpfr Infinity - sage: RDF(-1).gamma() + sage: RDF(-1).gamma() # needs sage.rings.real_mpfr NaN sage: CDF(-1).gamma() # needs sage.libs.pari sage.rings.complex_double Infinity @@ -691,9 +691,9 @@ def gamma(a, *args, **kwds): :: - sage: gamma(CDF(I)) # needs sage.libs.pari sage.symbolic + sage: gamma(CDF(I)) # needs sage.libs.pari sage.rings.complex_double sage.symbolic -0.15494982830181067 - 0.49801566811835607*I - sage: gamma(CDF(0.5, 14)) # needs sage.libs.pari + sage: gamma(CDF(0.5, 14)) # needs sage.libs.pari sage.rings.complex_double -4.0537030780372815e-10 - 5.773299834553605e-10*I Use ``numerical_approx`` to get higher precision from @@ -721,7 +721,8 @@ def gamma(a, *args, **kwds): sage: gamma(i) # needs sage.rings.number_field sage.symbolic Traceback (most recent call last): ... - TypeError: cannot coerce arguments: no canonical coercion from Number Field in i with defining polynomial x^2 + 1 to Symbolic Ring + TypeError: cannot coerce arguments: no canonical coercion + from Number Field in i with defining polynomial x^2 + 1 to Symbolic Ring .. SEEALSO:: @@ -1004,9 +1005,9 @@ def __init__(self): INPUT: - - ``p`` - number or symbolic expression + - ``p`` -- number or symbolic expression - - ``q`` - number or symbolic expression + - ``q`` -- number or symbolic expression OUTPUT: number or symbolic expression (if input is symbolic) @@ -1016,18 +1017,18 @@ def __init__(self): sage: # needs sage.symbolic sage: beta(3, 2) 1/12 - sage: beta(3,1) + sage: beta(3, 1) 1/3 sage: beta(1/2, 1/2) beta(1/2, 1/2) - sage: beta(-1,1) + sage: beta(-1, 1) -1 - sage: beta(-1/2,-1/2) + sage: beta(-1/2, -1/2) 0 sage: ex = beta(x/2, 3) sage: set(ex.operands()) == set([1/2*x, 3]) True - sage: beta(.5,.5) + sage: beta(.5, .5) 3.14159265358979 sage: beta(1, 2.0+I) 0.400000000000000 - 0.200000000000000*I diff --git a/src/sage/functions/generalized.py b/src/sage/functions/generalized.py index 5e66d267828..ba8222121b9 100644 --- a/src/sage/functions/generalized.py +++ b/src/sage/functions/generalized.py @@ -290,7 +290,7 @@ class FunctionUnitStep(GinacFunction): INPUT: - - ``x`` - a real number or a symbolic expression + - ``x`` -- a real number or a symbolic expression DEFINITION: @@ -331,7 +331,7 @@ def __init__(self): INPUT: - - ``x`` - a real number or a symbolic expression + - ``x`` -- a real number or a symbolic expression EXAMPLES:: @@ -378,7 +378,7 @@ class FunctionSignum(BuiltinFunction): INPUT: - - ``x`` - a real number or a symbolic expression + - ``x`` -- a real number or a symbolic expression DEFINITION: @@ -548,8 +548,8 @@ class FunctionKroneckerDelta(BuiltinFunction): INPUT: - - ``m`` - a number or a symbolic expression - - ``n`` - a number or a symbolic expression + - ``m`` -- a number or a symbolic expression + - ``n`` -- a number or a symbolic expression DEFINITION: @@ -560,9 +560,9 @@ class FunctionKroneckerDelta(BuiltinFunction): EXAMPLES:: - sage: kronecker_delta(1,2) # needs sage.rings.complex_interval_field + sage: kronecker_delta(1, 2) # needs sage.rings.complex_interval_field 0 - sage: kronecker_delta(1,1) # needs sage.rings.complex_interval_field + sage: kronecker_delta(1, 1) # needs sage.rings.complex_interval_field 1 sage: m, n = var('m,n') # needs sage.symbolic sage: kronecker_delta(m, n) # needs sage.symbolic @@ -579,9 +579,9 @@ def __init__(self): EXAMPLES:: - sage: kronecker_delta(1,2) # needs sage.rings.complex_interval_field + sage: kronecker_delta(1, 2) # needs sage.rings.complex_interval_field 0 - sage: kronecker_delta(1,1) # needs sage.rings.complex_interval_field + sage: kronecker_delta(1, 1) # needs sage.rings.complex_interval_field 1 sage: y = var('y') # needs sage.symbolic sage: kronecker_delta(x, y)._sympy_() # needs sympy sage.symbolic @@ -598,9 +598,9 @@ def _eval_(self, m, n): EXAMPLES:: - sage: kronecker_delta(1,2) # needs sage.rings.complex_interval_field + sage: kronecker_delta(1, 2) # needs sage.rings.complex_interval_field 0 - sage: kronecker_delta(1,1) # needs sage.rings.complex_interval_field + sage: kronecker_delta(1, 1) # needs sage.rings.complex_interval_field 1 Kronecker delta is a symmetric function. We keep arguments sorted to diff --git a/src/sage/functions/hyperbolic.py b/src/sage/functions/hyperbolic.py index 7c94892ba9d..6098a6de0bb 100644 --- a/src/sage/functions/hyperbolic.py +++ b/src/sage/functions/hyperbolic.py @@ -53,7 +53,7 @@ def __init__(self): EXAMPLES:: - sage: sinh(3.1415) + sage: sinh(3.1415) # needs sage.rings.real_mpfr 11.5476653707437 sage: # needs sage.symbolic @@ -91,7 +91,7 @@ def __init__(self): EXAMPLES:: - sage: cosh(3.1415) + sage: cosh(3.1415) # needs sage.rings.real_mpfr 11.5908832931176 sage: # needs sage.symbolic @@ -129,9 +129,9 @@ def __init__(self): EXAMPLES:: - sage: tanh(3.1415) + sage: tanh(3.1415) # needs sage.rings.real_mpfr 0.996271386633702 - sage: tan(3.1415/4) + sage: tan(3.1415/4) # needs sage.rings.real_mpfr 0.999953674278156 sage: # needs sage.symbolic @@ -197,7 +197,7 @@ def __init__(self): EXAMPLES:: - sage: coth(3.1415) + sage: coth(3.1415) # needs sage.rings.real_mpfr 1.00374256795520 sage: coth(complex(1, 2)) # abs tol 1e-15 # needs sage.rings.complex_double (0.8213297974938518+0.17138361290918508j) @@ -256,7 +256,7 @@ def __init__(self): EXAMPLES:: - sage: sech(3.1415) + sage: sech(3.1415) # needs sage.rings.real_mpfr 0.0862747018248192 sage: # needs sage.symbolic @@ -313,7 +313,7 @@ def __init__(self): EXAMPLES:: - sage: csch(3.1415) + sage: csch(3.1415) # needs sage.rings.real_mpfr 0.0865975907592133 sage: # needs sage.symbolic @@ -375,7 +375,7 @@ def __init__(self): sage: asinh arcsinh - sage: asinh(0.5) + sage: asinh(0.5) # needs sage.rings.real_mpfr 0.481211825059603 sage: asinh(1/2) # needs sage.symbolic arcsinh(1/2) @@ -527,7 +527,7 @@ def __init__(self): EXAMPLES:: - sage: atanh(0.5) + sage: atanh(0.5) # needs sage.rings.real_mpfr 0.549306144334055 sage: atanh(1/2) # needs sage.symbolic 1/2*log(3) diff --git a/src/sage/functions/hypergeometric.py b/src/sage/functions/hypergeometric.py index 6e2b26d284a..010c61febe0 100644 --- a/src/sage/functions/hypergeometric.py +++ b/src/sage/functions/hypergeometric.py @@ -14,13 +14,14 @@ Examples from :issue:`9908`:: + sage: # needs sage.symbolic sage: maxima('integrate(bessel_j(2, x), x)').sage() 1/24*x^3*hypergeometric((3/2,), (5/2, 3), -1/4*x^2) sage: sum(((2*I)^x/(x^3 + 1)*(1/4)^x), x, 0, oo) hypergeometric((1, 1, -1/2*I*sqrt(3) - 1/2, 1/2*I*sqrt(3) - 1/2),... (2, -1/2*I*sqrt(3) + 1/2, 1/2*I*sqrt(3) + 1/2), 1/2*I) sage: res = sum((-1)^x/((2*x + 1)*factorial(2*x + 1)), x, 0, oo) - sage: res # not tested - depends on maxima version + sage: res # not tested (depends on maxima version) hypergeometric((1/2,), (3/2, 3/2), -1/4) sage: res in [hypergeometric((1/2,), (3/2, 3/2), -1/4), sin_integral(1)] True @@ -28,6 +29,7 @@ Simplification (note that ``simplify_full`` does not yet call ``simplify_hypergeometric``):: + sage: # needs sage.symbolic sage: hypergeometric([-2], [], x).simplify_hypergeometric() x^2 - 2*x + 1 sage: hypergeometric([], [], x).simplify_hypergeometric() @@ -41,10 +43,10 @@ Equality testing:: - sage: bool(hypergeometric([], [], x).derivative(x) == + sage: bool(hypergeometric([], [], x).derivative(x) == # needs sage.symbolic ....: hypergeometric([], [], x)) # diff(e^x, x) == e^x True - sage: bool(hypergeometric([], [], x) == hypergeometric([], [1], x)) + sage: bool(hypergeometric([], [], x) == hypergeometric([], [1], x)) # needs sage.symbolic False Computing terms and series:: @@ -79,14 +81,14 @@ 1 + (-1/2)*z^2 + 1/24*z^4 + (-1/720)*z^6 + 1/40320*z^8 +... (-1/3628800)*z^10 + Order(z^11) - sage: hypergeometric([1], [5], x).series(x, 5) + sage: hypergeometric([1], [5], x).series(x, 5) # needs sage.symbolic 1 + 1/5*x + 1/30*x^2 + 1/210*x^3 + 1/1680*x^4 + Order(x^5) sage: sum(hypergeometric([1, 2], [3], 1/3).terms(6)).n() # needs sage.symbolic 1.29788359788360 sage: hypergeometric([1, 2], [3], 1/3).n() # needs sage.symbolic 1.29837194594696 - sage: hypergeometric([], [], x).series(x, 20)(x=1).n() == e.n() + sage: hypergeometric([], [], x).series(x, 20)(x=1).n() == e.n() # needs sage.symbolic True Plotting:: @@ -96,7 +98,7 @@ sage: plot(f, x, -30, 30) # needs sage.plot Graphics object consisting of 1 graphics primitive sage: g(x) = hypergeometric([x], [], 2) - sage: complex_plot(g, (-1, 1), (-1, 1)) + sage: complex_plot(g, (-1, 1), (-1, 1)) # needs sage.plot Graphics object consisting of 1 graphics primitive Numeric evaluation:: @@ -121,7 +123,7 @@ sage: maxima(hypergeometric([1, 1, 1], [3, 3, 3], x)) # needs sage.symbolic hypergeometric([1,1,1],[3,3,3],_SAGE_VAR_x) - sage: hypergeometric((5, 4), (4, 4), 3)._sympy_() # needs sage.symbolic + sage: hypergeometric((5, 4), (4, 4), 3)._sympy_() # needs sympy sage.symbolic hyper((5, 4), (4, 4), 3) sage: hypergeometric((5, 4), (4, 4), 3)._mathematica_init_() # needs sage.symbolic 'HypergeometricPFQ[{5,4},{4,4},3]' @@ -154,7 +156,7 @@ 1 + 1*x + 1/2*x^2 + Order(x^3) sage: hypergeometric_U(2, 2, x).series(x == 3, 100).subs(x=1).n() # needs sage.symbolic 0.403652637676806 - sage: hypergeometric_U(2, 2, 1).n() # needs mpmath + sage: hypergeometric_U(2, 2, 1).n() # needs mpmath sage.symbolic 0.403652637676806 """ @@ -451,7 +453,7 @@ def eliminate_parameters(self, a, b, z): sage: hypergeometric([1, 1, 2, 5], [5, 1, 4], # needs sage.symbolic ....: 1/2).eliminate_parameters() hypergeometric((1, 2), (4,), 1/2) - sage: hypergeometric([x], [x], x).eliminate_parameters() + sage: hypergeometric([x], [x], x).eliminate_parameters() # needs sage.symbolic hypergeometric((), (), x) sage: hypergeometric((5, 4), (4, 4), 3).eliminate_parameters() # needs sage.symbolic hypergeometric((5,), (4,), 3) @@ -538,11 +540,11 @@ def is_terminating(self, a, b, z): EXAMPLES:: - sage: hypergeometric([1, 2], [3, 4], x).is_terminating() + sage: hypergeometric([1, 2], [3, 4], x).is_terminating() # needs sage.symbolic False - sage: hypergeometric([1, -2], [3, 4], x).is_terminating() + sage: hypergeometric([1, -2], [3, 4], x).is_terminating() # needs sage.symbolic True - sage: hypergeometric([1, -2], [], x).is_terminating() + sage: hypergeometric([1, -2], [], x).is_terminating() # needs sage.symbolic True """ if z == 0: @@ -642,11 +644,11 @@ def terms(self, a, b, z, n=None): EXAMPLES:: - sage: list(hypergeometric([-2, 1], [3, 4], x).terms()) + sage: list(hypergeometric([-2, 1], [3, 4], x).terms()) # needs sage.symbolic [1, -1/6*x, 1/120*x^2] - sage: list(hypergeometric([-2, 1], [3, 4], x).terms(2)) + sage: list(hypergeometric([-2, 1], [3, 4], x).terms(2)) # needs sage.symbolic [1, -1/6*x] - sage: list(hypergeometric([-2, 1], [3, 4], x).terms(0)) + sage: list(hypergeometric([-2, 1], [3, 4], x).terms(0)) # needs sage.symbolic [] """ if n is None: @@ -675,8 +677,7 @@ def deflated(self, a, b, z): sage: # needs sage.symbolic sage: x = hypergeometric([6, 1], [3, 4, 5], 10) - sage: y = x.deflated() - sage: y + sage: y = x.deflated(); y 1/252*hypergeometric((4,), (7, 8), 10) + 1/12*hypergeometric((3,), (6, 7), 10) + 1/2*hypergeometric((2,), (5, 6), 10) @@ -687,8 +688,7 @@ def deflated(self, a, b, z): sage: # needs sage.symbolic sage: x = hypergeometric([6, 7], [3, 4, 5], 10) - sage: y = x.deflated() - sage: y + sage: y = x.deflated(); y 25/27216*hypergeometric((), (11,), 10) + 25/648*hypergeometric((), (10,), 10) + 265/504*hypergeometric((), (9,), 10) @@ -710,8 +710,7 @@ def _deflated(self, a, b, z): sage: # needs sage.symbolic sage: x = hypergeometric([5], [4], 3) - sage: y = x.deflated() - sage: y + sage: y = x.deflated(); y 7/4*hypergeometric((), (), 3) sage: x.n(); y.n() 35.1496896155784 @@ -958,21 +957,21 @@ class Hypergeometric_M(BuiltinFunction): EXAMPLES:: - sage: # needs mpmath + + sage: hypergeometric_M(1, 1, 1.) # needs mpmath + 2.71828182845905 + + sage: # needs sage.symbolic sage: hypergeometric_M(1, 1, 1) hypergeometric_M(1, 1, 1) - sage: hypergeometric_M(1, 1, 1.) - 2.71828182845905 - sage: hypergeometric_M(1, 1, 1).n(70) + sage: hypergeometric_M(1, 1, 1).n(70) # needs mpmath 2.7182818284590452354 sage: hypergeometric_M(1, 1, 1).simplify_hypergeometric() e sage: hypergeometric_M(1, 3/2, 1).simplify_hypergeometric() 1/2*sqrt(pi)*erf(1)*e - - sage: hypergeometric_M(1, 1/2, x).simplify_hypergeometric() # needs sage.symbolic + sage: hypergeometric_M(1, 1/2, x).simplify_hypergeometric() (-I*sqrt(pi)*x*erf(I*sqrt(-x))*e^x + sqrt(-x))/sqrt(-x) - """ def __init__(self): r""" @@ -980,7 +979,7 @@ def __init__(self): sage: maxima(hypergeometric_M(1,1,x)) # needs sage.symbolic kummer_m(1,1,_SAGE_VAR_x) - sage: latex(hypergeometric_M(1,1,x)) + sage: latex(hypergeometric_M(1,1,x)) # needs sage.symbolic M\left(1, 1, x\right) """ BuiltinFunction.__init__(self, 'hypergeometric_M', nargs=3, @@ -995,8 +994,8 @@ def _eval_(self, a, b, z, **kwargs): """ TESTS:: - sage: (a,b)=var('a,b') # needs sage.symbolic - sage: hypergeometric_M(a,b,0) # needs sage.symbolic + sage: a, b = var('a,b') # needs sage.symbolic + sage: hypergeometric_M(a, b, 0) # needs sage.symbolic 1 """ if not isinstance(z, Expression) and z == 0: @@ -1007,7 +1006,7 @@ def _evalf_(self, a, b, z, parent, algorithm=None): """ TESTS:: - sage: hypergeometric_M(1,1,1).n() # needs mpmath + sage: hypergeometric_M(1,1,1).n() # needs mpmath sage.symbolic 2.71828182845905 """ return _mpmath_utils_call(_mpmath_hyp1f1, a, b, z, parent=parent) @@ -1016,9 +1015,9 @@ def _derivative_(self, a, b, z, diff_param): """ TESTS:: - sage: diff(hypergeometric_M(1,1,x),x,3) + sage: diff(hypergeometric_M(1, 1, x), x, 3) # needs sage.symbolic hypergeometric_M(4, 4, x) - sage: diff(hypergeometric_M(x,1,1),x,3) + sage: diff(hypergeometric_M(x, 1, 1), x, 3) # needs sage.symbolic Traceback (most recent call last): ... NotImplementedError: derivative of hypergeometric function with respect to parameters @@ -1076,7 +1075,9 @@ class Hypergeometric_U(BuiltinFunction): hypergeometric_U(1, 1, 1) sage: hypergeometric_U(1, 1, 1.) 0.596347362323194 - sage: hypergeometric_U(1, 1, 1).n(70) + + sage: # needs sage.symbolic + sage: hypergeometric_U(1, 1, 1).n(70) # needs mpmath 0.59634736232319407434 sage: hypergeometric_U(10^4, 1/3, 1).n() # needs sage.libs.pari 6.60377008885811e-35745 @@ -1092,9 +1093,9 @@ def __init__(self): r""" TESTS:: - sage: maxima(hypergeometric_U(1,1,x)) # needs sage.symbolic + sage: maxima(hypergeometric_U(1, 1, x)) # needs sage.symbolic kummer_u(1,1,_SAGE_VAR_x) - sage: latex(hypergeometric_U(1,1,x)) + sage: latex(hypergeometric_U(1, 1, x)) # needs sage.symbolic U\left(1, 1, x\right) """ BuiltinFunction.__init__(self, 'hypergeometric_U', nargs=3, @@ -1112,7 +1113,7 @@ def _evalf_(self, a, b, z, parent, algorithm=None): """ TESTS:: - sage: hypergeometric_U(1,1,1).n() # needs mpmath + sage: hypergeometric_U(1, 1, 1).n() # needs mpmath sage.symbolic 0.596347362323194 """ return _mpmath_utils_call(_mpmath_hyperu, a, b, z, parent=parent) @@ -1121,9 +1122,9 @@ def _derivative_(self, a, b, z, diff_param): """ TESTS:: - sage: diff(hypergeometric_U(1,1,x),x,3) + sage: diff(hypergeometric_U(1, 1, x), x, 3) # needs sage.symbolic -6*hypergeometric_U(4, 4, x) - sage: diff(hypergeometric_U(x,1,1),x,3) + sage: diff(hypergeometric_U(x, 1, 1), x, 3) # needs sage.symbolic Traceback (most recent call last): ... NotImplementedError: derivative of hypergeometric function with respect to parameters @@ -1140,13 +1141,14 @@ def generalized(self, a, b, z): EXAMPLES:: - sage: var('a b z') # needs sage.symbolic + sage: # needs sage.symbolic + sage: var('a b z') (a, b, z) - sage: hypergeometric_U(a, b, z).generalized() # needs sage.symbolic + sage: hypergeometric_U(a, b, z).generalized() hypergeometric((a, a - b + 1), (), -1/z)/z^a - sage: hypergeometric_U(1, 3, 1/2).generalized() # needs mpmath + sage: hypergeometric_U(1, 3, 1/2).generalized() 2*hypergeometric((1, -1), (), -2) - sage: hypergeometric_U(3, I, 2).generalized() # needs sage.symbolic + sage: hypergeometric_U(3, I, 2).generalized() 1/8*hypergeometric((3, -I + 4), (), -1/2) """ diff --git a/src/sage/functions/log.py b/src/sage/functions/log.py index 37e5f601e59..903bb7cfe75 100644 --- a/src/sage/functions/log.py +++ b/src/sage/functions/log.py @@ -63,7 +63,7 @@ class Function_exp(GinacFunction): sage: exp(float(2.5)) 12.182493960703473 - sage: exp(RDF('2.5')) + sage: exp(RDF('2.5')) # needs sage.symbolic 12.182493960703473 To prevent automatic evaluation, use the ``hold`` parameter:: diff --git a/src/sage/functions/orthogonal_polys.py b/src/sage/functions/orthogonal_polys.py index 8976001bc62..1de970e0aa4 100644 --- a/src/sage/functions/orthogonal_polys.py +++ b/src/sage/functions/orthogonal_polys.py @@ -439,7 +439,7 @@ class OrthogonalFunction(BuiltinFunction): def __init__(self, name, nargs=2, latex_name=None, conversions=None): """ :class:`OrthogonalFunction` class needs the same input parameter as - it's parent class. + its parent class. EXAMPLES:: @@ -466,7 +466,7 @@ def eval_formula(self, *args): sage: from sage.functions.orthogonal_polys import OrthogonalFunction sage: P = OrthogonalFunction('testo_P') - sage: P.eval_formula(1,2.0) + sage: P.eval_formula(1, 2.0) Traceback (most recent call last): ... NotImplementedError: no explicit calculation of values implemented @@ -543,8 +543,8 @@ class ChebyshevFunction(OrthogonalFunction): """ def __call__(self, n, *args, **kwds): """ - This overides the call method from SageObject to avoid problems with coercions, - since the _eval_ method is able to handle more data types than symbolic functions + This overides the call method from :class:`SageObject` to avoid problems with coercions, + since the ``_eval_`` method is able to handle more data types than symbolic functions would normally allow. Thus we have the distinction between algebraic objects (if n is an integer), and else as symbolic function. @@ -563,7 +563,7 @@ def __call__(self, n, *args, **kwds): Univariate Polynomial Ring in x over Rational Field sage: chebyshev_T(5, 2, hold=True) # needs sage.symbolic chebyshev_T(5, 2) - sage: chebyshev_T(1,2,3) + sage: chebyshev_T(1, 2, 3) Traceback (most recent call last): ... TypeError: Symbolic function chebyshev_T takes exactly 2 arguments (3 given) @@ -599,11 +599,11 @@ def _eval_(self, n, x): chebyshev_T(3/2, x) sage: R. = QQ[] - sage: chebyshev_T(2,t) + sage: chebyshev_T(2, t) 2*t^2 - 1 - sage: chebyshev_U(2,t) + sage: chebyshev_U(2, t) 4*t^2 - 1 - sage: parent(chebyshev_T(4, RIF(5))) + sage: parent(chebyshev_T(4, RIF(5))) # needs sage.rings.real_interval_field Real Interval Field with 53 bits of precision sage: RR2 = RealField(5) # needs sage.rings.real_mpfr sage: chebyshev_T(100000, RR2(2)) # needs sage.rings.real_mpfr @@ -779,8 +779,9 @@ def _evalf_(self, n, x, **kwds): sage: chebyshev_T._evalf_(10^6, 0.1) # needs sage.rings.real_mpfr Traceback (most recent call last): ... - NoConvergence: Hypergeometric series converges too slowly. Try increasing maxterms. - sage: chebyshev_T(10^6, 0.1) + NoConvergence: Hypergeometric series converges too slowly. + Try increasing maxterms. + sage: chebyshev_T(10^6, 0.1) # needs sage.rings.real_mpfr 0.636384327171504 """ try: @@ -976,9 +977,9 @@ class Func_chebyshev_U(ChebyshevFunction): EXAMPLES:: sage: R. = QQ[] - sage: chebyshev_U(2,t) + sage: chebyshev_U(2, t) 4*t^2 - 1 - sage: chebyshev_U(3,t) + sage: chebyshev_U(3, t) 8*t^3 - 4*t """ def __init__(self): @@ -1052,7 +1053,7 @@ def eval_formula(self, n, x): 1 sage: chebyshev_U.eval_formula(1, x) 2*x - sage: chebyshev_U.eval_formula(2,0.1) == chebyshev_U._evalf_(2,0.1) + sage: chebyshev_U.eval_formula(2, 0.1) == chebyshev_U._evalf_(2, 0.1) True """ if n < -1: @@ -1086,9 +1087,9 @@ def eval_algebraic(self, n, x): Ring of integers modulo 9 sage: chebyshev_U(-3, x) + chebyshev_U(1, x) # needs sage.symbolic 0 - sage: chebyshev_U(-1,Mod(5,8)) + sage: chebyshev_U(-1, Mod(5,8)) 0 - sage: parent(chebyshev_U(-1,Mod(5,8))) + sage: parent(chebyshev_U(-1, Mod(5,8))) Ring of integers modulo 8 sage: R. = ZZ[] sage: chebyshev_U.eval_algebraic(-2, t) @@ -1102,8 +1103,10 @@ def eval_algebraic(self, n, x): sage: n = 97; x = RIF(pi/n) # needs sage.symbolic sage: chebyshev_U(n - 1, cos(x)).contains_zero() # needs sage.symbolic True - sage: R. = Zp(2, 6, 'capped-abs')[] # needs sage.rings.padics - sage: chebyshev_U(10^6 + 1, t) # needs sage.rings.padics + + sage: # needs sage.rings.padics + sage: R. = Zp(2, 6, 'capped-abs')[] + sage: chebyshev_U(10^6 + 1, t) (2 + O(2^6))*t + O(2^6) """ if n == -1: @@ -1142,7 +1145,7 @@ def _evalf_(self, n, x, **kwds): EXAMPLES:: - sage: chebyshev_U(5,-4+3.*I) # needs sage.symbolic + sage: chebyshev_U(5, -4 + 3.*I) # needs sage.symbolic 98280.0000000000 - 11310.0000000000*I sage: chebyshev_U(10, 3).n(75) # needs sage.symbolic 4.661117900000000000000e7 @@ -1676,7 +1679,7 @@ class Func_assoc_legendre_P(BuiltinFunction): -sqrt(-x^2 + 1) sage: gen_legendre_P(1, 1, 0.5) # abs tol 1e-14 # needs mpmath -0.866025403784439 - sage: gen_legendre_P.eval_gen_poly(1, 1, 0.5) # abs tol 1e-14 + sage: gen_legendre_P.eval_gen_poly(1, 1, 0.5) # abs tol 1e-14 # needs sage.rings.real_mpfr -0.866025403784439 sage: gen_legendre_P._evalf_(1, 1, 0.5) # abs tol 1e-14 # needs mpmath -0.866025403784439 @@ -1831,7 +1834,7 @@ def _evalf_(self, n, m, x, parent=None, **kwds): sage: gen_legendre_P(10, 2, 3).n() # abs tol 1e-14 # needs sage.symbolic -7.19496360000000e8 - sage: gen_legendre_P(5/2,2,1.+I) # needs sage.symbolic + sage: gen_legendre_P(5/2, 2, 1. + I) # needs sage.symbolic 14.3165258449040 - 12.7850496155152*I sage: gen_legendre_P(5/2, 2, ComplexField(70)(1+I)) # needs sage.rings.real_mpfr sage.symbolic 14.316525844904028532 - 12.785049615515157033*I @@ -2145,9 +2148,9 @@ class Func_jacobi_P(OrthogonalFunction): EXAMPLES:: sage: x = PolynomialRing(QQ, 'x').gen() - sage: jacobi_P(2,0,0,x) + sage: jacobi_P(2, 0, 0, x) # needs sage.libs.flint sage.symbolic 3/2*x^2 - 1/2 - sage: jacobi_P(2,1,2,1.2) # needs sage.symbolic + sage: jacobi_P(2, 1, 2, 1.2) # needs sage.libs.flint 5.01000000000000 """ def __init__(self): @@ -2205,18 +2208,18 @@ def _eval_(self, n, a, b, x): Check that :issue:`17192` is fixed:: sage: x = PolynomialRing(QQ, 'x').gen() - sage: jacobi_P(0,0,0,x) + sage: jacobi_P(0, 0, 0, x) # needs sage.libs.flint sage.symbolic 1 - sage: jacobi_P(-1,0,0,x) + sage: jacobi_P(-1, 0, 0, x) # needs sage.libs.flint sage.symbolic 1 - sage: jacobi_P(-1,1,1,x) + sage: jacobi_P(-1, 1, 1, x) # needs sage.libs.flint sage.symbolic Traceback (most recent call last): ... ValueError: n must be greater than -1, got n = -1 - sage: jacobi_P(-7,0,0,x) + sage: jacobi_P(-7, 0, 0, x) # needs sage.libs.flint sage.symbolic 231/16*x^6 - 315/16*x^4 + 105/16*x^2 - 5/16 - sage: jacobi_P(-7,0,2,x) + sage: jacobi_P(-7, 0, 2, x) # needs sage.symbolic Traceback (most recent call last): ... ValueError: n must be greater than -1, got n = -7 @@ -2324,11 +2327,11 @@ class Func_ultraspherical(GinacFunction): sage: # needs sage.symbolic sage: gegenbauer(2, -3, x) 12*x^2 + 3 - sage: gegenbauer(120,-99/2,3) + sage: gegenbauer(120, -99/2, 3) 1654502372608570682112687530178328494861923493372493824 sage: gegenbauer(5, 9/2, x) 21879/8*x^5 - 6435/4*x^3 + 1287/8*x - sage: gegenbauer(15,3/2,5) + sage: gegenbauer(15, 3/2, 5) 3903412392243800 sage: derivative(gegenbauer(n, a, x), x) # needs sage.symbolic @@ -2484,7 +2487,7 @@ def _pol_laguerre(self, n, x): 1/24*x^4 - 2/3*x^3 + 3*x^2 - 4*x + 1 sage: laguerre(4, x + 1) # needs mpmath 1/24*(x + 1)^4 - 2/3*(x + 1)^3 + 3*(x + 1)^2 - 4*x - 3 - sage: laguerre(10,1+I) # needs sage.symbolic + sage: laguerre(10, 1 + I) # needs sage.symbolic 142511/113400*I + 95867/22680 """ if hasattr(x, 'pyobject'): @@ -2503,7 +2506,7 @@ def _evalf_(self, n, x, **kwds): sage: laguerre(100, RealField(300)(pi)) # needs sage.symbolic -0.638322077840648311606324... - sage: laguerre(10,1.+I) # needs sage.symbolic + sage: laguerre(10, 1. + I) # needs sage.symbolic 4.22694003527337 + 1.25671075837743*I sage: laguerre(-9, 2.) # needs sage.symbolic 1566.22186244286 @@ -2638,7 +2641,7 @@ def _pol_gen_laguerre(self, n, a, x): 1/24*x^4 - 7/12*x^3 + 35/16*x^2 - 35/16*x + 35/128 sage: gen_laguerre(4, -1/2, x + 1) # needs mpmath 1/24*(x + 1)^4 - 7/12*(x + 1)^3 + 35/16*(x + 1)^2 - 35/16*x - 245/128 - sage: gen_laguerre(10, 1, 1+I) # needs sage.symbolic + sage: gen_laguerre(10, 1, 1 + I) # needs sage.symbolic 25189/2100*I + 11792/2835 """ return sum(binomial(n + a, n - k) * (-1)**k / factorial(k) * x**k diff --git a/src/sage/functions/other.py b/src/sage/functions/other.py index 3da7beec8ce..23450acb02e 100644 --- a/src/sage/functions/other.py +++ b/src/sage/functions/other.py @@ -173,7 +173,7 @@ def _eval_floor_ceil(self, x, method, bits=0, **kwds): These do not work but fail gracefully:: - sage: ceil(Infinity) + sage: ceil(Infinity) # needs sage.rings.real_interval_field Traceback (most recent call last): ... ValueError: Calling ceil() on infinity or NaN @@ -714,9 +714,9 @@ def __init__(self): EXAMPLES:: - sage: frac(5.4) + sage: frac(5.4) # needs sage.rings.real_mpfr 0.400000000000000 - sage: type(frac(5.4)) + sage: type(frac(5.4)) # needs sage.rings.real_mpfr sage: frac(456/123) 29/41 @@ -812,9 +812,9 @@ class Function_real_nth_root(BuiltinFunction): For numeric input, it gives a numerical approximation. :: - sage: real_nth_root(2., 3) + sage: real_nth_root(2., 3) # needs sage.rings.real_mpfr 1.25992104989487 - sage: real_nth_root(-2., 3) + sage: real_nth_root(-2., 3) # needs sage.rings.real_mpfr -1.25992104989487 Some symbolic calculus:: @@ -914,9 +914,9 @@ def _eval_(self, base, exp): sage: real_nth_root(x, 3) # needs sage.symbolic real_nth_root(x, 3) - sage: real_nth_root(RIF(2), 3) + sage: real_nth_root(RIF(2), 3) # needs sage.rings.real_interval_field 1.259921049894873? - sage: real_nth_root(RBF(2), 3) + sage: real_nth_root(RBF(2), 3) # needs sage.libs.flint [1.259921049894873 +/- 3.92e-16] """ if not isinstance(base, Expression) and not isinstance(exp, Expression): @@ -1145,9 +1145,9 @@ def __init__(self): sage: real(5/3) 5/3 sage: a = 2.5 - sage: real(a) + sage: real(a) # needs sage.rings.real_mpfr 2.50000000000000 - sage: type(real(a)) + sage: type(real(a)) # needs sage.rings.real_mpfr sage: real(1.0r) 1.0 diff --git a/src/sage/functions/piecewise.py b/src/sage/functions/piecewise.py index f621c324cc4..fe0f6d71ed3 100644 --- a/src/sage/functions/piecewise.py +++ b/src/sage/functions/piecewise.py @@ -291,7 +291,7 @@ def _tderivative_(self, parameters, variable, *args, **kwds): EXAMPLES:: - sage: f = piecewise([ [(-1,1), x**2], [(1,3), x**3]]) + sage: f = piecewise([[(-1,1), x**2], [(1,3), x**3]]) sage: f.diff() piecewise(x|-->2*x on (-1, 1), x|-->3*x^2 on (1, 3); x) sage: f.diff(x,x) @@ -300,7 +300,7 @@ def _tderivative_(self, parameters, variable, *args, **kwds): This still fails miserably:: sage: y = SR.var('y') - sage: f = piecewise([ [(-6,0), x+y], [(0,8), x*y]],var=x) + sage: f = piecewise([[(-6,0), x+y], [(0,8), x*y]],var=x) sage: f.derivative(x) # known bug piecewise(x|-->1 on (-6, 0), x|-->y on (0, 8); x) sage: f.derivative(y) # known bug @@ -308,7 +308,7 @@ def _tderivative_(self, parameters, variable, *args, **kwds): TESTS:: - sage: f = piecewise([((-oo, -1),0), ((-1, 1),exp(-1/(1 - x^2))), ((1, oo),0)]) + sage: f = piecewise([((-oo, -1), 0), ((-1, 1), exp(-1/(1 - x^2))), ((1, oo), 0)]) sage: f.diff() piecewise(x|-->0 on (-oo, -1), x|-->-2*x*e^(1/(x^2 - 1))/(x^2 - 1)^2 on (-1, 1), x|-->0 on (1, +oo); x) """ @@ -330,7 +330,7 @@ def __pow__(self, parameters, variable, n): EXAMPLES:: sage: f1(x) = -abs(x) + 1; f2(x) = abs(x - 2) - 1 - sage: f = piecewise([ [(-1,1), f1], [(1,3), f2]]) + sage: f = piecewise([[(-1,1), f1], [(1,3), f2]]) sage: (f^2).integral(definite=True) 4/3 """ @@ -635,9 +635,9 @@ def end_points(self, parameters, variable): EXAMPLES:: sage: f1(x) = 1 - sage: f2(x) = 1-x - sage: f3(x) = x^2-5 - sage: f = piecewise([[(0,1),f1],[(1,2),f2],[(2,3),f3]]) + sage: f2(x) = 1 - x + sage: f3(x) = x^2 - 5 + sage: f = piecewise([[(0,1), f1], [(1,2), f2], [(2,3), f3]]) sage: f.end_points() [0, 1, 2, 3] sage: f = piecewise([([0,0], sin(x)), ((0,2), cos(x))]); f @@ -665,7 +665,9 @@ def piecewise_add(self, parameters, variable, other): sage: f = piecewise([([0,1], 1), ((2,3), x)]) sage: g = piecewise([((1/2, 2), x)]) sage: f.piecewise_add(g).unextend_zero() - piecewise(x|-->1 on (0, 1/2], x|-->x + 1 on (1/2, 1], x|-->x on (1, 2) ∪ (2, 3); x) + piecewise(x|-->1 on (0, 1/2], + x|-->x + 1 on (1/2, 1], + x|-->x on (1, 2) ∪ (2, 3); x) """ points = ([minus_infinity] + sorted(set(self.end_points() + other.end_points())) + @@ -731,7 +733,7 @@ def integral(self, parameters, variable, x=None, a=None, b=None, definite=False, r""" By default, return the indefinite integral of the function. - If definite=True is given, returns the definite integral. + If ``definite=True`` is given, returns the definite integral. AUTHOR: @@ -739,8 +741,8 @@ def integral(self, parameters, variable, x=None, a=None, b=None, definite=False, EXAMPLES:: - sage: f1(x) = 1-x - sage: f = piecewise([((0,1),1), ((1,2),f1)]) + sage: f1(x) = 1 - x + sage: f = piecewise([((0,1), 1), ((1,2), f1)]) sage: f.integral(definite=True) 1/2 @@ -748,7 +750,7 @@ def integral(self, parameters, variable, x=None, a=None, b=None, definite=False, sage: f1(x) = -1 sage: f2(x) = 2 - sage: f = piecewise([((0,pi/2),f1), ((pi/2,pi),f2)]) + sage: f = piecewise([((0,pi/2), f1), ((pi/2,pi), f2)]) sage: f.integral(definite=True) 1/2*pi @@ -764,8 +766,8 @@ def integral(self, parameters, variable, x=None, a=None, b=None, definite=False, sage: f3(y) = -y - 1 sage: f4(y) = y^2 - 1 sage: f5(y) = 3 - sage: f = piecewise([[[-4,-3],f1], [(-3,-2),f2], [[-2,0],f3], - ....: [(0,2),f4], [[2,3],f5]]) + sage: f = piecewise([[[-4,-3], f1], [(-3,-2), f2], [[-2,0], f3], + ....: [(0,2), f4], [[2,3], f5]]) sage: F = f.integral(y); F piecewise(y|-->-y - 4 on [-4, -3], y|-->1/2*y^2 + 3*y + 7/2 on (-3, -2), @@ -795,7 +797,8 @@ def integral(self, parameters, variable, x=None, a=None, b=None, definite=False, sage: f1(y) = (y+3)^2 sage: f2(y) = y+3 sage: f3(y) = 3 - sage: f = piecewise([[(-infinity, -3), f1], [(-3, 0), f2], [(0, infinity), f3]]) + sage: f = piecewise([[(-infinity, -3), f1], [(-3, 0), f2], + ....: [(0, infinity), f3]]) sage: f.integral() piecewise(y|-->1/3*y^3 + 3*y^2 + 9*y + 9 on (-oo, -3), y|-->1/2*y^2 + 3*y + 9/2 on (-3, 0), @@ -823,7 +826,7 @@ def integral(self, parameters, variable, x=None, a=None, b=None, definite=False, Verify that piecewise integrals of zero work (:issue:`10841`):: sage: f0(x) = 0 - sage: f = piecewise([[[0,1],f0]]) + sage: f = piecewise([[[0,1], f0]]) sage: f.integral(x,0,1) 0 sage: f = piecewise([[[0,1], 0]]) @@ -836,9 +839,9 @@ def integral(self, parameters, variable, x=None, a=None, b=None, definite=False, Check that the algorithm keyword can be used:: sage: ex = piecewise([([0, 1], 1), ((1, oo), 1/x**2)]) - sage: integral(ex,x,0,100,algorithm='giac') + sage: integral(ex, x, 0, 100, algorithm='giac') 199/100 - sage: integral(ex,x,algorithm='giac') + sage: integral(ex, x, algorithm='giac') piecewise(x|-->x on [0, 1], x|-->-1/x + 2 on (1, +oo); x) """ if a is not None and b is not None: @@ -901,7 +904,7 @@ def critical_points(self, parameters, variable): sage: f1 = x^0 sage: f2 = 10*x - x^2 sage: f3 = 3*x^4 - 156*x^3 + 3036*x^2 - 26208*x - sage: f = piecewise([[(0,3),f1],[(3,10),f2],[(10,20),f3]]) + sage: f = piecewise([[(0,3), f1], [(3,10), f2], [(10,20), f3]]) sage: expected = [5, 12, 13, 14] sage: all(abs(e-a) < 0.001 for e,a in zip(expected, f.critical_points())) True @@ -914,7 +917,7 @@ def critical_points(self, parameters, variable): sage: f1 = y^0 sage: f2 = 10*y - y^2 sage: f3 = 3*y^4 - 156*y^3 + 3036*y^2 - 26208*y - sage: f = piecewise([[(0,3),f1],[(3,10),f2],[(10,20),f3]]) + sage: f = piecewise([[(0,3), f1], [(3,10), f2], [(10,20), f3]]) sage: expected = [5, 12, 13, 14] sage: all(abs(e-a) < 0.001 for e,a in zip(expected, f.critical_points())) True @@ -940,15 +943,22 @@ def convolution(self, parameters, variable, other): EXAMPLES:: - sage: x = PolynomialRing(QQ,'x').gen() - sage: f = piecewise([[[0,1],1]]) ## example 0 + sage: x = PolynomialRing(QQ, 'x').gen() + + Example 0:: + + sage: f = piecewise([[[0,1], 1]]) sage: g = f.convolution(f); g - piecewise(x|-->x on (0, 1], x|-->-x + 2 on (1, 2]; x) + piecewise(x|-->x on (0, 1], + x|-->-x + 2 on (1, 2]; x) sage: h = f.convolution(g); h piecewise(x|-->1/2*x^2 on (0, 1], x|-->-x^2 + 3*x - 3/2 on (1, 2], x|-->1/2*x^2 - 3*x + 9/2 on (2, 3]; x) - sage: f = piecewise([[(0,1),1], [(1,2),2], [(2,3),1]]) ## example 1 + + Example 1:: + + sage: f = piecewise([[(0,1), 1], [(1,2), 2], [(2,3), 1]]) sage: g = f.convolution(f) sage: h = f.convolution(g); h piecewise(x|-->1/2*x^2 on (0, 1], @@ -958,13 +968,16 @@ def convolution(self, parameters, variable, other): x|-->-2*x^2 + 15*x - 15/2 on (5, 6], x|-->2*x^2 - 33*x + 273/2 on (6, 8], x|-->1/2*x^2 - 9*x + 81/2 on (8, 9]; x) - sage: f = piecewise([[(-1,1),1]]) ## example 2 - sage: g = piecewise([[(0,3),x]]) + + Example 2:: + + sage: f = piecewise([[(-1,1), 1]]) + sage: g = piecewise([[(0,3), x]]) sage: f.convolution(g) piecewise(x|-->1/2*x^2 + x + 1/2 on (-1, 1], x|-->2*x on (1, 2], x|-->-1/2*x^2 + x + 4 on (2, 4]; x) - sage: g = piecewise([[(0,3),1], [(3,4),2]]) + sage: g = piecewise([[(0,3), 1], [(3,4), 2]]) sage: f.convolution(g) piecewise(x|-->x + 1 on (-1, 1], x|-->2 on (1, 2], @@ -1037,7 +1050,8 @@ def trapezoid(self, parameters, variable, N): EXAMPLES:: - sage: f = piecewise([[[0,1], x^2], [RealSet.open_closed(1,2), 5-x^2]]) + sage: f = piecewise([[[0,1], x^2], + ....: [RealSet.open_closed(1,2), 5 - x^2]]) sage: f.trapezoid(2) piecewise(x|-->1/2*x on (0, 1/2), x|-->3/2*x - 1/2 on (1/2, 1), @@ -1056,8 +1070,8 @@ def trapezoid(self, parameters, variable, N): sage: R. = QQ[] sage: f1 = y^2 - sage: f2 = 5-y^2 - sage: f = piecewise([[[0,1],f1], [RealSet.open_closed(1,2),f2]]) + sage: f2 = 5 - y^2 + sage: f = piecewise([[[0,1], f1], [RealSet.open_closed(1,2), f2]]) sage: f.trapezoid(2) piecewise(y|-->1/2*y on (0, 1/2), y|-->3/2*y - 1/2 on (1/2, 1), @@ -1082,14 +1096,14 @@ def func(x0, x1): def laplace(self, parameters, variable, x='x', s='t'): r""" - Returns the Laplace transform of self with respect to the variable + Return the Laplace transform of ``self`` with respect to the variable var. INPUT: - - ``x`` - variable of self + - ``x`` -- variable of ``self`` - - ``s`` - variable of Laplace transform. + - ``s`` -- variable of Laplace transform. We assume that a piecewise function is 0 outside of its domain and that the left-most endpoint of the domain is 0. @@ -1097,7 +1111,7 @@ def laplace(self, parameters, variable, x='x', s='t'): EXAMPLES:: sage: x, s, w = var('x, s, w') - sage: f = piecewise([[(0,1),1], [[1,2], 1 - x]]) + sage: f = piecewise([[(0,1), 1], [[1,2], 1 - x]]) sage: f.laplace(x, s) -e^(-s)/s + (s + 1)*e^(-2*s)/s^2 + 1/s - e^(-s)/s^2 sage: f.laplace(x, w) @@ -1116,8 +1130,8 @@ def laplace(self, parameters, variable, x='x', s='t'): sage: t = var('t') sage: f1(t) = -t sage: f2(t) = 2 - sage: f = piecewise([[[0,1],f1], [(1,infinity),f2]]) - sage: f.laplace(t,s) + sage: f = piecewise([[[0,1], f1], [(1,infinity), f2]]) + sage: f.laplace(t, s) (s + 1)*e^(-s)/s^2 + 2*e^(-s)/s - 1/s^2 """ from sage.symbolic.assumptions import assume, forget @@ -1172,7 +1186,7 @@ def fourier_series_cosine_coefficient(self, parameters, A triangle wave function of period 2:: - sage: f = piecewise([((0,1), x), ((1,2), 2-x)]) + sage: f = piecewise([((0,1), x), ((1,2), 2 - x)]) sage: f.fourier_series_cosine_coefficient(0) 1 sage: f.fourier_series_cosine_coefficient(3) @@ -1203,13 +1217,13 @@ def fourier_series_cosine_coefficient(self, parameters, Other examples:: sage: f(x) = x^2 - sage: f = piecewise([[(-1,1),f]]) + sage: f = piecewise([[(-1,1), f]]) sage: f.fourier_series_cosine_coefficient(2) pi^(-2) sage: f1(x) = -1 sage: f2(x) = 2 - sage: f = piecewise([[(-pi,pi/2),f1],[(pi/2,pi),f2]]) - sage: f.fourier_series_cosine_coefficient(5,pi) + sage: f = piecewise([[(-pi, pi/2), f1], [(pi/2, pi), f2]]) + sage: f.fourier_series_cosine_coefficient(5, pi) -3/5/pi """ diff --git a/src/sage/functions/spike_function.py b/src/sage/functions/spike_function.py index 4739ca7ffb4..c2fb6113e39 100644 --- a/src/sage/functions/spike_function.py +++ b/src/sage/functions/spike_function.py @@ -71,7 +71,7 @@ def __init__(self, v, eps=0.0000001): A spike function with spikes at [-3.0, -1.0, 2.0] sage: S.height [4.0, 1.0, 3.0] - sage: S.eps + sage: S.eps # needs sage.rings.real_mpfr 0.00100000000000000 """ if not v: diff --git a/src/sage/functions/transcendental.py b/src/sage/functions/transcendental.py index c0debecdc0d..236646bae52 100644 --- a/src/sage/functions/transcendental.py +++ b/src/sage/functions/transcendental.py @@ -173,7 +173,7 @@ def __init__(self): INPUT: - - ``n`` - non-negative integer + - ``n`` -- non-negative integer EXAMPLES:: @@ -265,11 +265,11 @@ def _evalf_(self, s, x, parent=None, algorithm=None): r""" TESTS:: - sage: hurwitz_zeta(11/10, 1/2).n() # needs sage.symbolic + sage: hurwitz_zeta(11/10, 1/2).n() # needs mpmath sage.symbolic 12.1038134956837 - sage: hurwitz_zeta(11/10, 1/2).n(100) # needs sage.symbolic + sage: hurwitz_zeta(11/10, 1/2).n(100) # needs mpmath sage.symbolic 12.103813495683755105709077413 - sage: hurwitz_zeta(11/10, 1 + 1j).n() + sage: hurwitz_zeta(11/10, 1 + 1j).n() # needs mpmath sage.rings.real_mpfr 9.85014164287853 - 1.06139499403981*I """ return _mpmath_utils_call(_mpmath_zeta, s, x, parent=parent) @@ -571,48 +571,54 @@ def power_series(self, n, abs_prec): """ This function returns the power series about `n+1/2` used to evaluate Dickman's function. It is scaled such that the interval - `[n,n+1]` corresponds to x in `[-1,1]`. + `[n,n+1]` corresponds to `x` in `[-1,1]`. INPUT: - - ``n`` - the lower endpoint of the interval for which + - ``n`` -- the lower endpoint of the interval for which this power series holds - - ``abs_prec`` - the absolute precision of the + - ``abs_prec`` -- the absolute precision of the resulting power series EXAMPLES:: + sage: # needs sage.rings.real_mpfr sage: f = dickman_rho.power_series(2, 20); f - -9.9376e-8*x^11 + 3.7722e-7*x^10 - 1.4684e-6*x^9 + 5.8783e-6*x^8 - 0.000024259*x^7 + 0.00010341*x^6 - 0.00045583*x^5 + 0.0020773*x^4 - 0.0097336*x^3 + 0.045224*x^2 - 0.11891*x + 0.13032 + -9.9376e-8*x^11 + 3.7722e-7*x^10 - 1.4684e-6*x^9 + 5.8783e-6*x^8 + - 0.000024259*x^7 + 0.00010341*x^6 - 0.00045583*x^5 + 0.0020773*x^4 + - 0.0097336*x^3 + 0.045224*x^2 - 0.11891*x + 0.13032 sage: f(-1), f(0), f(1) (0.30685, 0.13032, 0.048608) - sage: dickman_rho(2), dickman_rho(2.5), dickman_rho(3) # needs sage.symbolic + sage: dickman_rho(2), dickman_rho(2.5), dickman_rho(3) (0.306852819440055, 0.130319561832251, 0.0486083882911316) """ return self._compute_power_series(n, abs_prec, cache_ring=None) def _compute_power_series(self, n, abs_prec, cache_ring=None): """ - Compute the power series giving Dickman's function on [n, n+1], by - recursion in n. For internal use; self.power_series() is a wrapper + Compute the power series giving Dickman's function on `[n, n+1]`, by + recursion in `n`. For internal use; ``self.power_series()`` is a wrapper around this intended for the user. INPUT: - - ``n`` - the lower endpoint of the interval for which + - ``n`` -- the lower endpoint of the interval for which this power series holds - - ``abs_prec`` - the absolute precision of the + - ``abs_prec`` -- the absolute precision of the resulting power series - - ``cache_ring`` - for internal use, caches the power + - ``cache_ring`` -- for internal use, caches the power series at this precision. EXAMPLES:: + sage: # needs sage.rings.real_mpfr sage: f = dickman_rho.power_series(2, 20); f - -9.9376e-8*x^11 + 3.7722e-7*x^10 - 1.4684e-6*x^9 + 5.8783e-6*x^8 - 0.000024259*x^7 + 0.00010341*x^6 - 0.00045583*x^5 + 0.0020773*x^4 - 0.0097336*x^3 + 0.045224*x^2 - 0.11891*x + 0.13032 + -9.9376e-8*x^11 + 3.7722e-7*x^10 - 1.4684e-6*x^9 + 5.8783e-6*x^8 + - 0.000024259*x^7 + 0.00010341*x^6 - 0.00045583*x^5 + 0.0020773*x^4 + - 0.0097336*x^3 + 0.045224*x^2 - 0.11891*x + 0.13032 """ if n <= 1: if n <= -1: diff --git a/src/sage/functions/trig.py b/src/sage/functions/trig.py index d4e723ec6e2..b767fbbd5d4 100644 --- a/src/sage/functions/trig.py +++ b/src/sage/functions/trig.py @@ -210,6 +210,7 @@ def __init__(self): EXAMPLES:: + sage: # needs sage.rings.real_mpfr sage: tan(3.1415) -0.0000926535900581913 sage: tan(3.1415/4) @@ -323,20 +324,20 @@ def __init__(self): TESTS:: - sage: cot(float(0)) # needs sage.symbolic + sage: # needs sage.symbolic + sage: cot(float(0)) Infinity - sage: cot(SR(0)) # needs sage.symbolic + sage: cot(SR(0)) Infinity - sage: cot(float(0.1)) # needs sage.symbolic + sage: cot(float(0.1)) 9.966644423259238 sage: type(_) <... 'float'> - - sage: cot(float(0)) # needs sage.symbolic + sage: cot(float(0)) Infinity - sage: cot(SR(0)) # needs sage.symbolic + sage: cot(SR(0)) Infinity - sage: cot(float(0.1)) # needs sage.symbolic + sage: cot(float(0.1)) 9.966644423259238 sage: type(_) <... 'float'> @@ -520,7 +521,7 @@ def __init__(self): EXAMPLES:: - sage: arcsin(0.5) + sage: arcsin(0.5) # needs sage.rings.real_mpfr 0.523598775598299 sage: arcsin(1/2) # needs sage.symbolic 1/6*pi @@ -584,7 +585,7 @@ def __init__(self): EXAMPLES:: - sage: arccos(0.5) + sage: arccos(0.5) # needs sage.rings.real_mpfr 1.04719755119660 sage: arccos(1/2) # needs sage.symbolic 1/3*pi @@ -940,7 +941,7 @@ def __init__(self): sage: maxima.atan2(1, -1) # needs sage.symbolic (3*%pi)/4 - sage: math.atan2(1,-1) + sage: math.atan2(1, -1) 2.356194490192345 More examples:: diff --git a/src/sage/functions/wigner.py b/src/sage/functions/wigner.py index 0bafe13a246..5a19010f073 100644 --- a/src/sage/functions/wigner.py +++ b/src/sage/functions/wigner.py @@ -616,11 +616,11 @@ def gaunt(l_1, l_2, l_3, m_1, m_2, m_3, prec=None): It is an error to use non-integer values for `l` or `m`:: - sage: gaunt(1.2,0,1.2,0,0,0) + sage: gaunt(1.2,0,1.2,0,0,0) # needs sage.rings.real_mpfr Traceback (most recent call last): ... TypeError: Attempt to coerce non-integral RealNumber to Integer - sage: gaunt(1,0,1,1.1,0,-1.1) + sage: gaunt(1,0,1,1.1,0,-1.1) # needs sage.rings.real_mpfr Traceback (most recent call last): ... TypeError: Attempt to coerce non-integral RealNumber to Integer diff --git a/src/sage/numerical/mip.pyx b/src/sage/numerical/mip.pyx index 368b9e4b0e3..c8aecbf6482 100644 --- a/src/sage/numerical/mip.pyx +++ b/src/sage/numerical/mip.pyx @@ -2852,7 +2852,7 @@ cdef class MixedIntegerLinearProgram(SageObject): The command :: - sage: p = MixedIntegerLinearProgram(solver="CPLEX") # optional - CPLEX + sage: p = MixedIntegerLinearProgram(solver="CPLEX") # optional - CPLEX sage: p.solver_parameter("CPX_PARAM_TILIM", 60) # optional - CPLEX works as intended. diff --git a/src/sage/numerical/optimize.py b/src/sage/numerical/optimize.py index 54262183b1b..1d8e9fafd57 100644 --- a/src/sage/numerical/optimize.py +++ b/src/sage/numerical/optimize.py @@ -346,7 +346,7 @@ def minimize(func, x0, gradient=None, hessian=None, algorithm="default", sage: vars = var('x y z') # needs sage.symbolic sage: f = 100*(y-x^2)^2 + (1-x)^2 + 100*(z-y^2)^2 + (1-y)^2 # needs sage.symbolic - sage: minimize(f, [.1,.3,.4]) # abs tol 1e-6 # needs sage.symbolic + sage: minimize(f, [.1,.3,.4]) # abs tol 1e-6 # needs sage.symbolic (1.0, 1.0, 1.0) Try the newton-conjugate gradient method; the gradient and hessian are diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx index e14674678a0..02b23d16cf4 100644 --- a/src/sage/symbolic/expression.pyx +++ b/src/sage/symbolic/expression.pyx @@ -7497,14 +7497,14 @@ cdef class Expression(Expression_abc): INPUT: - - ``base_ring`` - (optional) the base ring for the polynomial + - ``base_ring`` -- (optional) the base ring for the polynomial - - ``ring`` - (optional) the parent for the polynomial + - ``ring`` -- (optional) the parent for the polynomial .. warning:: This is different from :meth:`poly` which is used to rewrite - self as a polynomial in terms of one of the variables. + ``self`` as a polynomial in terms of one of the variables. EXAMPLES:: @@ -9019,7 +9019,7 @@ cdef class Expression(Expression_abc): This also works using functional notation:: - sage: arccos(1,hold=True) + sage: arccos(1, hold=True) arccos(1) sage: arccos(1) 0 @@ -9070,7 +9070,7 @@ cdef class Expression(Expression_abc): This also works using functional notation:: - sage: arctan(1,hold=True) + sage: arctan(1, hold=True) arctan(1) sage: arctan(1) 1/4*pi @@ -9342,7 +9342,7 @@ cdef class Expression(Expression_abc): This also works using functional notation:: - sage: tanh(arcsinh(x),hold=True) + sage: tanh(arcsinh(x), hold=True) tanh(arcsinh(x)) sage: tanh(arcsinh(x)) x/sqrt(x^2 + 1) @@ -9623,7 +9623,7 @@ cdef class Expression(Expression_abc): The ``hold`` parameter also works in functional notation:: - sage: log(-1,hold=True) + sage: log(-1, hold=True) log(-1) sage: log(-1) I*pi @@ -9668,7 +9668,7 @@ cdef class Expression(Expression_abc): This also works using functional notation:: - sage: zeta(2,hold=True) + sage: zeta(2, hold=True) zeta(2) sage: zeta(2) 1/6*pi^2 @@ -9845,7 +9845,7 @@ cdef class Expression(Expression_abc): This also works using functional notation:: - sage: gamma(1/2,hold=True) + sage: gamma(1/2, hold=True) gamma(1/2) sage: gamma(1/2) sqrt(pi) @@ -9876,8 +9876,8 @@ cdef class Expression(Expression_abc): def log_gamma(self, hold=False): """ - Return the log gamma function evaluated at self. - This is the logarithm of gamma of self, where + Return the log gamma function evaluated at ``self``. + This is the logarithm of gamma of ``self``, where gamma is a complex function such that `gamma(n)` equals `factorial(n-1)`. @@ -12142,12 +12142,12 @@ cdef class Expression(Expression_abc): .. warning:: - This is *not* a numerical solver - use ``find_root`` to - solve for self == 0 numerically on an interval. + This is *not* a numerical solver - use :meth:`find_root` to + solve for ``self == 0`` numerically on an interval. INPUT: - - ``x`` - variable to view the function in terms of + - ``x`` -- variable to view the function in terms of (use default variable if not given) - ``explicit_solutions`` -- bool (default ``True``); require that @@ -12157,7 +12157,7 @@ cdef class Expression(Expression_abc): multiplicities - ``ring`` -- a ring (default ``None``): if not ``None``, convert - ``self`` to a polynomial over ring and find roots over ring + ``self`` to a polynomial over ``ring`` and find roots over ``ring`` OUTPUT: @@ -12210,9 +12210,9 @@ cdef class Expression(Expression_abc): .. NOTE:: It is possible to solve a greater variety of equations - using ``solve()`` and the keyword ``to_poly_solve``, + using :func:`solve` and the keyword ``to_poly_solve``, but only at the price of possibly encountering - approximate solutions. See documentation for f.solve + approximate solutions. See documentation for :meth:`solve` for more details. We derive the roots of a general quadratic polynomial:: @@ -12388,7 +12388,7 @@ cdef class Expression(Expression_abc): Solve a polynomial equation in the integers (a so called Diophantine). If the argument is just a polynomial expression, equate to zero. - If ``solution_dict=True`` return a list of dictionaries instead of + If ``solution_dict=True``, return a list of dictionaries instead of a list of tuples. EXAMPLES:: @@ -12505,26 +12505,26 @@ cdef class Expression(Expression_abc): def find_root(self, a, b, var=None, xtol=10e-13, rtol=2.0**-50, maxiter=100, full_output=False, imaginary_tolerance=1e-8): """ - Numerically find a root of self on the closed interval [a,b] (or - [b,a]) if possible, where self is a function in the one variable. + Numerically find a root of ``self`` on the closed interval [a,b] (or + [b,a]) if possible, where ``self`` is a function in one variable. Note: this function only works in fixed (machine) precision, it is not possible to get arbitrary precision approximations with it. INPUT: - - ``a, b`` - endpoints of the interval + - ``a``, ``b`` -- endpoints of the interval - - ``var`` - optional variable + - ``var`` -- optional variable - - ``xtol, rtol`` - the routine converges when a root - is known to lie within xtol of the value return. Should be >= 0. The + - ``xtol, rtol`` -- the routine converges when a root + is known to lie within ``xtol`` of the value return. Should be >= 0. The routine modifies this to take into account the relative precision of doubles. - - ``maxiter`` - integer; if convergence is not + - ``maxiter`` -- integer; if convergence is not achieved in maxiter iterations, an error is raised. Must be >= 0. - - ``full_output`` - bool (default: False), if True, + - ``full_output`` -- bool (default: ``False``), if ``True``, also return object that contains information about convergence. - ``imaginary_tolerance`` -- (default: ``1e-8``); if an imaginary @@ -12698,19 +12698,19 @@ cdef class Expression(Expression_abc): INPUT: - - ``a`` - real number; left endpoint of interval on which to + - ``a`` -- real number; left endpoint of interval on which to minimize - - ``b`` - real number; right endpoint of interval on which to + - ``b`` -- real number; right endpoint of interval on which to minimize - - ``var`` - variable (default: first variable in self); the + - ``var`` -- variable (default: first variable in self); the variable in self to maximize over - - ``tol`` - positive real (default: 1.48e-08); the convergence + - ``tol`` -- positive real (default: 1.48e-08); the convergence tolerance - - ``maxfun`` - natural number (default: 500); maximum function + - ``maxfun`` -- natural number (default: 500); maximum function evaluations - ``imaginary_tolerance`` -- (default: ``1e-8``); if an imaginary @@ -12842,7 +12842,7 @@ cdef class Expression(Expression_abc): def plot(self, *args, **kwds): """ - Plot a symbolic expression. All arguments are passed onto the standard plot command. + Plot a symbolic expression. All arguments are passed onto the standard :func:`plot` command. EXAMPLES: @@ -12890,7 +12890,8 @@ cdef class Expression(Expression_abc): sage: plot(2*sin, -4, 4) # needs sage.plot Traceback (most recent call last): ... - TypeError: unsupported operand parent(s) for *: 'Integer Ring' and '' + TypeError: unsupported operand parent(s) for *: + 'Integer Ring' and '' You should evaluate the function first:: @@ -12990,7 +12991,7 @@ cdef class Expression(Expression_abc): - ``b`` -- upper endpoint of the sum - - ``algorithm`` - (default: ``'maxima'``) one of + - ``algorithm`` -- (default: ``'maxima'``) one of - ``'maxima'`` -- use Maxima (the default) - ``'maple'`` -- (optional) use Maple diff --git a/src/sage/symbolic/function.pyx b/src/sage/symbolic/function.pyx index f33b8eb47e6..574fa649597 100644 --- a/src/sage/symbolic/function.pyx +++ b/src/sage/symbolic/function.pyx @@ -290,7 +290,7 @@ cdef class Function(SageObject): sage: coth(5) # indirect doctest # needs sage.symbolic coth(5) - sage: coth(0.5) + sage: coth(0.5) # needs sage.rings.real_mpfr 2.16395341373865 sage: from sage.symbolic.function import BuiltinFunction sage: class Test(BuiltinFunction): @@ -307,13 +307,13 @@ cdef class Function(SageObject): ....: else: ....: return sage: test = Test() - sage: test(1.3, 4) + sage: test(1.3, 4) # needs sage.rings.real_mpfr 2.30000000000000 sage: test(pi, 4) # needs sage.symbolic test(pi, 4) sage: test(2, x) # needs sage.symbolic 3 - sage: test(2., 4) + sage: test(2., 4) # needs sage.rings.real_mpfr 3.00000000000000 sage: test(1 + 1.0*I, 2) # needs sage.symbolic 2.00000000000000 + 1.00000000000000*I @@ -329,7 +329,7 @@ cdef class Function(SageObject): ....: else: ....: return 3 sage: test2 = Test2() - sage: test2(1.3) + sage: test2(1.3) # needs sage.rings.real_mpfr 0.500000000000000 sage: test2(pi) # needs sage.symbolic 3 @@ -456,7 +456,7 @@ cdef class Function(SageObject): Precision of the result depends on the precision of the input:: - sage: arctan(RR(1)) + sage: arctan(RR(1)) # needs sage.rings.real_mpfr 0.785398163397448 sage: arctan(RealField(100)(1)) # needs sage.rings.real_mpfr 0.78539816339744830961566084582 @@ -646,7 +646,7 @@ cdef class Function(SageObject): sage: airy_ai(iv) # needs sage.rings.real_interval_field airy_ai(1.0001?) - sage: airy_ai(CIF(iv)) # needs sage.rings.complex_interval_field + sage: airy_ai(CIF(iv)) # needs sage.rings.complex_interval_field sage.rings.real_interval_field airy_ai(1.0001?) """ if isinstance(x, (float, complex)): diff --git a/src/sage/symbolic/integration/integral.py b/src/sage/symbolic/integration/integral.py index 61e1513d87f..554af7063ce 100644 --- a/src/sage/symbolic/integration/integral.py +++ b/src/sage/symbolic/integration/integral.py @@ -452,28 +452,28 @@ def integrate(expression, v=None, a=None, b=None, algorithm=None, hold=False): INPUT: - - ``v`` - a variable or variable name. This can also be a tuple of + - ``v`` -- a variable or variable name. This can also be a tuple of the variable (optional) and endpoints (i.e., ``(x,0,1)`` or ``(0,1)``). - - ``a`` - (optional) lower endpoint of definite integral + - ``a`` -- (optional) lower endpoint of definite integral - - ``b`` - (optional) upper endpoint of definite integral + - ``b`` -- (optional) upper endpoint of definite integral - - ``algorithm`` - (default: 'maxima', 'libgiac' and 'sympy') one of + - ``algorithm`` -- (default: ``'maxima'``, ``'libgiac'`` and ``'sympy'``) one of - - 'maxima' - use maxima + - ``'maxima'`` -- use maxima - - 'sympy' - use sympy (also in Sage) + - ``'sympy'`` -- use sympy (also in Sage) - - 'mathematica_free' - use http://integrals.wolfram.com/ + - ``'mathematica_free'`` -- use http://integrals.wolfram.com/ - - 'fricas' - use FriCAS (the optional fricas spkg has to be installed) + - ``'fricas'`` -- use FriCAS (the optional fricas spkg has to be installed) - - 'giac' - use Giac + - ``'giac'`` - use Giac - - 'libgiac' - use libgiac + - ``'libgiac'`` - use libgiac - To prevent automatic evaluation use the ``hold`` argument. + To prevent automatic evaluation, use the ``hold`` argument. .. SEEALSO:: @@ -596,7 +596,7 @@ def integrate(expression, v=None, a=None, b=None, algorithm=None, hold=False): sage: _ = var('x, y, z') sage: f = sin(x^2) + y^z - sage: g = mathematica(f) # optional - mathematica + sage: g = mathematica(f) # optional - mathematica sage: print(g) # optional - mathematica z 2 y + Sin[x ] @@ -605,7 +605,10 @@ def integrate(expression, v=None, a=None, b=None, algorithm=None, hold=False): x y + Sqrt[--] FresnelS[Sqrt[--] x] 2 Pi sage: print(f.integral(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)) + 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!):: @@ -659,12 +662,15 @@ def integrate(expression, v=None, a=None, b=None, algorithm=None, hold=False): sage: f(x) = sqrt(x+sqrt(1+x^2))/x sage: integrate(f(x), x, algorithm="fricas") # optional - fricas - 2*sqrt(x + sqrt(x^2 + 1)) - 2*arctan(sqrt(x + sqrt(x^2 + 1))) - log(sqrt(x + sqrt(x^2 + 1)) + 1) + log(sqrt(x + sqrt(x^2 + 1)) - 1) + 2*sqrt(x + sqrt(x^2 + 1)) - 2*arctan(sqrt(x + sqrt(x^2 + 1))) + - log(sqrt(x + sqrt(x^2 + 1)) + 1) + log(sqrt(x + sqrt(x^2 + 1)) - 1) where the default integrator obtains another answer:: sage: integrate(f(x), x) # long time - 1/8*sqrt(x)*gamma(1/4)*gamma(-1/4)^2*hypergeometric((-1/4, -1/4, 1/4), (1/2, 3/4), -1/x^2)/(pi*gamma(3/4)) + 1/8*sqrt(x)*gamma(1/4)*gamma(-1/4)^2*hypergeometric((-1/4, -1/4, 1/4), + (1/2, 3/4), + -1/x^2)/(pi*gamma(3/4)) The following definite integral is not found by maxima:: @@ -713,7 +719,10 @@ def integrate(expression, v=None, a=None, b=None, algorithm=None, hold=False): sage: assume(a>0) sage: integrate(1/(x^3 *(a+b*x)^(1/3)), x) - 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) + 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) TESTS: