Average Error: 20.6 → 0.1
Time: 59.4s
Precision: 64
\[x + \frac{y \cdot \left(\left(z \cdot 0.06929105992918889456166908757950295694172 + 0.4917317610505967939715787906607147306204\right) \cdot z + 0.2791953179185249767080279070796677842736\right)}{\left(z + 6.012459259764103336465268512256443500519\right) \cdot z + 3.350343815022303939343828460550867021084}\]
\[\begin{array}{l} \mathbf{if}\;z \le -6.766709111451644193955940194972756165735 \cdot 10^{44} \lor \neg \left(z \le 1835980.83345684572122991085052490234375\right):\\ \;\;\;\;\left(y \cdot 0.06929105992918889456166908757950295694172 + \left(\frac{0.07512208616047560960637952121032867580652}{\frac{z}{y}} - \frac{0.4046220386999212492717958866705885156989}{z} \cdot \frac{y}{z}\right)\right) + x\\ \mathbf{else}:\\ \;\;\;\;\left(0.2791953179185249767080279070796677842736 + \left(z \cdot 0.4917317610505967939715787906607147306204 + 0.06929105992918889456166908757950295694172 \cdot \left(z \cdot z\right)\right)\right) \cdot \frac{y}{3.350343815022303939343828460550867021084 + \left(z + 6.012459259764103336465268512256443500519\right) \cdot z} + x\\ \end{array}\]
x + \frac{y \cdot \left(\left(z \cdot 0.06929105992918889456166908757950295694172 + 0.4917317610505967939715787906607147306204\right) \cdot z + 0.2791953179185249767080279070796677842736\right)}{\left(z + 6.012459259764103336465268512256443500519\right) \cdot z + 3.350343815022303939343828460550867021084}
\begin{array}{l}
\mathbf{if}\;z \le -6.766709111451644193955940194972756165735 \cdot 10^{44} \lor \neg \left(z \le 1835980.83345684572122991085052490234375\right):\\
\;\;\;\;\left(y \cdot 0.06929105992918889456166908757950295694172 + \left(\frac{0.07512208616047560960637952121032867580652}{\frac{z}{y}} - \frac{0.4046220386999212492717958866705885156989}{z} \cdot \frac{y}{z}\right)\right) + x\\

\mathbf{else}:\\
\;\;\;\;\left(0.2791953179185249767080279070796677842736 + \left(z \cdot 0.4917317610505967939715787906607147306204 + 0.06929105992918889456166908757950295694172 \cdot \left(z \cdot z\right)\right)\right) \cdot \frac{y}{3.350343815022303939343828460550867021084 + \left(z + 6.012459259764103336465268512256443500519\right) \cdot z} + x\\

\end{array}
double f(double x, double y, double z) {
        double r353451 = x;
        double r353452 = y;
        double r353453 = z;
        double r353454 = 0.0692910599291889;
        double r353455 = r353453 * r353454;
        double r353456 = 0.4917317610505968;
        double r353457 = r353455 + r353456;
        double r353458 = r353457 * r353453;
        double r353459 = 0.279195317918525;
        double r353460 = r353458 + r353459;
        double r353461 = r353452 * r353460;
        double r353462 = 6.012459259764103;
        double r353463 = r353453 + r353462;
        double r353464 = r353463 * r353453;
        double r353465 = 3.350343815022304;
        double r353466 = r353464 + r353465;
        double r353467 = r353461 / r353466;
        double r353468 = r353451 + r353467;
        return r353468;
}

double f(double x, double y, double z) {
        double r353469 = z;
        double r353470 = -6.766709111451644e+44;
        bool r353471 = r353469 <= r353470;
        double r353472 = 1835980.8334568457;
        bool r353473 = r353469 <= r353472;
        double r353474 = !r353473;
        bool r353475 = r353471 || r353474;
        double r353476 = y;
        double r353477 = 0.0692910599291889;
        double r353478 = r353476 * r353477;
        double r353479 = 0.07512208616047561;
        double r353480 = r353469 / r353476;
        double r353481 = r353479 / r353480;
        double r353482 = 0.40462203869992125;
        double r353483 = r353482 / r353469;
        double r353484 = r353476 / r353469;
        double r353485 = r353483 * r353484;
        double r353486 = r353481 - r353485;
        double r353487 = r353478 + r353486;
        double r353488 = x;
        double r353489 = r353487 + r353488;
        double r353490 = 0.279195317918525;
        double r353491 = 0.4917317610505968;
        double r353492 = r353469 * r353491;
        double r353493 = r353469 * r353469;
        double r353494 = r353477 * r353493;
        double r353495 = r353492 + r353494;
        double r353496 = r353490 + r353495;
        double r353497 = 3.350343815022304;
        double r353498 = 6.012459259764103;
        double r353499 = r353469 + r353498;
        double r353500 = r353499 * r353469;
        double r353501 = r353497 + r353500;
        double r353502 = r353476 / r353501;
        double r353503 = r353496 * r353502;
        double r353504 = r353503 + r353488;
        double r353505 = r353475 ? r353489 : r353504;
        return r353505;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original20.6
Target0.2
Herbie0.1
\[\begin{array}{l} \mathbf{if}\;z \lt -8120153.6524566747248172760009765625:\\ \;\;\;\;\left(\frac{0.07512208616047560960637952121032867580652}{z} + 0.06929105992918889456166908757950295694172\right) \cdot y - \left(\frac{0.4046220386999212492717958866705885156989 \cdot y}{z \cdot z} - x\right)\\ \mathbf{elif}\;z \lt 657611897278737678336:\\ \;\;\;\;x + \left(y \cdot \left(\left(z \cdot 0.06929105992918889456166908757950295694172 + 0.4917317610505967939715787906607147306204\right) \cdot z + 0.2791953179185249767080279070796677842736\right)\right) \cdot \frac{1}{\left(z + 6.012459259764103336465268512256443500519\right) \cdot z + 3.350343815022303939343828460550867021084}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{0.07512208616047560960637952121032867580652}{z} + 0.06929105992918889456166908757950295694172\right) \cdot y - \left(\frac{0.4046220386999212492717958866705885156989 \cdot y}{z \cdot z} - x\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -6.766709111451644e+44 or 1835980.8334568457 < z

    1. Initial program 43.9

      \[x + \frac{y \cdot \left(\left(z \cdot 0.06929105992918889456166908757950295694172 + 0.4917317610505967939715787906607147306204\right) \cdot z + 0.2791953179185249767080279070796677842736\right)}{\left(z + 6.012459259764103336465268512256443500519\right) \cdot z + 3.350343815022303939343828460550867021084}\]
    2. Simplified35.0

      \[\leadsto \color{blue}{\frac{\left(0.4917317610505967939715787906607147306204 + z \cdot 0.06929105992918889456166908757950295694172\right) \cdot z + 0.2791953179185249767080279070796677842736}{z \cdot \left(z + 6.012459259764103336465268512256443500519\right) + 3.350343815022303939343828460550867021084} \cdot y + x}\]
    3. Taylor expanded around 0 35.0

      \[\leadsto \frac{\color{blue}{\left(0.4917317610505967939715787906607147306204 \cdot z + 0.06929105992918889456166908757950295694172 \cdot {z}^{2}\right)} + 0.2791953179185249767080279070796677842736}{z \cdot \left(z + 6.012459259764103336465268512256443500519\right) + 3.350343815022303939343828460550867021084} \cdot y + x\]
    4. Simplified35.0

      \[\leadsto \frac{\color{blue}{\left(0.4917317610505967939715787906607147306204 \cdot z + 0.06929105992918889456166908757950295694172 \cdot \left(z \cdot z\right)\right)} + 0.2791953179185249767080279070796677842736}{z \cdot \left(z + 6.012459259764103336465268512256443500519\right) + 3.350343815022303939343828460550867021084} \cdot y + x\]
    5. Using strategy rm
    6. Applied add-exp-log36.4

      \[\leadsto \frac{\left(0.4917317610505967939715787906607147306204 \cdot z + 0.06929105992918889456166908757950295694172 \cdot \left(z \cdot z\right)\right) + 0.2791953179185249767080279070796677842736}{\color{blue}{e^{\log \left(z \cdot \left(z + 6.012459259764103336465268512256443500519\right) + 3.350343815022303939343828460550867021084\right)}}} \cdot y + x\]
    7. Applied add-exp-log36.6

      \[\leadsto \frac{\color{blue}{e^{\log \left(\left(0.4917317610505967939715787906607147306204 \cdot z + 0.06929105992918889456166908757950295694172 \cdot \left(z \cdot z\right)\right) + 0.2791953179185249767080279070796677842736\right)}}}{e^{\log \left(z \cdot \left(z + 6.012459259764103336465268512256443500519\right) + 3.350343815022303939343828460550867021084\right)}} \cdot y + x\]
    8. Applied div-exp36.6

      \[\leadsto \color{blue}{e^{\log \left(\left(0.4917317610505967939715787906607147306204 \cdot z + 0.06929105992918889456166908757950295694172 \cdot \left(z \cdot z\right)\right) + 0.2791953179185249767080279070796677842736\right) - \log \left(z \cdot \left(z + 6.012459259764103336465268512256443500519\right) + 3.350343815022303939343828460550867021084\right)}} \cdot y + x\]
    9. Simplified35.0

      \[\leadsto e^{\color{blue}{\log \left(\frac{0.4917317610505967939715787906607147306204 \cdot z + \left(\left(z \cdot z\right) \cdot 0.06929105992918889456166908757950295694172 + 0.2791953179185249767080279070796677842736\right)}{\left(z + 6.012459259764103336465268512256443500519\right) \cdot z + 3.350343815022303939343828460550867021084}\right)}} \cdot y + x\]
    10. Taylor expanded around inf 0.0

      \[\leadsto \color{blue}{\left(\left(0.06929105992918889456166908757950295694172 \cdot y + 0.07512208616047560960637952121032867580652 \cdot \frac{y}{z}\right) - 0.4046220386999212492717958866705885156989 \cdot \frac{y}{{z}^{2}}\right)} + x\]
    11. Simplified0.0

      \[\leadsto \color{blue}{\left(\left(\frac{0.07512208616047560960637952121032867580652}{\frac{z}{y}} - \frac{y}{z} \cdot \frac{0.4046220386999212492717958866705885156989}{z}\right) + y \cdot 0.06929105992918889456166908757950295694172\right)} + x\]

    if -6.766709111451644e+44 < z < 1835980.8334568457

    1. Initial program 0.4

      \[x + \frac{y \cdot \left(\left(z \cdot 0.06929105992918889456166908757950295694172 + 0.4917317610505967939715787906607147306204\right) \cdot z + 0.2791953179185249767080279070796677842736\right)}{\left(z + 6.012459259764103336465268512256443500519\right) \cdot z + 3.350343815022303939343828460550867021084}\]
    2. Simplified0.1

      \[\leadsto \color{blue}{\frac{\left(0.4917317610505967939715787906607147306204 + z \cdot 0.06929105992918889456166908757950295694172\right) \cdot z + 0.2791953179185249767080279070796677842736}{z \cdot \left(z + 6.012459259764103336465268512256443500519\right) + 3.350343815022303939343828460550867021084} \cdot y + x}\]
    3. Taylor expanded around 0 0.1

      \[\leadsto \frac{\color{blue}{\left(0.4917317610505967939715787906607147306204 \cdot z + 0.06929105992918889456166908757950295694172 \cdot {z}^{2}\right)} + 0.2791953179185249767080279070796677842736}{z \cdot \left(z + 6.012459259764103336465268512256443500519\right) + 3.350343815022303939343828460550867021084} \cdot y + x\]
    4. Simplified0.1

      \[\leadsto \frac{\color{blue}{\left(0.4917317610505967939715787906607147306204 \cdot z + 0.06929105992918889456166908757950295694172 \cdot \left(z \cdot z\right)\right)} + 0.2791953179185249767080279070796677842736}{z \cdot \left(z + 6.012459259764103336465268512256443500519\right) + 3.350343815022303939343828460550867021084} \cdot y + x\]
    5. Using strategy rm
    6. Applied div-inv0.4

      \[\leadsto \color{blue}{\left(\left(\left(0.4917317610505967939715787906607147306204 \cdot z + 0.06929105992918889456166908757950295694172 \cdot \left(z \cdot z\right)\right) + 0.2791953179185249767080279070796677842736\right) \cdot \frac{1}{z \cdot \left(z + 6.012459259764103336465268512256443500519\right) + 3.350343815022303939343828460550867021084}\right)} \cdot y + x\]
    7. Applied associate-*l*0.2

      \[\leadsto \color{blue}{\left(\left(0.4917317610505967939715787906607147306204 \cdot z + 0.06929105992918889456166908757950295694172 \cdot \left(z \cdot z\right)\right) + 0.2791953179185249767080279070796677842736\right) \cdot \left(\frac{1}{z \cdot \left(z + 6.012459259764103336465268512256443500519\right) + 3.350343815022303939343828460550867021084} \cdot y\right)} + x\]
    8. Simplified0.2

      \[\leadsto \left(\left(0.4917317610505967939715787906607147306204 \cdot z + 0.06929105992918889456166908757950295694172 \cdot \left(z \cdot z\right)\right) + 0.2791953179185249767080279070796677842736\right) \cdot \color{blue}{\frac{y}{\left(z + 6.012459259764103336465268512256443500519\right) \cdot z + 3.350343815022303939343828460550867021084}} + x\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -6.766709111451644193955940194972756165735 \cdot 10^{44} \lor \neg \left(z \le 1835980.83345684572122991085052490234375\right):\\ \;\;\;\;\left(y \cdot 0.06929105992918889456166908757950295694172 + \left(\frac{0.07512208616047560960637952121032867580652}{\frac{z}{y}} - \frac{0.4046220386999212492717958866705885156989}{z} \cdot \frac{y}{z}\right)\right) + x\\ \mathbf{else}:\\ \;\;\;\;\left(0.2791953179185249767080279070796677842736 + \left(z \cdot 0.4917317610505967939715787906607147306204 + 0.06929105992918889456166908757950295694172 \cdot \left(z \cdot z\right)\right)\right) \cdot \frac{y}{3.350343815022303939343828460550867021084 + \left(z + 6.012459259764103336465268512256443500519\right) \cdot z} + x\\ \end{array}\]

Reproduce

herbie shell --seed 2019174 
(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.0 (+ (* (+ 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))))