Average Error: 20.2 → 0.1
Time: 2.5m
Precision: 64
Internal Precision: 384
\[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}\]
\[\begin{array}{l} \mathbf{if}\;z \le -354554309650.3642:\\ \;\;\;\;\left(x + y \cdot 0.0692910599291889\right) - \frac{y}{z} \cdot \left(\frac{0.40462203869992125}{z} - 0.07512208616047561\right)\\ \mathbf{if}\;z \le 1.1570910217973246 \cdot 10^{-07}:\\ \;\;\;\;x + \frac{y}{\sqrt{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}} \cdot \frac{\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525}{\sqrt{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}}\\ \mathbf{else}:\\ \;\;\;\;\left(x + y \cdot 0.0692910599291889\right) - \frac{y}{z} \cdot \left(\frac{0.40462203869992125}{z} - 0.07512208616047561\right)\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original20.2
Target0.4
Herbie0.1
\[\begin{array}{l} \mathbf{if}\;z \lt -8120153.652456675:\\ \;\;\;\;\left(\frac{0.07512208616047561}{z} + 0.0692910599291889\right) \cdot y - \left(\frac{0.40462203869992125 \cdot y}{z \cdot z} - x\right)\\ \mathbf{if}\;z \lt 6.576118972787377 \cdot 10^{+20}:\\ \;\;\;\;x + \left(y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)\right) \cdot \frac{1}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{0.07512208616047561}{z} + 0.0692910599291889\right) \cdot y - \left(\frac{0.40462203869992125 \cdot y}{z \cdot z} - x\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -354554309650.3642 or 1.1570910217973246e-07 < z

    1. Initial program 40.2

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}\]
    2. Taylor expanded around inf 0.0

      \[\leadsto x + \color{blue}{\left(\left(0.07512208616047561 \cdot \frac{y}{z} + 0.0692910599291889 \cdot y\right) - 0.40462203869992125 \cdot \frac{y}{{z}^{2}}\right)}\]
    3. Applied simplify0.0

      \[\leadsto \color{blue}{\left(x + y \cdot 0.0692910599291889\right) - \frac{y}{z} \cdot \left(\frac{0.40462203869992125}{z} - 0.07512208616047561\right)}\]

    if -354554309650.3642 < z < 1.1570910217973246e-07

    1. Initial program 0.1

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.4

      \[\leadsto x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\color{blue}{\sqrt{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \cdot \sqrt{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}}}\]
    4. Applied times-frac0.1

      \[\leadsto x + \color{blue}{\frac{y}{\sqrt{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}} \cdot \frac{\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525}{\sqrt{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}}}\]
  3. Recombined 2 regimes into one program.
  4. Removed slow pow expressions.

Runtime

Time bar (total: 2.5m)Debug log

herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit
(FPCore (x y z)
  :name "Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, B"

  :herbie-target
  (if (< z -8120153.652456675) (- (* (+ (/ 0.07512208616047561 z) 0.0692910599291889) y) (- (/ (* 0.40462203869992125 y) (* z z)) x)) (if (< z 6.576118972787377e+20) (+ x (* (* y (+ (* (+ (* z 0.0692910599291889) 0.4917317610505968) z) 0.279195317918525)) (/ 1 (+ (* (+ z 6.012459259764103) z) 3.350343815022304)))) (- (* (+ (/ 0.07512208616047561 z) 0.0692910599291889) y) (- (/ (* 0.40462203869992125 y) (* z z)) x))))

  (+ x (/ (* y (+ (* (+ (* z 0.0692910599291889) 0.4917317610505968) z) 0.279195317918525)) (+ (* (+ z 6.012459259764103) z) 3.350343815022304))))