Numerical integration: Difference between revisions
Content added Content deleted
(C) |
m (Added wp links) |
||
Line 1: | Line 1: | ||
{{task|Arithmetic operations}} |
{{task|Arithmetic operations}} |
||
Write functions to calculate the definite integral of a function (<tt>f(x)</tt>) using rectangular (left, right, and midpoint), trapezium, and Simpson's methods. Your functions should take in the upper and lower bounds (<tt>a</tt> and <tt>b</tt>) and the number of approximations to make in that range (<tt>n</tt>). Assume that your example already has a function that gives values for <tt>f(x)</tt>. |
Write functions to calculate the definite integral of a function (<tt>f(x)</tt>) using [[wp:Rectangle_method|rectangular]] (left, right, and midpoint), [[wp:Trapezoidal_rule|trapezium]], and [[wp:Simpson%27s_rule|Simpson's]] methods. Your functions should take in the upper and lower bounds (<tt>a</tt> and <tt>b</tt>) and the number of approximations to make in that range (<tt>n</tt>). Assume that your example already has a function that gives values for <tt>f(x)</tt>. |
||
Simpson's method is defined by the following pseudocode: |
Simpson's method is defined by the following pseudocode: |