Files
pi-integral/main.ua

12 lines
591 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
f ← ˜÷1+1ⁿ2
ι ← +⟜(\+↯⤙(˜÷⌵-)) # linspace
i! ← ÷⊃⧻/+ ^0 ι # integrate numerically (mean function value)
t! ← ⊙(&p×1e3⌵-)⊙now^0⊙now # time 1-ary function
0 1 4 # interval [a, b] with n partitions (threads)
⊂⟜(\+↯⤙(˜÷⌵-)) # partition into n subintervals
⊃(t!(⧈₂/(i!f⊙⊙1e8)) # sequential: integrate each area
| t!(wait⧈₂/pool(i!f⊙⊙1e8)) # threading with n threads: this is faster
)
×4÷⊃⧻/+ ◌ # discard one of the benchmarked calculations, collect result