Average Error: 3.7 → 0.5
Time: 9.9s
Precision: 64
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.982808370584645728390571403324870832662 \cdot 10^{-59} \lor \neg \left(z \le 1.637385439772020732742719657482536703395 \cdot 10^{-52}\right):\\ \;\;\;\;\left(x - \frac{\frac{y}{z}}{3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x + \left(\frac{1}{z} \cdot \frac{\frac{t}{3}}{y} - \frac{\frac{y}{3}}{z}\right)\\ \end{array}\]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;z \le -2.982808370584645728390571403324870832662 \cdot 10^{-59} \lor \neg \left(z \le 1.637385439772020732742719657482536703395 \cdot 10^{-52}\right):\\
\;\;\;\;\left(x - \frac{\frac{y}{z}}{3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\

\mathbf{else}:\\
\;\;\;\;x + \left(\frac{1}{z} \cdot \frac{\frac{t}{3}}{y} - \frac{\frac{y}{3}}{z}\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r767274 = x;
        double r767275 = y;
        double r767276 = z;
        double r767277 = 3.0;
        double r767278 = r767276 * r767277;
        double r767279 = r767275 / r767278;
        double r767280 = r767274 - r767279;
        double r767281 = t;
        double r767282 = r767278 * r767275;
        double r767283 = r767281 / r767282;
        double r767284 = r767280 + r767283;
        return r767284;
}

double f(double x, double y, double z, double t) {
        double r767285 = z;
        double r767286 = -2.9828083705846457e-59;
        bool r767287 = r767285 <= r767286;
        double r767288 = 1.6373854397720207e-52;
        bool r767289 = r767285 <= r767288;
        double r767290 = !r767289;
        bool r767291 = r767287 || r767290;
        double r767292 = x;
        double r767293 = y;
        double r767294 = r767293 / r767285;
        double r767295 = 3.0;
        double r767296 = r767294 / r767295;
        double r767297 = r767292 - r767296;
        double r767298 = t;
        double r767299 = r767285 * r767295;
        double r767300 = r767299 * r767293;
        double r767301 = r767298 / r767300;
        double r767302 = r767297 + r767301;
        double r767303 = 1.0;
        double r767304 = r767303 / r767285;
        double r767305 = r767298 / r767295;
        double r767306 = r767305 / r767293;
        double r767307 = r767304 * r767306;
        double r767308 = r767293 / r767295;
        double r767309 = r767308 / r767285;
        double r767310 = r767307 - r767309;
        double r767311 = r767292 + r767310;
        double r767312 = r767291 ? r767302 : r767311;
        return r767312;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.7
Target1.6
Herbie0.5
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -2.9828083705846457e-59 or 1.6373854397720207e-52 < z

    1. Initial program 0.5

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    2. Using strategy rm
    3. Applied associate-/r*0.5

      \[\leadsto \left(x - \color{blue}{\frac{\frac{y}{z}}{3}}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]

    if -2.9828083705846457e-59 < z < 1.6373854397720207e-52

    1. Initial program 13.7

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    2. Using strategy rm
    3. Applied associate-/r*3.6

      \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \color{blue}{\frac{\frac{t}{z \cdot 3}}{y}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity3.6

      \[\leadsto \left(x - \frac{\color{blue}{1 \cdot y}}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y}\]
    6. Applied times-frac3.6

      \[\leadsto \left(x - \color{blue}{\frac{1}{z} \cdot \frac{y}{3}}\right) + \frac{\frac{t}{z \cdot 3}}{y}\]
    7. Using strategy rm
    8. Applied sub-neg3.6

      \[\leadsto \color{blue}{\left(x + \left(-\frac{1}{z} \cdot \frac{y}{3}\right)\right)} + \frac{\frac{t}{z \cdot 3}}{y}\]
    9. Applied associate-+l+3.6

      \[\leadsto \color{blue}{x + \left(\left(-\frac{1}{z} \cdot \frac{y}{3}\right) + \frac{\frac{t}{z \cdot 3}}{y}\right)}\]
    10. Simplified3.6

      \[\leadsto x + \color{blue}{\left(\frac{\frac{t}{z \cdot 3}}{y} - \frac{\frac{y}{3}}{z}\right)}\]
    11. Using strategy rm
    12. Applied *-un-lft-identity3.6

      \[\leadsto x + \left(\frac{\frac{t}{z \cdot 3}}{\color{blue}{1 \cdot y}} - \frac{\frac{y}{3}}{z}\right)\]
    13. Applied *-un-lft-identity3.6

      \[\leadsto x + \left(\frac{\frac{\color{blue}{1 \cdot t}}{z \cdot 3}}{1 \cdot y} - \frac{\frac{y}{3}}{z}\right)\]
    14. Applied times-frac3.6

      \[\leadsto x + \left(\frac{\color{blue}{\frac{1}{z} \cdot \frac{t}{3}}}{1 \cdot y} - \frac{\frac{y}{3}}{z}\right)\]
    15. Applied times-frac0.3

      \[\leadsto x + \left(\color{blue}{\frac{\frac{1}{z}}{1} \cdot \frac{\frac{t}{3}}{y}} - \frac{\frac{y}{3}}{z}\right)\]
    16. Simplified0.3

      \[\leadsto x + \left(\color{blue}{\frac{1}{z}} \cdot \frac{\frac{t}{3}}{y} - \frac{\frac{y}{3}}{z}\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -2.982808370584645728390571403324870832662 \cdot 10^{-59} \lor \neg \left(z \le 1.637385439772020732742719657482536703395 \cdot 10^{-52}\right):\\ \;\;\;\;\left(x - \frac{\frac{y}{z}}{3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x + \left(\frac{1}{z} \cdot \frac{\frac{t}{3}}{y} - \frac{\frac{y}{3}}{z}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020001 +o rules:numerics
(FPCore (x y z t)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, H"
  :precision binary64

  :herbie-target
  (+ (- x (/ y (* z 3))) (/ (/ t (* z 3)) y))

  (+ (- x (/ y (* z 3))) (/ t (* (* z 3) y))))