Numerical integration: Difference between revisions

m
→‎{{header|PureBasic}}: improved code readability
(→‎{{header|PicoLisp}}: Added PureBasic)
m (→‎{{header|PureBasic}}: improved code readability)
Line 1,340:
<lang PureBasic>Procedure.d leftRect(a.d, b.d, n.d)
Protected.d h, sum, x
h = (b - a) / n
x = a
Line 1,346 ⟶ 1,347:
x + h
Wend
ProcedureReturn sum
EndProcedure
Line 1,351 ⟶ 1,353:
Procedure.d rightRect(a.d, b.d, n.d)
Protected.d h, sum, x
h = (b - a) / n
x = a + h
Line 1,357 ⟶ 1,360:
x + h
Wend
ProcedureReturn sum
EndProcedure
Line 1,362 ⟶ 1,366:
Procedure.d midRect(a.d, b.d, n.d)
Protected.d h, sum, x
h = (b - a) / n
x = a
Line 1,368 ⟶ 1,373:
x + h
Wend
ProcedureReturn sum
EndProcedure
Line 1,374 ⟶ 1,380:
Protected.d h, sum
Protected i
h = (b - a) / n
sum = f(a) + f(b)
Line 1,379 ⟶ 1,386:
sum + 2 * f((a + i * h))
Next
ProcedureReturn h / 2 * sum
EndProcedure
Line 1,385 ⟶ 1,393:
Protected.d h, sum1, sum2
Protected i
h = (b - a) / n
 
Anonymous user