object-oriented programming from math import pisincos import numpy as np [ /( **ifor in range( )ref cos(pi/ print(fh forward central central 'for h_ in hf forward (sin,h_) central (sin,h_) central (sin,h_e abs( (pi/ )-refe abs( (pi/ )-refe abs( (pi/ )-refprint( '{h_: { : { :> { :> }' forward central central notice that we create new instances and for each iteration of the loopsince we want new value of in the formula more elegant solution could be to add new method named set_stepsize(hor similarthat would allow us to adjust for an existing instance such method could easily be added to the superclass and inherited by all subclasses an examination of the output numbers confirm that the three methods behave as expected for each rowwe reduce by factor of twoand the errors are reduced by factor of about twofourand respectively this result is consistent with the theoretical accuracy of the formulaswhich states that the errors should be proportional to hh and respectively exampleclasses for numerical integration just as numerical differentiationnumerical integration is mainstay of computational mathematics there are numerous methods to choose fromand they can all be written on the form ( )dx - wi (xi = and the based on this general formuladifferent methods are realized by choosing the integration points xi and associated weights wi for instancethe trapezoidal rule has xi ihw wn- wi (  )