summaryrefslogtreecommitdiff
path: root/devdocs/c/numeric%2Fmath%2Fatanh.html
blob: 68ec0eb783bedb64d2fca9c6659e72fb607c392d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
    <h1 id="firstHeading" class="firstHeading">atanh, atanhf, atanhl</h1>            <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code>&lt;math.h&gt;</code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">float       atanhf( float arg );</pre>
</td> <td> (1) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">double      atanh( double arg );</pre>
</td> <td> (2) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">long double atanhl( long double arg );</pre>
</td> <td> (3) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dsc-header"> <th> Defined in header <code>&lt;tgmath.h&gt;</code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">#define atanh( arg )</pre>
</td> <td> (4) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr>  </table> <div class="t-li1">
<span class="t-li">1-3)</span> Computes the inverse hyperbolic tangent of <code>arg</code>.</div> <div class="t-li1">
<span class="t-li">4)</span> Type-generic macro: If the argument has type <code>long double</code>, <code>atanhl</code> is called. Otherwise, if the argument has integer type or the type <code>double</code>, <code>atanh</code> is called. Otherwise, <code>atanhf</code> is called. If the argument is complex, then the macro invokes the corresponding complex function (<code><a href="http://en.cppreference.com/w/c/numeric/complex/catanh"><span class="kw805">catanhf</span></a></code>, <code><a href="http://en.cppreference.com/w/c/numeric/complex/catanh"><span class="kw804">catanh</span></a></code>, <code><a href="http://en.cppreference.com/w/c/numeric/complex/catanh"><span class="kw806">catanhl</span></a></code>).</div>  <h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> arg </td> <td> - </td> <td> floating point value representing the area of a hyperbolic sector </td>
</tr>
</table> <h3 id="Return_value"> Return value</h3> <p>If no errors occur, the inverse hyperbolic tangent of <code>arg</code> (tanh<sup class="t-su">-1</sup>(arg), or artanh(arg)), is returned.</p>
<p>If a domain error occurs, an implementation-defined value is returned (NaN where supported).</p>
<p>If a pole error occurs, <code><a href="huge_val" title="c/numeric/math/HUGE VAL">±HUGE_VAL</a></code>, <code>±HUGE_VALF</code>, or <code>±HUGE_VALL</code> is returned (with the correct sign).</p>
<p>If a range error occurs due to underflow, the correct result (after rounding) is returned.</p>
<h3 id="Error_handling"> Error handling</h3> <p>Errors are reported as specified in <a href="math_errhandling" title="c/numeric/math/math errhandling"><code>math_errhandling</code></a>.</p>
<p>If the argument is not on the interval [-1, +1], a range error occurs.</p>
<p>If the argument is ±1, a pole error occurs.</p>
<p>If the implementation supports IEEE floating-point arithmetic (IEC 60559),</p>
<ul>
<li> if the argument is ±0, it is returned unmodified </li>
<li> if the argument is ±1, ±∞ is returned and <code><a href="../fenv/fe_exceptions" title="c/numeric/fenv/FE exceptions">FE_DIVBYZERO</a></code> is raised. </li>
<li> if |arg|&gt;1, NaN is returned and <code><a href="../fenv/fe_exceptions" title="c/numeric/fenv/FE exceptions">FE_INVALID</a></code> is raised. </li>
<li> if the argument is NaN, NaN is returned. </li>
</ul> <h3 id="Notes"> Notes</h3> <p>Although the C standard names this function "arc hyperbolic tangent", the inverse functions of the hyperbolic functions are the area functions. Their argument is the area of a hyperbolic sector, not an arc. The correct name is "inverse hyperbolic tangent" (used by POSIX) or "area hyperbolic tangent".</p>
<p><a rel="nofollow" class="external text" href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/atanh.html">POSIX specifies</a> that in case of underflow, <code>arg</code> is returned unmodified, and if that is not supported, an implementation-defined value no greater than <code><a href="../../types/limits" title="c/types/limits">DBL_MIN</a></code>, <code><a href="../../types/limits" title="c/types/limits">FLT_MIN</a></code>, and <code><a href="../../types/limits" title="c/types/limits">LDBL_MIN</a></code> is returned.</p>
<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include &lt;stdio.h&gt;
#include &lt;math.h&gt;
#include &lt;float.h&gt;
#include &lt;errno.h&gt;
#include &lt;fenv.h&gt;
// #pragma STDC FENV_ACCESS ON
 
int main(void)
{
    printf("atanh(0) = %f\natanh(-0) = %f\n", atanh(0), atanh(-0.0));
    printf("atanh(0.9) = %f\n", atanh(0.9));
    //error handling
    errno = 0; feclearexcept(FE_ALL_EXCEPT);
    printf("atanh(-1) = %f\n", atanh(-1));
    if (errno == ERANGE)
        perror("    errno == ERANGE");
    if (fetestexcept(FE_DIVBYZERO))
        puts("    FE_DIVBYZERO raised");
}</pre></div> <p>Possible output:</p>
<div class="text source-text"><pre data-language="c">atanh(0) = 0.000000
atanh(-0) = -0.000000
atanh(0.9) = 1.472219
atanh(-1) = -inf
    errno == ERANGE: Numerical result out of range
    FE_DIVBYZERO raised</pre></div> </div> <h3 id="References"> References</h3>  <ul>
<li> C17 standard (ISO/IEC 9899:2018): </li>
<ul>
<li> 7.12.5.3 The atanh functions (p: TBD) </li>
<li> 7.25 Type-generic math &lt;tgmath.h&gt; (p: TBD) </li>
<li> F.10.2.3 The atanh functions (p: TBD) </li>
</ul>
<li> C11 standard (ISO/IEC 9899:2011): </li>
<ul>
<li> 7.12.5.3 The atanh functions (p: 241) </li>
<li> 7.25 Type-generic math &lt;tgmath.h&gt; (p: 373-375) </li>
<li> F.10.2.3 The atanh functions (p: 520) </li>
</ul>
<li> C99 standard (ISO/IEC 9899:1999): </li>
<ul>
<li> 7.12.5.3 The atanh functions (p: 221-222) </li>
<li> 7.22 Type-generic math &lt;tgmath.h&gt; (p: 335-337) </li>
<li> F.9.2.3 The atanh functions (p: 457) </li>
</ul>
</ul>                 <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="asinh" title="c/numeric/math/asinh"> <span class="t-lines"><span>asinh</span><span>asinhf</span><span>asinhl</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> computes inverse hyperbolic sine (\({\small\operatorname{arsinh}{x} }\)arsinh(x)) <br> <span class="t-mark">(function)</span>  </td>
</tr> <tr class="t-dsc"> <td> <div><a href="acosh" title="c/numeric/math/acosh"> <span class="t-lines"><span>acosh</span><span>acoshf</span><span>acoshl</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> computes inverse hyperbolic cosine (\({\small\operatorname{arcosh}{x} }\)arcosh(x)) <br> <span class="t-mark">(function)</span>  </td>
</tr> <tr class="t-dsc"> <td> <div><a href="tanh" title="c/numeric/math/tanh"> <span class="t-lines"><span>tanh</span><span>tanhf</span><span>tanhl</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> computes hyperbolic tangent (\({\small\tanh{x} }\)tanh(x)) <br> <span class="t-mark">(function)</span>  </td>
</tr> <tr class="t-dsc"> <td> <div><a href="../complex/catanh" title="c/numeric/complex/catanh"> <span class="t-lines"><span>catanh</span><span>catanhf</span><span>catanhl</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> computes the complex arc hyperbolic tangent <br> <span class="t-mark">(function)</span>  </td>
</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/numeric/math/atanh" title="cpp/numeric/math/atanh">C++ documentation</a></span> for <code>atanh</code> </td>
</tr> </table> <h3 id="External_links"> External links</h3> <table> <tr> <td>
<a rel="nofollow" class="external text" href="https://mathworld.wolfram.com/InverseHyperbolicTangent.html">Weisstein, Eric W. "Inverse Hyperbolic Tangent."</a> From MathWorld — A Wolfram Web Resource. </td>
</tr>
</table>           <div class="_attribution">
  <p class="_attribution-p">
    &copy; cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br>
    <a href="https://en.cppreference.com/w/c/numeric/math/atanh" class="_attribution-link">https://en.cppreference.com/w/c/numeric/math/atanh</a>
  </p>
</div>