Given a polynomial y=5x^5+x^4+2x^3-7x^2+x+2, and the start and end points 1, 5, the user inputs are:
x5=5, x4=1, x3=2, x2=-7, x=1, c=2, s=1, e=5, and cL is the convergence limit saying that it must be accurate to .01.
Expand|Select|Wrap|Line Numbers
- Function EC(x5, x4, x3, x2, x, c, s, e, cL)
- r = 10
- Do
- w = (e - s) / r
- h = s + 0.5 * w
- For n = 1 To r
- y = x5 * h ^ 5 + x4 * h ^ 4 + x3 * h ^ 3 + x2 * h ^ 2 + x * h + c
- area = y * w
- sum0 = sum0 + area
- h = h + w
- Next n
- r = r * 2
- w = (e - s) / r
- h = s + 0.5 * w
- For p = 1 To r
- y = x5 * h ^ 5 + x4 * h ^ 4 + x3 * h ^ 3 + x2 * h ^ 2 + x * h + c
- area = y * w
- Sum = Sum + area
- h = h + w
- Next p
- r = r * 10
- Loop Until Sum - sum0 <= cL
- EC = Sum
- End Function
Thanks