How do you make an integral (∫) block in Snap!

So I am trying to make a factorial block using the gamma function which uses an integral, and that is where I am right now.

I tried mapping a really large list of numbers from A to B to the given function of #1, but it’s not very efficient nor is it accurate enough.

Images:

1: try compiling your map blocks. (right click->compile) this makes them faster
2: read this: I got the wrong answer to a computation involving decimals!
3: use

for factorial, VERY fast, and if the block keeps reporting Infinity for large numbers, use this block before you use the factorial block:

drag these blocks into snap to use them. (although if snap says you need to download the blocks because of a cross origin proxy, you may have to download them and then drag the file in)
4: you don't need to use input names in your block as the function, just leave the slot you would use the input names in empty, and make sure to click on the left arrowhead to get rid of the input names in the ring.

Hope this helps!

If the function is “well-behaved” (though I’m not sure about the exact conditions) Simpson’s rule - there’s actually several versions, the simplest “1/3” rule is usually good enough - will approximate a definite integral pretty well, very fast.

See this post.

If (like in the OP’s example) the function is quadratic, the rule will even generate a perfect solution, with any even number of calculation intervals (my code will round to the next higher even number, if necessary):

BTW with a higher number of intervals. minor rounding errors may occur (in this particular case; whereas in general the approximation tends to improve with the number of intervals). However, when integration is used for real-world (physical) purposes, small errors don’t matter much. If you require an exact result, better apply mathematical analysis on the original function’s formula.