Average Error: 3.4 → 0.6
Time: 19.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 \cdot 3 \le -4.951281591912220767412188426238969967275 \cdot 10^{100} \lor \neg \left(z \cdot 3 \le 7.577309234972421914586172099876946403791 \cdot 10^{-42}\right):\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + t \cdot \frac{1}{\left(z \cdot 3\right) \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{\frac{y}{z}}{3}\right) + \frac{\frac{t}{y}}{z \cdot 3}\\ \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 -4.951281591912220767412188426238969967275 \cdot 10^{100} \lor \neg \left(z \cdot 3 \le 7.577309234972421914586172099876946403791 \cdot 10^{-42}\right):\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + t \cdot \frac{1}{\left(z \cdot 3\right) \cdot y}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r513060 = x;
        double r513061 = y;
        double r513062 = z;
        double r513063 = 3.0;
        double r513064 = r513062 * r513063;
        double r513065 = r513061 / r513064;
        double r513066 = r513060 - r513065;
        double r513067 = t;
        double r513068 = r513064 * r513061;
        double r513069 = r513067 / r513068;
        double r513070 = r513066 + r513069;
        return r513070;
}

double f(double x, double y, double z, double t) {
        double r513071 = z;
        double r513072 = 3.0;
        double r513073 = r513071 * r513072;
        double r513074 = -4.951281591912221e+100;
        bool r513075 = r513073 <= r513074;
        double r513076 = 7.577309234972422e-42;
        bool r513077 = r513073 <= r513076;
        double r513078 = !r513077;
        bool r513079 = r513075 || r513078;
        double r513080 = x;
        double r513081 = y;
        double r513082 = r513081 / r513073;
        double r513083 = r513080 - r513082;
        double r513084 = t;
        double r513085 = 1.0;
        double r513086 = r513073 * r513081;
        double r513087 = r513085 / r513086;
        double r513088 = r513084 * r513087;
        double r513089 = r513083 + r513088;
        double r513090 = r513081 / r513071;
        double r513091 = r513090 / r513072;
        double r513092 = r513080 - r513091;
        double r513093 = r513084 / r513081;
        double r513094 = r513093 / r513073;
        double r513095 = r513092 + r513094;
        double r513096 = r513079 ? r513089 : r513095;
        return r513096;
}

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.4
Target1.4
Herbie0.6
\[\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 3.0) < -4.951281591912221e+100 or 7.577309234972422e-42 < (* z 3.0)

    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 div-inv0.5

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

    if -4.951281591912221e+100 < (* z 3.0) < 7.577309234972422e-42

    1. Initial program 7.7

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt7.9

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

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

      \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \frac{\sqrt[3]{t} \cdot \sqrt[3]{t}}{z \cdot 3} \cdot \color{blue}{\left(\sqrt[3]{t} \cdot \frac{1}{y}\right)}\]
    7. Applied associate-*r*2.6

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

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

      \[\leadsto \left(x - \color{blue}{\frac{\frac{y}{z}}{3}}\right) + \frac{t}{z \cdot 3} \cdot \frac{1}{y}\]
    11. Using strategy rm
    12. Applied associate-*l/0.8

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

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

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

Reproduce

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