# Ticket #7763: trac_7763.8.patch

File trac_7763.8.patch, 19.2 KB (added by gagansekhon, 10 years ago)
• ## sage/calculus/all.py

```# HG changeset patch
# User Gagan Sekhon <gagan.d.sekhon@gmail.com>
# Date 1294883391 28800
# Node ID ba8c6b036de215b12ba8c4d5a3c8959246caf25c
# Parent  4a9f7b41ae22e247c2a6675c7854e419f7340d09
trac 7763, unify numerical integration as a top level function

diff -r 4a9f7b41ae22 -r ba8c6b036de2 sage/calculus/all.py```
 a from calculus import maxima as maxima_calculus from calculus import (laplace, inverse_laplace, limit, lim) limit, lim, numerical_integral) nintegral=numerical_integral nintegrate=numerical_integral from functional import (diff, derivative, expand,
• ## sage/calculus/calculus.py

`diff -r 4a9f7b41ae22 -r ba8c6b036de2 sage/calculus/calculus.py`
• ## sage/functions/transcendental.py

`diff -r 4a9f7b41ae22 -r ba8c6b036de2 sage/functions/transcendental.py`
 a import sage.rings.complex_field as complex_field import sage.rings.real_double as real_double import sage.rings.complex_number from sage.gsl.integration import numerical_integral from sage.gsl.integration import gsl_numerical_integral from sage.structure.parent import Parent from sage.structure.coerce import parent from sage.symbolic.expression import Expression sage: t.prec() 100 sage: Ei(1.1, prec=300) sage: Ei(1.1, prec=30) doctest:...: DeprecationWarning: The prec keyword argument is deprecated. Explicitly set the precision of the input, for example Ei(RealField(300)(1)), or use the prec argument to .n() for exact inputs, e.g., Ei(1).n(300), instead. 2.16737827956340306615064476647912607220394065907142504328679588538509331805598360907980986 2.1673783 """ if prec is not None: from sage.misc.misc import deprecation if x < 2: raise ValueError, "Li only defined for x at least 2." if eps_rel: ans = numerical_integral(_one_over_log, 2, float(x), ans = gsl_numerical_integral(_one_over_log, 2, float(x), eps_rel=eps_rel) else: ans = numerical_integral(_one_over_log, 2, float(x)) ans = gsl_numerical_integral(_one_over_log, 2, float(x)) if err_bound: return real_double.RDF(ans[0]), ans[1] else:
• ## sage/gsl/all.py

`diff -r 4a9f7b41ae22 -r ba8c6b036de2 sage/gsl/all.py`
 a from ode import ode_solver from ode import ode_system from probability_distribution import RealDistribution from integration import numerical_integral integral_numerical = numerical_integral #from integration import gsl_numerical_integral #integral_numerical = numerical_integral from probability_distribution import SphericalDistribution from probability_distribution import GeneralDiscreteDistribution
• ## sage/gsl/integration.pyx

`diff -r 4a9f7b41ae22 -r ba8c6b036de2 sage/gsl/integration.pyx`
 a return (params)._call_c(&t) def numerical_integral(func, a, b=None, def gsl_numerical_integral(func, a, b=None, algorithm='qag', max_points=87, params=[], eps_abs=1e-6, eps_rel=1e-6, rule=6): For a Python function with parameters: sage: f(x,a) = 1/(a+x^2) sage: [numerical_integral(f, 1, 2, max_points=100, params=[n]) for n in range(10)]   # slightly random output (architecture and os dependent) sage: [gsl_numerical_integral(f, 1, 2, max_points=100, params=[n]) for n in range(10)]   # slightly random output (architecture and os dependent) [(0.49999999999998657, 5.5511151231256336e-15), (0.32175055439664557, 3.5721487367706477e-15), (0.24030098317249229, 2.6678768435816325e-15),
• ## sage/symbolic/expression.pyx

`diff -r 4a9f7b41ae22 -r ba8c6b036de2 sage/symbolic/expression.pyx`
 a sage: sin(x).nintegral(x,0,3) (1.989992496600..., 2.209335488557...e-14, 21, 0) """ from sage.calculus.calculus import nintegral from sage.calculus.calculus import _nintegral_sym as nintegral return nintegral(self, *args, **kwds) nintegrate = nintegral
• ## sage/symbolic/integration/integral.py

`diff -r 4a9f7b41ae22 -r ba8c6b036de2 sage/symbolic/integration/integral.py`
 a sage: integrate(x^2.7 * e^(-2.4*x), x, 0, 3).n() 0.154572952320790 """ from sage.gsl.integration import numerical_integral from sage.calculus.calculus import numerical_integral # The gsl routine returns a tuple, which also contains the error. # We only return the result. return numerical_integral(f, a, b)[0]