I am trying to calculate numerical integration for each different StepSize.So I used this operator StepSize_list.append(StepSize)
f = lambda x: 3 * x ** 2 + 2 * x
variable_list = []
initial_value = 1.0
final_value = 3.0
Actual_value = 34
StepSize_list = []
for StepSize in range(50, 250, 50):
StepSize_list.append(StepSize)
def Integral(L1, L2, STEP):
delta_value = (L2 - L1) / STEP
count = 0; Int = 0
variable_list = []
for k in range(STEP):
count = count + delta_value
variable_list.append(count)
for k in range(len(variable_list) - 1):
Int = Int + delta_value * ((f(L1 + variable_list[k]) + f(L1 + variable_list[k + 1])) /2)
return Int
Calc_value = Integral(initial_value, final_value,StepSize)
Error = (abs(Actual_value - Calc_value) / Actual_value) * 100
print('Int Result is {} with {} percent Error'.format(Calc_value, Error))
and then I encountered this error:
TypeError: unsupported operand type(s) for /: 'float' and 'list'