PHP atanh() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Math

Definition

The PHP atanh() function returns the inverse hyperbolic tangent of a number.

It is the opposite of tanh(), and it only gives a normal answer for numbers strictly between -1 and 1.

Syntax

Call atanh() with the values you need. Start with this line.

PHP
$result = atanh($num);
CallWhat it does
atanh(0)Returns 0 because tanh(0) is 0.
atanh(0.5)Returns about 0.5493.
atanh(1)Returns INF because the result grows without limit.

Valid inputs are between -1 and 1. The values -1 and 1 give -INF and INF.

Library declarations
PHP
atanh(float $num): float

Parameters

ParameterDescription
numRequired. The value to work on. It should be greater than -1 and smaller than 1.

Return Value

Return ValueDescription
floatThe inverse hyperbolic tangent of $num. Returns INF for 1, -INF for -1, and NAN for values outside -1 to 1.

PHP Examples

Example 1 — Basic atanh() usage

This example calls atanh() with zero and a few values between -1 and 1.

PHP
<?php
echo atanh(0) . PHP_EOL;
echo round(atanh(0.5), 4) . PHP_EOL;
echo round(atanh(-0.5), 4) . PHP_EOL;
echo round(atanh(0.9), 4) . PHP_EOL;

How It Works

  1. atanh(0) is 0 because tanh(0) is 0.
  2. atanh(0.5) is about 0.5493.
  3. atanh(-0.5) is the negative of that, -0.5493.
  4. atanh(0.9) is 1.4722, and the result grows fast as the input gets closer to 1.

Example 2 — Boundaries and invalid input

At exactly 1 and -1 the answer is infinite, and outside that range there is no real answer at all.

PHP
<?php
var_dump(atanh(1));
var_dump(atanh(-1));
var_dump(atanh(2));

How It Works

  1. atanh(1) grows without limit, so PHP returns float(INF).
  2. atanh(-1) goes the other way and returns float(-INF).
  3. atanh(2) is outside the valid range.
  4. PHP returns float(NAN) instead of throwing an error.

Example 3 — Round trip with tanh()

atanh() reverses tanh(). Because tanh() always returns a number between -1 and 1, the result can always go back through atanh().

PHP
<?php
$x = 0.5;
$y = tanh($x);
$back = atanh($y);

echo "tanh(0.5) = " . round($y, 4) . PHP_EOL;
echo "atanh back = " . round($back, 4) . PHP_EOL;

How It Works

  1. We start with $x = 0.5.
  2. tanh($x) returns about 0.4621, which is safely between -1 and 1.
  3. atanh($y) reverses the step and returns the original value.
  4. round() removes tiny floating point differences.

Frequently Asked Questions

atanh() returns the inverse hyperbolic tangent of a number. It finds the value whose tanh() equals your input.
It returns INF. atanh(-1) returns -INF.
Because tanh() only produces values between -1 and 1, there is no real answer for 2. PHP returns NAN.
No. It returns INF, -INF or NAN depending on the input.
atan() is the inverse of the normal tangent and accepts any number. atanh() is the inverse of the hyperbolic tangent and only works between -1 and 1.

Next: base_convert()

base_convert() function converts a number from one base to another, such as binary to deci.

base_convert() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful