<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/libc/src/__support/math/atanf_float.h, branch main</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>[libc][math] Add float-only implementation for atanf. (#167004)</title>
<updated>2025-11-20T14:42:13+00:00</updated>
<author>
<name>lntue</name>
<email>lntue@google.com</email>
</author>
<published>2025-11-20T14:42:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=aa3f930931e65b02bacac0c7dfa52a181a0fd5bb'/>
<id>aa3f930931e65b02bacac0c7dfa52a181a0fd5bb</id>
<content type='text'>
Algorithm:
```
  1)  atan(x) = sign(x) * atan(|x|)

  2)  If |x| &gt; 1 + 1/32, atan(|x|) = pi/2 - atan(1/|x|)

  3)  For 1/16 &lt; |x| &lt; 1 + 1/32, we find k such that: | |x| - k/16 | &lt;= 1/32.
      Let y = |x| - k/16, then using the angle summation formula, we have:
    atan(|x|) = atan(k/16) + atan( (|x| - k/16) / (1 + |x| * k/16) )
              = atan(k/16) + atan( y / (1 + (y + k/16) * k/16 )
              = atan(k/16) + atan( y / ((1 + k^2/256) + y * k/16) )

  4)  Let u = y / (1 + k^2/256), then we can rewritten the above as:
    atan(|x|) = atan(k/16) + atan( u / (1 + u * k/16) )
              ~ atan(k/16) + (u - k/16 * u^2 + (k^2/256 - 1/3) * u^3 +
                              + (k/16 - (k/16)^3) * u^4) + O(u^5)
```

With all the computations are done in single precision (float), the
total of approximation errors and rounding errors is bounded by 4 ULPs.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Algorithm:
```
  1)  atan(x) = sign(x) * atan(|x|)

  2)  If |x| &gt; 1 + 1/32, atan(|x|) = pi/2 - atan(1/|x|)

  3)  For 1/16 &lt; |x| &lt; 1 + 1/32, we find k such that: | |x| - k/16 | &lt;= 1/32.
      Let y = |x| - k/16, then using the angle summation formula, we have:
    atan(|x|) = atan(k/16) + atan( (|x| - k/16) / (1 + |x| * k/16) )
              = atan(k/16) + atan( y / (1 + (y + k/16) * k/16 )
              = atan(k/16) + atan( y / ((1 + k^2/256) + y * k/16) )

  4)  Let u = y / (1 + k^2/256), then we can rewritten the above as:
    atan(|x|) = atan(k/16) + atan( u / (1 + u * k/16) )
              ~ atan(k/16) + (u - k/16 * u^2 + (k^2/256 - 1/3) * u^3 +
                              + (k/16 - (k/16)^3) * u^4) + O(u^5)
```

With all the computations are done in single precision (float), the
total of approximation errors and rounding errors is bounded by 4 ULPs.</pre>
</div>
</content>
</entry>
</feed>
