Numerical integration: Difference between revisions

Content added Content deleted
(Added Elixir)
m (→‎{{header|BASIC}}: corrected the error)
Line 398:
 
=={{header|BASIC}}==
{{incorrect|BASIC|midRect is not sampling midpoints but recreating trap differently}}
{{works with|QuickBasic|4.5}}
{{trans|Java}}
 
<lang qbasic>FUNCTION leftRect(a, b, n)
h = (b - a) / n
Line 423 ⟶ 421:
h = (b - a) / n
sum = 0
FOR x = a + h / 2 TO b - h / 2 STEP h
sum = sum + (h / 2) * (f(x) + f(x + h))
NEXT x
midRect = sum
Line 444 ⟶ 442:
 
FOR i = 0 TO n-1
sum1 = sumsum1 + f(a + h * i + h / 2)
NEXT i