Average Error: 3.8 → 0.8
Time: 20.3s
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 r507198 = x;
        double r507199 = y;
        double r507200 = z;
        double r507201 = 3.0;
        double r507202 = r507200 * r507201;
        double r507203 = r507199 / r507202;
        double r507204 = r507198 - r507203;
        double r507205 = t;
        double r507206 = r507202 * r507199;
        double r507207 = r507205 / r507206;
        double r507208 = r507204 + r507207;
        return r507208;
}

double f(double x, double y, double z, double t) {
        double r507209 = z;
        double r507210 = 3.0;
        double r507211 = r507209 * r507210;
        double r507212 = -5.208058459313365e-09;
        bool r507213 = r507211 <= r507212;
        double r507214 = x;
        double r507215 = y;
        double r507216 = r507215 / r507211;
        double r507217 = r507214 - r507216;
        double r507218 = t;
        double r507219 = 1.0;
        double r507220 = r507219 / r507211;
        double r507221 = r507220 / r507215;
        double r507222 = r507218 * r507221;
        double r507223 = r507217 + r507222;
        double r507224 = 2.326106448978872e-111;
        bool r507225 = r507211 <= r507224;
        double r507226 = r507219 / r507209;
        double r507227 = r507218 / r507210;
        double r507228 = r507227 / r507215;
        double r507229 = r507226 * r507228;
        double r507230 = r507217 + r507229;
        double r507231 = r507215 * r507220;
        double r507232 = r507214 - r507231;
        double r507233 = r507218 / r507211;
        double r507234 = r507233 / r507215;
        double r507235 = r507232 + r507234;
        double r507236 = r507225 ? r507230 : r507235;
        double r507237 = r507213 ? r507223 : r507236;
        return r507237;
}

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 
(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))))