Average Error: 3.5 → 1.3
Time: 5.2s
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 \le -3.40096777770621427 \cdot 10^{158}:\\ \;\;\;\;\mathsf{fma}\left(1, x, -0.333333333333333315 \cdot \frac{y}{z}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{\frac{t}{z \cdot 3}}{y}\right)\\ \mathbf{elif}\;z \le 5.541098349876343 \cdot 10^{-21}:\\ \;\;\;\;\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}, \frac{1}{z} \cdot \frac{\frac{t}{3}}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{\frac{y}{z}}{3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot 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 \le -3.40096777770621427 \cdot 10^{158}:\\
\;\;\;\;\mathsf{fma}\left(1, x, -0.333333333333333315 \cdot \frac{y}{z}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{\frac{t}{z \cdot 3}}{y}\right)\\

\mathbf{elif}\;z \le 5.541098349876343 \cdot 10^{-21}:\\
\;\;\;\;\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}, \frac{1}{z} \cdot \frac{\frac{t}{3}}{y}\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r798187 = x;
        double r798188 = y;
        double r798189 = z;
        double r798190 = 3.0;
        double r798191 = r798189 * r798190;
        double r798192 = r798188 / r798191;
        double r798193 = r798187 - r798192;
        double r798194 = t;
        double r798195 = r798191 * r798188;
        double r798196 = r798194 / r798195;
        double r798197 = r798193 + r798196;
        return r798197;
}

double f(double x, double y, double z, double t) {
        double r798198 = z;
        double r798199 = -3.4009677777062143e+158;
        bool r798200 = r798198 <= r798199;
        double r798201 = 1.0;
        double r798202 = x;
        double r798203 = 0.3333333333333333;
        double r798204 = y;
        double r798205 = r798204 / r798198;
        double r798206 = r798203 * r798205;
        double r798207 = -r798206;
        double r798208 = fma(r798201, r798202, r798207);
        double r798209 = r798201 / r798198;
        double r798210 = 3.0;
        double r798211 = r798204 / r798210;
        double r798212 = -r798211;
        double r798213 = r798212 + r798211;
        double r798214 = t;
        double r798215 = r798198 * r798210;
        double r798216 = r798214 / r798215;
        double r798217 = r798216 / r798204;
        double r798218 = fma(r798209, r798213, r798217);
        double r798219 = r798208 + r798218;
        double r798220 = 5.541098349876343e-21;
        bool r798221 = r798198 <= r798220;
        double r798222 = r798211 * r798209;
        double r798223 = -r798222;
        double r798224 = fma(r798201, r798202, r798223);
        double r798225 = r798214 / r798210;
        double r798226 = r798225 / r798204;
        double r798227 = r798209 * r798226;
        double r798228 = fma(r798209, r798213, r798227);
        double r798229 = r798224 + r798228;
        double r798230 = r798205 / r798210;
        double r798231 = r798202 - r798230;
        double r798232 = r798215 * r798204;
        double r798233 = r798214 / r798232;
        double r798234 = r798231 + r798233;
        double r798235 = r798221 ? r798229 : r798234;
        double r798236 = r798200 ? r798219 : r798235;
        return r798236;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original3.5
Target1.7
Herbie1.3
\[\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.4009677777062143e+158

    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 associate-/r*1.4

      \[\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-identity1.4

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

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

      \[\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-diff1.4

      \[\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+1.4

      \[\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. Simplified1.4

      \[\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 1.5

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

    if -3.4009677777062143e+158 < z < 5.541098349876343e-21

    1. Initial program 6.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*2.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-identity2.3

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

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

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

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

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

      \[\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. Using strategy rm
    12. Applied *-un-lft-identity2.4

      \[\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}, \frac{\frac{t}{z \cdot 3}}{\color{blue}{1 \cdot y}}\right)\]
    13. Applied *-un-lft-identity2.4

      \[\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}, \frac{\frac{\color{blue}{1 \cdot t}}{z \cdot 3}}{1 \cdot y}\right)\]
    14. Applied times-frac2.4

      \[\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}, \frac{\color{blue}{\frac{1}{z} \cdot \frac{t}{3}}}{1 \cdot y}\right)\]
    15. Applied times-frac2.0

      \[\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}{\frac{\frac{1}{z}}{1} \cdot \frac{\frac{t}{3}}{y}}\right)\]
    16. Simplified2.0

      \[\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}{\frac{1}{z}} \cdot \frac{\frac{t}{3}}{y}\right)\]

    if 5.541098349876343e-21 < z

    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.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -3.40096777770621427 \cdot 10^{158}:\\ \;\;\;\;\mathsf{fma}\left(1, x, -0.333333333333333315 \cdot \frac{y}{z}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{\frac{t}{z \cdot 3}}{y}\right)\\ \mathbf{elif}\;z \le 5.541098349876343 \cdot 10^{-21}:\\ \;\;\;\;\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}, \frac{1}{z} \cdot \frac{\frac{t}{3}}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{\frac{y}{z}}{3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \end{array}\]

Reproduce

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