update meta data
This commit is contained in:
parent
f3a896c724
commit
90e15ed6ce
3307 changed files with 1674 additions and 7 deletions
24
Task/Numerical-integration/00DESCRIPTION
Normal file
24
Task/Numerical-integration/00DESCRIPTION
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
Write functions to calculate the definite integral of a function (<span style="font-family: serif">''f(x)''</span>) 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 (<span style="font-family: serif">''a''</span> and <span style="font-family: serif">''b''</span>) and the number of approximations to make in that range (<span style="font-family: serif">''n''</span>). Assume that your example already has a function that gives values for <span style="font-family: serif">''f(x)''</span>.
|
||||
|
||||
Simpson's method is defined by the following pseudocode:
|
||||
<pre>
|
||||
h := (b - a) / n
|
||||
sum1 := f(a + h/2)
|
||||
sum2 := 0
|
||||
|
||||
loop on i from 1 to (n - 1)
|
||||
sum1 := sum1 + f(a + h * i + h/2)
|
||||
sum2 := sum2 + f(a + h * i)
|
||||
|
||||
answer := (h / 6) * (f(a) + f(b) + 4*sum1 + 2*sum2)
|
||||
</pre>
|
||||
|
||||
Demonstrate your function by showing the results for:
|
||||
* f(x) = x^3, where x is [0,1], with 100 approximations. The exact result is 1/4, or 0.25.
|
||||
* f(x) = 1/x, where x is [1,100], with 1,000 approximations. The exact result is the natural log of 100, or about 4.605170
|
||||
* f(x) = x, where x is [0,5000], with 5,000,000 approximations. The exact result is 12,500,000.
|
||||
* f(x) = x, where x is [0,6000], with 6,000,000 approximations. The exact result is 18,000,000.
|
||||
|
||||
'''See also'''
|
||||
* [[Active object]] for integrating a function of real time.
|
||||
* [[Numerical integration/Gauss-Legendre Quadrature]] for another integration method.
|
||||
Loading…
Add table
Add a link
Reference in a new issue