Source code for naginterfaces.library.examples.quad.dim1_fin_smooth_ex
#!/usr/bin/env python3
"``naginterfaces.library.quad.dim1_fin_smooth`` Python Example."
# NAG Copyright 2017-2019.
# pylint: disable=invalid-name
from math import pi, sin
from naginterfaces.library import quad
[docs]def main():
"""
Example for :func:`naginterfaces.library.quad.dim1_fin_smooth`.
One-dimensional quadrature, non-adaptive, finite interval.
>>> main()
naginterfaces.library.quad.dim1_fin_smooth Python Example Results.
One-dimensional quadrature, non-adaptive, finite interval.
Approximation for the integral = -0.03183099
"""
print('naginterfaces.library.quad.dim1_fin_smooth Python Example Results.')
print('One-dimensional quadrature, non-adaptive, finite interval.')
quad_res = quad.dim1_fin_smooth(
f=lambda x: (x**2*sin(10.*pi*x)), a=0., b=1.,
epsabs=0., epsrel=0.0001,
)
print('Approximation for the integral = {:1.8f}'.format(quad_res.result))
if __name__ == '__main__':
import doctest
import sys
sys.exit(
doctest.testmod(
None, verbose=True, report=False,
optionflags=doctest.REPORT_NDIFF,
).failed
)