Average Error: 3.8 → 0.6
Time: 20.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}\;z \cdot 3 \le -282361661764429.625 \lor \neg \left(z \cdot 3 \le 3.074398170560975393827152030411223220276 \cdot 10^{-93}\right):\\ \;\;\;\;\left(x - \frac{0.3333333333333333148296162562473909929395}{\frac{z}{y}}\right) + \frac{t}{3 \cdot \left(y \cdot z\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y} \cdot \frac{1}{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 -282361661764429.625 \lor \neg \left(z \cdot 3 \le 3.074398170560975393827152030411223220276 \cdot 10^{-93}\right):\\
\;\;\;\;\left(x - \frac{0.3333333333333333148296162562473909929395}{\frac{z}{y}}\right) + \frac{t}{3 \cdot \left(y \cdot z\right)}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r490739 = x;
        double r490740 = y;
        double r490741 = z;
        double r490742 = 3.0;
        double r490743 = r490741 * r490742;
        double r490744 = r490740 / r490743;
        double r490745 = r490739 - r490744;
        double r490746 = t;
        double r490747 = r490743 * r490740;
        double r490748 = r490746 / r490747;
        double r490749 = r490745 + r490748;
        return r490749;
}

double f(double x, double y, double z, double t) {
        double r490750 = z;
        double r490751 = 3.0;
        double r490752 = r490750 * r490751;
        double r490753 = -282361661764429.6;
        bool r490754 = r490752 <= r490753;
        double r490755 = 3.0743981705609754e-93;
        bool r490756 = r490752 <= r490755;
        double r490757 = !r490756;
        bool r490758 = r490754 || r490757;
        double r490759 = x;
        double r490760 = 0.3333333333333333;
        double r490761 = y;
        double r490762 = r490750 / r490761;
        double r490763 = r490760 / r490762;
        double r490764 = r490759 - r490763;
        double r490765 = t;
        double r490766 = r490761 * r490750;
        double r490767 = r490751 * r490766;
        double r490768 = r490765 / r490767;
        double r490769 = r490764 + r490768;
        double r490770 = r490761 / r490752;
        double r490771 = r490759 - r490770;
        double r490772 = r490765 / r490761;
        double r490773 = 1.0;
        double r490774 = r490773 / r490752;
        double r490775 = r490772 * r490774;
        double r490776 = r490771 + r490775;
        double r490777 = r490758 ? r490769 : r490776;
        return r490777;
}

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.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) < -282361661764429.6 or 3.0743981705609754e-93 < (* z 3.0)

    1. Initial program 0.7

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

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

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

      \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(\color{blue}{{z}^{1}} \cdot {3}^{1}\right) \cdot {y}^{1}}\]
    6. Applied pow-prod-down0.7

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

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

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

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

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

    if -282361661764429.6 < (* z 3.0) < 3.0743981705609754e-93

    1. Initial program 12.3

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity12.3

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

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

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

Reproduce

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