Average Error: 3.7 → 0.4
Time: 13.8s
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 -15821052806207.40625:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, 0.3333333333333333148296162562473909929395 \cdot \frac{t}{z \cdot y}\right) + \mathsf{fma}\left(1, x, \frac{y}{3} \cdot \frac{-1}{z}\right)\\ \mathbf{elif}\;t \le 2285.050982389833734487183392047882080078:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{1}{z \cdot 3} \cdot \frac{t}{y}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{z \cdot \left(3 \cdot y\right)}\\ \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 -15821052806207.40625:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, 0.3333333333333333148296162562473909929395 \cdot \frac{t}{z \cdot y}\right) + \mathsf{fma}\left(1, x, \frac{y}{3} \cdot \frac{-1}{z}\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r467270 = x;
        double r467271 = y;
        double r467272 = z;
        double r467273 = 3.0;
        double r467274 = r467272 * r467273;
        double r467275 = r467271 / r467274;
        double r467276 = r467270 - r467275;
        double r467277 = t;
        double r467278 = r467274 * r467271;
        double r467279 = r467277 / r467278;
        double r467280 = r467276 + r467279;
        return r467280;
}

double f(double x, double y, double z, double t) {
        double r467281 = t;
        double r467282 = -15821052806207.406;
        bool r467283 = r467281 <= r467282;
        double r467284 = 1.0;
        double r467285 = z;
        double r467286 = r467284 / r467285;
        double r467287 = y;
        double r467288 = 3.0;
        double r467289 = r467287 / r467288;
        double r467290 = -r467289;
        double r467291 = r467290 + r467289;
        double r467292 = 0.3333333333333333;
        double r467293 = r467285 * r467287;
        double r467294 = r467281 / r467293;
        double r467295 = r467292 * r467294;
        double r467296 = fma(r467286, r467291, r467295);
        double r467297 = x;
        double r467298 = -1.0;
        double r467299 = r467298 / r467285;
        double r467300 = r467289 * r467299;
        double r467301 = fma(r467284, r467297, r467300);
        double r467302 = r467296 + r467301;
        double r467303 = 2285.0509823898337;
        bool r467304 = r467281 <= r467303;
        double r467305 = r467285 * r467288;
        double r467306 = r467287 / r467305;
        double r467307 = r467297 - r467306;
        double r467308 = r467284 / r467305;
        double r467309 = r467281 / r467287;
        double r467310 = r467308 * r467309;
        double r467311 = r467307 + r467310;
        double r467312 = r467288 * r467287;
        double r467313 = r467285 * r467312;
        double r467314 = r467281 / r467313;
        double r467315 = r467307 + r467314;
        double r467316 = r467304 ? r467311 : r467315;
        double r467317 = r467283 ? r467302 : r467316;
        return r467317;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original3.7
Target1.6
Herbie0.4
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y}\]

Derivation

  1. Split input into 3 regimes
  2. if t < -15821052806207.406

    1. Initial program 0.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*2.6

      \[\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-identity2.6

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

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

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

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(1, x, -\frac{y}{3} \cdot \frac{1}{z}\right) + \mathsf{fma}\left(-\frac{y}{3}, \frac{1}{z}, \frac{y}{3} \cdot \frac{1}{z}\right)\right)} + \frac{\frac{t}{z \cdot 3}}{y}\]
    9. Applied associate-+l+2.7

      \[\leadsto \color{blue}{\mathsf{fma}\left(1, x, -\frac{y}{3} \cdot \frac{1}{z}\right) + \left(\mathsf{fma}\left(-\frac{y}{3}, \frac{1}{z}, \frac{y}{3} \cdot \frac{1}{z}\right) + \frac{\frac{t}{z \cdot 3}}{y}\right)}\]
    10. Simplified2.7

      \[\leadsto \mathsf{fma}\left(1, x, -\frac{y}{3} \cdot \frac{1}{z}\right) + \color{blue}{\mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{\frac{t}{z \cdot 3}}{y}\right)}\]
    11. Taylor expanded around 0 0.9

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

    if -15821052806207.406 < t < 2285.0509823898337

    1. Initial program 5.7

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

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

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

    if 2285.0509823898337 < t

    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 associate-*l*0.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -15821052806207.40625:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, 0.3333333333333333148296162562473909929395 \cdot \frac{t}{z \cdot y}\right) + \mathsf{fma}\left(1, x, \frac{y}{3} \cdot \frac{-1}{z}\right)\\ \mathbf{elif}\;t \le 2285.050982389833734487183392047882080078:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{1}{z \cdot 3} \cdot \frac{t}{y}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{z \cdot \left(3 \cdot y\right)}\\ \end{array}\]

Reproduce

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