NumPhp::trapz

Integrate along the given axis using the composite trapezoidal rule.

Description

float|int NumPhp::trapz( array|NdArray $m )

Parameters

$m
An array [1, 2, 3] or a NdArray.

Return Values

A float|int

Examples

Example #1: Integrate a range

use SciPhp\NumPhp as np;

$m np::arange(05);

$r np::trapz($m);

echo 
"m\n$m""r\n$r";

The above example will output:

m
[0  1  2  3  4]
r
8

See Also

  • NumPhp::prod() - Documentation does NOT exist for this function
  • NumPhp::sum() - Sum all elements.