With the help of scipy.integrate.fixed_quad() method, we can get the computation of a definite integral using fixed order gaussian quadrature by using scipy.integrate.fixed_quad() method.
Syntax :
scipy.integrate.fixed_quad(func, a, b, n)
Return : Return the computed value of a definite integral.
Example #1 :
In this example we can see that by using scipy.integrate.fixed_quad() method, we are able to get the definite integral using fixed order gaussian quadrature by using this method.
# import scipy.integratefrom scipy import integratefunc = lambda x: x**3 # using scipy.integrate.fixed_quad() methodgfg = integrate.fixed_quad(func, 0.0, 1.0, n = 2) # n is the order of integration print(gfg) |
Output :
0.24999999999999997
Example #2 :
# import scipy.integratefrom scipy import integratefunc = lambda x: x**2 + 4 * x + 4 # using scipy.integrate.fixed_quad() methodgfg = integrate.fixed_quad(func, 1.0, 2.0, n = 2) # n is the order of integration print(gfg) |
Output :
12.333333333333332
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course


