bundles / scipy latest / scipy / integrate / _rules / _base / FixedRule
class
scipy.integrate._rules._base:FixedRule
Signature
class FixedRule ( ) Members
Summary
A rule implemented as the weighted sum of function evaluations at fixed nodes.
Attributes
nodes_and_weights: (ndarray, ndarray)A tuple
(nodes, weights)of nodes at which to evaluatefand the corresponding weights.nodesshould be of shape(num_nodes,)for 1D cubature rules (quadratures) and more generally for N-D cubature rules, it should be of shape(num_nodes, ndim).weightsshould be of shape(num_nodes,). The nodes and weights should be for integrals over .
Examples
Implementing Simpson's 1/3 rule:import numpy as np from scipy.integrate._rules import FixedRule class SimpsonsQuad(FixedRule): @property def nodes_and_weights(self): nodes = np.array([-1, 0, 1]) weights = np.array([1/3, 4/3, 1/3]) return (nodes, weights) rule = SimpsonsQuad()✓
rule.estimate( f=lambda x: x**2, a=np.array([0]), b=np.array([1]), )✗
See also
Aliases
-
scipy.integrate._rules.FixedRule