Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Numerical-integration/E/numerical-integration-1.e
Normal file
26
Task/Numerical-integration/E/numerical-integration-1.e
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
pragma.enable("accumulator")
|
||||
|
||||
def leftRect(f, x, h) {
|
||||
return f(x)
|
||||
}
|
||||
|
||||
def midRect(f, x, h) {
|
||||
return f(x + h/2)
|
||||
}
|
||||
|
||||
def rightRect(f, x, h) {
|
||||
return f(x + h)
|
||||
}
|
||||
|
||||
def trapezium(f, x, h) {
|
||||
return (f(x) + f(x+h)) / 2
|
||||
}
|
||||
|
||||
def simpson(f, x, h) {
|
||||
return (f(x) + 4 * f(x + h / 2) + f(x+h)) / 6
|
||||
}
|
||||
|
||||
def integrate(f, a, b, steps, meth) {
|
||||
def h := (b-a) / steps
|
||||
return h * accum 0 for i in 0..!steps { _ + meth(f, a+i*h, h) }
|
||||
}
|
||||
5
Task/Numerical-integration/E/numerical-integration-2.e
Normal file
5
Task/Numerical-integration/E/numerical-integration-2.e
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
? integrate(fn x { x ** 2 }, 3.0, 7.0, 30, simpson)
|
||||
# value: 105.33333333333334
|
||||
|
||||
? integrate(fn x { x ** 9 }, 0, 1, 300, simpson)
|
||||
# value: 0.10000000002160479
|
||||
Loading…
Add table
Add a link
Reference in a new issue