Как использовать параметр epsabs в scipy.integrate.quad в Python?Python

Программы на Python
Anonymous
Как использовать параметр epsabs в scipy.integrate.quad в Python?

Сообщение Anonymous »


Я пытаюсь вычислить интегралы более точно, указав параметр for

Код: Выделить всё

scipy.integrate.quad
, say we are integrating the function sin(x) / x^2 from 1e-16 to 1.0

Код: Выделить всё

from scipy.integrate import quad
import numpy

integrand = lambda x: numpy.sin(x) / x ** 2
integral = quad(integrand, 1e-16, 1.0)
This gives us

Код: Выделить всё

(36.760078801255595, 0.01091187908038005)
To make the results more precise, we specify the absolute error tolerance by

Код: Выделить всё

from scipy.integrate import quad
import numpy

integrand = lambda x: numpy.sin(x) / x ** 2
integral = quad(integrand, 1e-16, 1.0, epsabs = 1e-4)
The result is exactly the same and the error is still as large as 0.0109! Am I understanding the parameter wrong? What should I do differently to increase the precision of integral?


Источник: https://stackoverflow.com/questions/538 ... -in-python

Вернуться в «Python»