Average Error: 3.8 → 0.4
Time: 5.4s
Precision: 64
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;t \le -5.63380401175012114 \cdot 10^{26} \lor \neg \left(t \le 2.41708142255612862 \cdot 10^{-32}\right):\\ \;\;\;\;\left(x - \frac{\frac{y}{z}}{3}\right) + 0.333333333333333315 \cdot \frac{t}{z \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{\frac{y}{z}}{3}\right) + \frac{1}{z} \cdot \frac{\frac{t}{3}}{y}\\ \end{array}\]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;t \le -5.63380401175012114 \cdot 10^{26} \lor \neg \left(t \le 2.41708142255612862 \cdot 10^{-32}\right):\\
\;\;\;\;\left(x - \frac{\frac{y}{z}}{3}\right) + 0.333333333333333315 \cdot \frac{t}{z \cdot y}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r693476 = x;
        double r693477 = y;
        double r693478 = z;
        double r693479 = 3.0;
        double r693480 = r693478 * r693479;
        double r693481 = r693477 / r693480;
        double r693482 = r693476 - r693481;
        double r693483 = t;
        double r693484 = r693480 * r693477;
        double r693485 = r693483 / r693484;
        double r693486 = r693482 + r693485;
        return r693486;
}

double f(double x, double y, double z, double t) {
        double r693487 = t;
        double r693488 = -5.633804011750121e+26;
        bool r693489 = r693487 <= r693488;
        double r693490 = 2.4170814225561286e-32;
        bool r693491 = r693487 <= r693490;
        double r693492 = !r693491;
        bool r693493 = r693489 || r693492;
        double r693494 = x;
        double r693495 = y;
        double r693496 = z;
        double r693497 = r693495 / r693496;
        double r693498 = 3.0;
        double r693499 = r693497 / r693498;
        double r693500 = r693494 - r693499;
        double r693501 = 0.3333333333333333;
        double r693502 = r693496 * r693495;
        double r693503 = r693487 / r693502;
        double r693504 = r693501 * r693503;
        double r693505 = r693500 + r693504;
        double r693506 = 1.0;
        double r693507 = r693506 / r693496;
        double r693508 = r693487 / r693498;
        double r693509 = r693508 / r693495;
        double r693510 = r693507 * r693509;
        double r693511 = r693500 + r693510;
        double r693512 = r693493 ? r693505 : r693511;
        return r693512;
}

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.8
Target1.8
Herbie0.4
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y}\]

Derivation

  1. Split input into 2 regimes
  2. if t < -5.633804011750121e+26 or 2.4170814225561286e-32 < t

    1. Initial program 0.6

      \[\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*2.4

      \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \color{blue}{\frac{\frac{t}{z \cdot 3}}{y}}\]
    4. Using strategy rm
    5. Applied associate-/r*2.4

      \[\leadsto \left(x - \color{blue}{\frac{\frac{y}{z}}{3}}\right) + \frac{\frac{t}{z \cdot 3}}{y}\]
    6. Taylor expanded around 0 0.7

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

    if -5.633804011750121e+26 < t < 2.4170814225561286e-32

    1. Initial program 6.1

      \[\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*1.3

      \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \color{blue}{\frac{\frac{t}{z \cdot 3}}{y}}\]
    4. Using strategy rm
    5. Applied associate-/r*1.3

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -5.63380401175012114 \cdot 10^{26} \lor \neg \left(t \le 2.41708142255612862 \cdot 10^{-32}\right):\\ \;\;\;\;\left(x - \frac{\frac{y}{z}}{3}\right) + 0.333333333333333315 \cdot \frac{t}{z \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{\frac{y}{z}}{3}\right) + \frac{1}{z} \cdot \frac{\frac{t}{3}}{y}\\ \end{array}\]

Reproduce

herbie shell --seed 2020036 +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))))