alternative flat special-purpose implementation let us illustrate the implementation implied by alternative in the programmer' dilemma box in sect that iswe make special-purpose code where we adapt the general formula ( to the specific problem dt basicallywe use for loop to compute the sum each term with xin the formula ( is replaced by by tand by first try at writing plainflat program doing the special calculation is from math import exp input(' 'dt float( )/ integral by the trapezoidal method numerical * *( ** )*exp( ** * *( ** )*exp( ** for in range( )numerical + *(( *dt)** )*exp(( *dt)** numerical *dt exact_value exp( ** exp( ** error abs(exact_value numericalrel_error (error/exact_value)* print ' =% ferror% (nnumericalerrorthe problem with the above code is at least three-fold we need to reformulate ( for our special problem with different notation the integrand is inserted many times in the codewhich quickly leads to errors lot of edits are necessary to use the code to compute different integral these edits are likely to introduce errors the potential errors involved in point serve to illustrate how important it is to use python functions as mathematical functions here we have chosen to use the lambda function to define the integrand as the variable vfrom math import exp lambda *( ** )*exp( ** input(' 'dt float( )/ function to be integrated replacing by is not strictly required as many use as interval also along the time axis neverthelesst is an even more popular notation for small time intervalso we adopt that common notation