NumPhp::tan

Compute tangent element-wise.

Description

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

Parameters

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

Return Values

The new SciPhp\NdArray The tangent values of each element of m. This is a scalar if m is a scalar.

Examples

Example #1: Compute the tangent of matrix values

use SciPhp\NumPhp as np;

$x np::ar([
    [
0   M_PI_2 2, - M_PI 4], 
    [
M_PI 4M_PI_2 20   ]
]);

$y np::tan($x);

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

The above example will output:

x=
[[0                  0.78539816339745   -0.78539816339745]
 [0.78539816339745   0.78539816339745   0                ]]
y=
[[0   1   -1]
 [1   1   0 ]]

See Also