Trigonometric Functions in PHP

acos() — Arc cosine

acosh() — Inverse hyperbolic cosine

asin() — Arc sine

asinh() — Inverse hyperbolic sine

atan2() — Arc tangent of two variables

atan() — Arc tangent

atanh() — Inverse hyperbolic tangent

cos() — Cosine

cosh() — Hyperbolic cosine

sin() — Sine

sinh() — Hyperbolic sine

tan() — Tangent

tanh() — Hyperbolic tangent

PHP acos() Function

What does acos() do?

The PHP acos() function will give you the arc cosine of arg in radians. acos() is the inverse function of cos(), which means that a==cos(acos(a)) for every value of a that is within acos()‘ range.

PHP acos() Syntax

 acos ( float $arg ) : float

PHP acos() Parameters

  1. arg — The argument to process

PHP acos() Return Value

The PHP acos() function returns the arc cosine of arg in radians.

PHP acosh() Function

What does acosh() do?

The PHP acosh() function will give you the inverse hyperbolic cosine of arg, i.e. the value whose hyperbolic cosine is arg.

PHP acosh() Syntax

 acosh ( float $arg ) : float

PHP acosh() Parameters

  1. arg — The value to process

PHP acosh() Return Value

The PHP acosh() function returns the inverse hyperbolic cosine of arg

Changelog for PHP acosh() Function

5.3.0 — This function is now available on all platforms

PHP asin() Function

What does asin() do?

The PHP asin() function will give you the arc sine of arg in radians. asin() is the inverse function of sin(), which means that a==sin(asin(a)) for every value of a that is within asin()‘s range.

PHP asin() Syntax

 asin ( float $arg ) : float

PHP asin() Parameters

  1. arg — The argument to process

PHP asin() Return Value

The PHP asin() function returns the arc sine of arg in radians

PHP asinh() Function

What does asinh() do?

The PHP asinh() function will give you the inverse hyperbolic sine of arg, i.e. the value whose hyperbolic sine is arg.

PHP asinh() Syntax

 asinh ( float $arg ) : float

PHP asinh() Parameters

  1. arg — The argument to process

PHP asinh() Return Value

The PHP asinh() function returns the inverse hyperbolic sine of arg

Changelog for PHP asinh() Function

5.3.0 — This function is now available on all platforms

PHP atan() Function

What does atan() do?

The PHP atan() function will give you the arc tangent of arg in radians. atan() is the inverse function of tan(), which means that a==tan(atan(a)) for every value of a that is within atan()‘s range.

PHP atan() Syntax

 atan ( float $arg ) : float

PHP atan() Parameters

  1. arg — The argument to process

PHP atan() Return Value

The PHP atan() function returns the arc tangent of arg in radians.

Additional Tips from Fellow Developers

Contributed By: Anonymous

Contrary to the current description, it should hold y == tan(atan(y)) for ALL  y.
However, x == atan(tan(x)) only holds for those x which are in the range of atan, which are those x with -pi/2 < x < pi/2.
Of course, those equalities are limited by precision. On my machine
tan(atan(1000)) returns 1000.0000000001.
atan(tan(0)) returns 0 (correct).
atan(tan(M_PI)) returns -1.2246467991474E-16 instead of 0.

PHP atan2() Function

What does atan2() do?

The PHP atan2() function will this function calculates the arc tangent of the two variables x and y. It is similar to calculating the arc tangent of y / x, except that the signs of both arguments are used to determine the quadrant of the result.

PHP atan2() Syntax

 atan2 ( float $y , float $x ) : float

PHP atan2() Parameters

  1. y — Dividend parameter

  2. x — Divisor parameter

PHP atan2() Return Value

The PHP atan2() function returns the arc tangent of y/x in radians.

Additional Tips from Fellow Developers

Contributed By: reubs

Just a note:
PHP's atan2 function receives parameters in (y,x) and Excel receives it in (x,y) format. Just in case you are porting formulas across. :)

PHP atanh() Function

What does atanh() do?

The PHP atanh() function will give you the inverse hyperbolic tangent of arg, i.e. the value whose hyperbolic tangent is arg.

PHP atanh() Syntax

 atanh ( float $arg ) : float

PHP atanh() Parameters

  1. arg — The argument to process

PHP atanh() Return Value

The PHP atanh() function returns inverse hyperbolic tangent of arg

Changelog for PHP atanh() Function

5.3.0 — This function is now available on all platforms

PHP cos() Function

What does cos() do?

The PHP cos() function will give you the cosine of the arg parameter. The arg parameter is in radians.

PHP cos() Syntax

 cos ( float $arg ) : float

PHP cos() Parameters

  1. arg — An angle in radians

PHP cos() Return Value

The PHP cos() function returns the cosine of arg

PHP cos() Working Examples

1. cos() example

<?php
echo cos(M_PI); // -1
?>

PHP cosh() Function

What does cosh() do?

The PHP cosh() function will give you the hyperbolic cosine of arg, defined as (exp(arg) + exp(-arg))/2.

PHP cosh() Syntax

 cosh ( float $arg ) : float

PHP cosh() Parameters

  1. arg — The argument to process

PHP cosh() Return Value

The PHP cosh() function returns the hyperbolic cosine of arg

PHP sin() Function

What does sin() do?

The PHP sin() function will give you the sine of the arg parameter. The arg parameter is in radians.

PHP sin() Syntax

 sin ( float $arg ) : float

PHP sin() Parameters

  1. arg — A value in radians

PHP sin() Return Value

The PHP sin() function returns the sine of arg

PHP sin() Working Examples

1. sin() example

<?php
// Precision depends on your precision directive
echo sin(deg2rad(60));  //  0.866025403 ...
echo sin(60);           // -0.304810621 ...
?>

PHP sinh() Function

What does sinh() do?

The PHP sinh() function will give you the hyperbolic sine of arg, defined as (exp(arg) – exp(-arg))/2.

PHP sinh() Syntax

 sinh ( float $arg ) : float

PHP sinh() Parameters

  1. arg — The argument to process

PHP sinh() Return Value

The PHP sinh() function returns the hyperbolic sine of arg

PHP tan() Function

What does tan() do?

The PHP tan() function will give you the tangent of the arg parameter. The arg parameter is in radians.

PHP tan() Syntax

 tan ( float $arg ) : float

PHP tan() Parameters

  1. arg — The argument to process in radians

PHP tan() Return Value

The PHP tan() function returns the tangent of arg

PHP tan() Working Examples

1. tan() example

<?php
echo tan(M_PI_4); // 1
?>

PHP tanh() Function

What does tanh() do?

The PHP tanh() function will give you the hyperbolic tangent of arg, defined as sinh(arg)/cosh(arg).

PHP tanh() Syntax

 tanh ( float $arg ) : float

PHP tanh() Parameters

  1. arg — The argument to process

PHP tanh() Return Value

The PHP tanh() function returns the hyperbolic tangent of arg

Rate this post —

Very PoorPoorAverageGoodExcellent (No Ratings Yet)
Loading...

Author: Nitish Kumar

Leave a Reply

avatar
1000
  Subscribe  
Notify of
0%