NumPhp::cos

Cosine element-wise.

Description

SciPhp\NdArray NdArray::cos( array|NdArray $m )

Parameters

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

Return Values

The new SciPhp\NdArray The corresponding cosine values. This is a scalar if m is a scalar.

Examples

Example #1: Cosine matrix values

use SciPhp\NumPhp as np;

$x np::ar([
    [
0   M_PI_2M_PI], 
    [
M_PIM_PI_20   ]
]);

$y np::cos($x);

echo 
"x=\n$x\n""y=\n$y\n";

The above example will output:

x=
[[0                1.5707963267949  3.1415926535898]
 [3.1415926535898  1.5707963267949  0              ]]

y=
[[1                    6.1232339957368E-17  -1                 ]
 [-1                   6.1232339957368E-17  1                  ]]

See Also