prod

prod(a, b, c, ...)

prod(A)

Try it yourself:


prod(): Product of Collection Values

prod() multiplies all values in a collection. For [2, 3, 4], the result is 24. It is useful for compound factors, scaling chains, and probability products.

Zeros and precision

Any zero input makes the product zero. Large products can overflow and small fractional products can underflow, so log-space calculations with log() may be better for long sequences. Use multiply() for a fixed pair and sum() for aggregation by addition.

Confirm collection shape with size() and handle empty inputs deliberately; a mathematical empty product convention may differ from an application’s expected value.

All functions