Average Error: 27.2 → 24.2
Time: 29.5s
Precision: 64
Internal Precision: 2368
\[\frac{2.0}{NdotD + \sqrt{\left(NdotD \cdot NdotD + \left(XdotD \cdot alpha_x\right) \cdot \left(XdotD \cdot alpha_x\right)\right) + \left(YdotD \cdot alpha_y\right) \cdot \left(YdotD \cdot alpha_y\right)}}\]
\[\begin{array}{l} \mathbf{if}\;NdotD \le 8.124670755501723 \cdot 10^{+148}:\\ \;\;\;\;\frac{2.0}{\sqrt{\sqrt{\left(alpha_y \cdot YdotD\right) \cdot \left(alpha_y \cdot YdotD\right) + \left(\left(alpha_x \cdot XdotD\right) \cdot \left(alpha_x \cdot XdotD\right) + NdotD \cdot NdotD\right)}} \cdot \sqrt{\sqrt{\left(alpha_y \cdot YdotD\right) \cdot \left(alpha_y \cdot YdotD\right) + \left(\left(alpha_x \cdot XdotD\right) \cdot \left(alpha_x \cdot XdotD\right) + NdotD \cdot NdotD\right)}} + NdotD}\\ \mathbf{else}:\\ \;\;\;\;\frac{2.0}{NdotD + NdotD}\\ \end{array}\]

Error

Bits error versus NdotD

Bits error versus XdotD

Bits error versus alpha_x

Bits error versus YdotD

Bits error versus alpha_y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if NdotD < 8.124670755501723e+148

    1. Initial program 24.4

      \[\frac{2.0}{NdotD + \sqrt{\left(NdotD \cdot NdotD + \left(XdotD \cdot alpha_x\right) \cdot \left(XdotD \cdot alpha_x\right)\right) + \left(YdotD \cdot alpha_y\right) \cdot \left(YdotD \cdot alpha_y\right)}}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt24.4

      \[\leadsto \frac{2.0}{NdotD + \sqrt{\color{blue}{\sqrt{\left(NdotD \cdot NdotD + \left(XdotD \cdot alpha_x\right) \cdot \left(XdotD \cdot alpha_x\right)\right) + \left(YdotD \cdot alpha_y\right) \cdot \left(YdotD \cdot alpha_y\right)} \cdot \sqrt{\left(NdotD \cdot NdotD + \left(XdotD \cdot alpha_x\right) \cdot \left(XdotD \cdot alpha_x\right)\right) + \left(YdotD \cdot alpha_y\right) \cdot \left(YdotD \cdot alpha_y\right)}}}}\]
    4. Applied sqrt-prod24.6

      \[\leadsto \frac{2.0}{NdotD + \color{blue}{\sqrt{\sqrt{\left(NdotD \cdot NdotD + \left(XdotD \cdot alpha_x\right) \cdot \left(XdotD \cdot alpha_x\right)\right) + \left(YdotD \cdot alpha_y\right) \cdot \left(YdotD \cdot alpha_y\right)}} \cdot \sqrt{\sqrt{\left(NdotD \cdot NdotD + \left(XdotD \cdot alpha_x\right) \cdot \left(XdotD \cdot alpha_x\right)\right) + \left(YdotD \cdot alpha_y\right) \cdot \left(YdotD \cdot alpha_y\right)}}}}\]

    if 8.124670755501723e+148 < NdotD

    1. Initial program 44.0

      \[\frac{2.0}{NdotD + \sqrt{\left(NdotD \cdot NdotD + \left(XdotD \cdot alpha_x\right) \cdot \left(XdotD \cdot alpha_x\right)\right) + \left(YdotD \cdot alpha_y\right) \cdot \left(YdotD \cdot alpha_y\right)}}\]
    2. Taylor expanded around inf 22.1

      \[\leadsto \frac{2.0}{NdotD + \color{blue}{NdotD}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification24.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;NdotD \le 8.124670755501723 \cdot 10^{+148}:\\ \;\;\;\;\frac{2.0}{\sqrt{\sqrt{\left(alpha_y \cdot YdotD\right) \cdot \left(alpha_y \cdot YdotD\right) + \left(\left(alpha_x \cdot XdotD\right) \cdot \left(alpha_x \cdot XdotD\right) + NdotD \cdot NdotD\right)}} \cdot \sqrt{\sqrt{\left(alpha_y \cdot YdotD\right) \cdot \left(alpha_y \cdot YdotD\right) + \left(\left(alpha_x \cdot XdotD\right) \cdot \left(alpha_x \cdot XdotD\right) + NdotD \cdot NdotD\right)}} + NdotD}\\ \mathbf{else}:\\ \;\;\;\;\frac{2.0}{NdotD + NdotD}\\ \end{array}\]

Runtime

Time bar (total: 29.5s)Debug log

herbie shell --seed '#(2775764126 3555076145 3898259844 1891440260 2599947619 1948460636)' 
(FPCore (NdotD XdotD alpha_x YdotD alpha_y)
  :name "2.0 / (NdotD + sqrt((NdotD*NdotD) + (XdotD*alpha_x)*(XdotD*alpha_x) + (YdotD*alpha_y)*(YdotD*alpha_y)))"
  (/ 2.0 (+ NdotD (sqrt (+ (+ (* NdotD NdotD) (* (* XdotD alpha_x) (* XdotD alpha_x))) (* (* YdotD alpha_y) (* YdotD alpha_y)))))))