Average Error: 3.8 → 0.8
Time: 21.1s
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 \cdot 3 \le -5.2080584593133653 \cdot 10^{-9}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + t \cdot \frac{\frac{1}{z \cdot 3}}{y}\\ \mathbf{elif}\;z \cdot 3 \le 2.3261064489788719 \cdot 10^{-111}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{1}{z} \cdot \frac{\frac{t}{3}}{y}\\ \mathbf{else}:\\ \;\;\;\;\left(x - y \cdot \frac{1}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 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}\;z \cdot 3 \le -5.2080584593133653 \cdot 10^{-9}:\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + t \cdot \frac{\frac{1}{z \cdot 3}}{y}\\

\mathbf{elif}\;z \cdot 3 \le 2.3261064489788719 \cdot 10^{-111}:\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{1}{z} \cdot \frac{\frac{t}{3}}{y}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r486764 = x;
        double r486765 = y;
        double r486766 = z;
        double r486767 = 3.0;
        double r486768 = r486766 * r486767;
        double r486769 = r486765 / r486768;
        double r486770 = r486764 - r486769;
        double r486771 = t;
        double r486772 = r486768 * r486765;
        double r486773 = r486771 / r486772;
        double r486774 = r486770 + r486773;
        return r486774;
}

double f(double x, double y, double z, double t) {
        double r486775 = z;
        double r486776 = 3.0;
        double r486777 = r486775 * r486776;
        double r486778 = -5.208058459313365e-09;
        bool r486779 = r486777 <= r486778;
        double r486780 = x;
        double r486781 = y;
        double r486782 = r486781 / r486777;
        double r486783 = r486780 - r486782;
        double r486784 = t;
        double r486785 = 1.0;
        double r486786 = r486785 / r486777;
        double r486787 = r486786 / r486781;
        double r486788 = r486784 * r486787;
        double r486789 = r486783 + r486788;
        double r486790 = 2.326106448978872e-111;
        bool r486791 = r486777 <= r486790;
        double r486792 = r486785 / r486775;
        double r486793 = r486784 / r486776;
        double r486794 = r486793 / r486781;
        double r486795 = r486792 * r486794;
        double r486796 = r486783 + r486795;
        double r486797 = r486781 * r486786;
        double r486798 = r486780 - r486797;
        double r486799 = r486784 / r486777;
        double r486800 = r486799 / r486781;
        double r486801 = r486798 + r486800;
        double r486802 = r486791 ? r486796 : r486801;
        double r486803 = r486779 ? r486789 : r486802;
        return r486803;
}

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

Derivation

  1. Split input into 3 regimes
  2. if (* z 3.0) < -5.208058459313365e-09

    1. Initial program 0.4

      \[\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.9

      \[\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-identity0.9

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

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

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

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

    if -5.208058459313365e-09 < (* z 3.0) < 2.326106448978872e-111

    1. Initial program 13.8

      \[\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.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 *-un-lft-identity3.3

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

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

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

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

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

    if 2.326106448978872e-111 < (* z 3.0)

    1. Initial program 0.9

      \[\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.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot 3 \le -5.2080584593133653 \cdot 10^{-9}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + t \cdot \frac{\frac{1}{z \cdot 3}}{y}\\ \mathbf{elif}\;z \cdot 3 \le 2.3261064489788719 \cdot 10^{-111}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{1}{z} \cdot \frac{\frac{t}{3}}{y}\\ \mathbf{else}:\\ \;\;\;\;\left(x - y \cdot \frac{1}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y}\\ \end{array}\]

Reproduce

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

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

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