Average Error: 3.8 → 1.1
Time: 24.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 -4.502749454027008170957276628426245652531 \cdot 10^{-149}:\\ \;\;\;\;\mathsf{fma}\left(0.3333333333333333148296162562473909929395, \frac{t}{y \cdot z} - \frac{y}{z}, x\right)\\ \mathbf{elif}\;z \cdot 3 \le 1.793502083090020071754782731555646800707 \cdot 10^{-49}:\\ \;\;\;\;\left(\left(\frac{y}{z \cdot 3} + \mathsf{fma}\left(-\frac{1}{z \cdot 3}, y, y \cdot \frac{1}{z \cdot 3}\right)\right) + \mathsf{fma}\left(\frac{1}{z}, \frac{\frac{t}{3}}{y}, \left(-y\right) \cdot \frac{1}{z \cdot 3}\right)\right) + \mathsf{fma}\left(1, x, \left(\sqrt[3]{\frac{y}{z \cdot 3}} \cdot \sqrt[3]{\frac{y}{z \cdot 3}}\right) \cdot \left(\sqrt[3]{\frac{y}{3}} \cdot \left(-\sqrt[3]{\frac{1}{z}}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(y \cdot z\right) \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.502749454027008170957276628426245652531 \cdot 10^{-149}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333148296162562473909929395, \frac{t}{y \cdot z} - \frac{y}{z}, x\right)\\

\mathbf{elif}\;z \cdot 3 \le 1.793502083090020071754782731555646800707 \cdot 10^{-49}:\\
\;\;\;\;\left(\left(\frac{y}{z \cdot 3} + \mathsf{fma}\left(-\frac{1}{z \cdot 3}, y, y \cdot \frac{1}{z \cdot 3}\right)\right) + \mathsf{fma}\left(\frac{1}{z}, \frac{\frac{t}{3}}{y}, \left(-y\right) \cdot \frac{1}{z \cdot 3}\right)\right) + \mathsf{fma}\left(1, x, \left(\sqrt[3]{\frac{y}{z \cdot 3}} \cdot \sqrt[3]{\frac{y}{z \cdot 3}}\right) \cdot \left(\sqrt[3]{\frac{y}{3}} \cdot \left(-\sqrt[3]{\frac{1}{z}}\right)\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r32526666 = x;
        double r32526667 = y;
        double r32526668 = z;
        double r32526669 = 3.0;
        double r32526670 = r32526668 * r32526669;
        double r32526671 = r32526667 / r32526670;
        double r32526672 = r32526666 - r32526671;
        double r32526673 = t;
        double r32526674 = r32526670 * r32526667;
        double r32526675 = r32526673 / r32526674;
        double r32526676 = r32526672 + r32526675;
        return r32526676;
}

double f(double x, double y, double z, double t) {
        double r32526677 = z;
        double r32526678 = 3.0;
        double r32526679 = r32526677 * r32526678;
        double r32526680 = -4.502749454027008e-149;
        bool r32526681 = r32526679 <= r32526680;
        double r32526682 = 0.3333333333333333;
        double r32526683 = t;
        double r32526684 = y;
        double r32526685 = r32526684 * r32526677;
        double r32526686 = r32526683 / r32526685;
        double r32526687 = r32526684 / r32526677;
        double r32526688 = r32526686 - r32526687;
        double r32526689 = x;
        double r32526690 = fma(r32526682, r32526688, r32526689);
        double r32526691 = 1.79350208309002e-49;
        bool r32526692 = r32526679 <= r32526691;
        double r32526693 = r32526684 / r32526679;
        double r32526694 = 1.0;
        double r32526695 = r32526694 / r32526679;
        double r32526696 = -r32526695;
        double r32526697 = r32526684 * r32526695;
        double r32526698 = fma(r32526696, r32526684, r32526697);
        double r32526699 = r32526693 + r32526698;
        double r32526700 = r32526694 / r32526677;
        double r32526701 = r32526683 / r32526678;
        double r32526702 = r32526701 / r32526684;
        double r32526703 = -r32526684;
        double r32526704 = r32526703 * r32526695;
        double r32526705 = fma(r32526700, r32526702, r32526704);
        double r32526706 = r32526699 + r32526705;
        double r32526707 = cbrt(r32526693);
        double r32526708 = r32526707 * r32526707;
        double r32526709 = r32526684 / r32526678;
        double r32526710 = cbrt(r32526709);
        double r32526711 = cbrt(r32526700);
        double r32526712 = -r32526711;
        double r32526713 = r32526710 * r32526712;
        double r32526714 = r32526708 * r32526713;
        double r32526715 = fma(r32526694, r32526689, r32526714);
        double r32526716 = r32526706 + r32526715;
        double r32526717 = r32526689 - r32526693;
        double r32526718 = r32526685 * r32526678;
        double r32526719 = r32526683 / r32526718;
        double r32526720 = r32526717 + r32526719;
        double r32526721 = r32526692 ? r32526716 : r32526720;
        double r32526722 = r32526681 ? r32526690 : r32526721;
        return r32526722;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original3.8
Target1.9
Herbie1.1
\[\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) < -4.502749454027008e-149

    1. Initial program 1.7

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    2. Taylor expanded around 0 1.8

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

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

    if -4.502749454027008e-149 < (* z 3.0) < 1.79350208309002e-49

    1. Initial program 15.9

      \[\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-cbrt16.3

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

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

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

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

      \[\leadsto \mathsf{fma}\left(1, x, -\sqrt[3]{\frac{y}{z \cdot 3}} \cdot \left(\sqrt[3]{\frac{y}{z \cdot 3}} \cdot \sqrt[3]{\frac{y}{z \cdot 3}}\right)\right) + \color{blue}{\left(\left(\frac{\frac{t}{z \cdot 3}}{y} - \frac{y}{z \cdot 3}\right) + \frac{y}{z \cdot 3}\right)}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity4.4

      \[\leadsto \mathsf{fma}\left(1, x, -\sqrt[3]{\frac{\color{blue}{1 \cdot y}}{z \cdot 3}} \cdot \left(\sqrt[3]{\frac{y}{z \cdot 3}} \cdot \sqrt[3]{\frac{y}{z \cdot 3}}\right)\right) + \left(\left(\frac{\frac{t}{z \cdot 3}}{y} - \frac{y}{z \cdot 3}\right) + \frac{y}{z \cdot 3}\right)\]
    10. Applied times-frac4.4

      \[\leadsto \mathsf{fma}\left(1, x, -\sqrt[3]{\color{blue}{\frac{1}{z} \cdot \frac{y}{3}}} \cdot \left(\sqrt[3]{\frac{y}{z \cdot 3}} \cdot \sqrt[3]{\frac{y}{z \cdot 3}}\right)\right) + \left(\left(\frac{\frac{t}{z \cdot 3}}{y} - \frac{y}{z \cdot 3}\right) + \frac{y}{z \cdot 3}\right)\]
    11. Applied cbrt-prod4.4

      \[\leadsto \mathsf{fma}\left(1, x, -\color{blue}{\left(\sqrt[3]{\frac{1}{z}} \cdot \sqrt[3]{\frac{y}{3}}\right)} \cdot \left(\sqrt[3]{\frac{y}{z \cdot 3}} \cdot \sqrt[3]{\frac{y}{z \cdot 3}}\right)\right) + \left(\left(\frac{\frac{t}{z \cdot 3}}{y} - \frac{y}{z \cdot 3}\right) + \frac{y}{z \cdot 3}\right)\]
    12. Using strategy rm
    13. Applied div-inv4.4

      \[\leadsto \mathsf{fma}\left(1, x, -\left(\sqrt[3]{\frac{1}{z}} \cdot \sqrt[3]{\frac{y}{3}}\right) \cdot \left(\sqrt[3]{\frac{y}{z \cdot 3}} \cdot \sqrt[3]{\frac{y}{z \cdot 3}}\right)\right) + \left(\left(\frac{\frac{t}{z \cdot 3}}{y} - \color{blue}{y \cdot \frac{1}{z \cdot 3}}\right) + \frac{y}{z \cdot 3}\right)\]
    14. Applied *-un-lft-identity4.4

      \[\leadsto \mathsf{fma}\left(1, x, -\left(\sqrt[3]{\frac{1}{z}} \cdot \sqrt[3]{\frac{y}{3}}\right) \cdot \left(\sqrt[3]{\frac{y}{z \cdot 3}} \cdot \sqrt[3]{\frac{y}{z \cdot 3}}\right)\right) + \left(\left(\frac{\frac{t}{z \cdot 3}}{\color{blue}{1 \cdot y}} - y \cdot \frac{1}{z \cdot 3}\right) + \frac{y}{z \cdot 3}\right)\]
    15. Applied *-un-lft-identity4.4

      \[\leadsto \mathsf{fma}\left(1, x, -\left(\sqrt[3]{\frac{1}{z}} \cdot \sqrt[3]{\frac{y}{3}}\right) \cdot \left(\sqrt[3]{\frac{y}{z \cdot 3}} \cdot \sqrt[3]{\frac{y}{z \cdot 3}}\right)\right) + \left(\left(\frac{\frac{\color{blue}{1 \cdot t}}{z \cdot 3}}{1 \cdot y} - y \cdot \frac{1}{z \cdot 3}\right) + \frac{y}{z \cdot 3}\right)\]
    16. Applied times-frac4.4

      \[\leadsto \mathsf{fma}\left(1, x, -\left(\sqrt[3]{\frac{1}{z}} \cdot \sqrt[3]{\frac{y}{3}}\right) \cdot \left(\sqrt[3]{\frac{y}{z \cdot 3}} \cdot \sqrt[3]{\frac{y}{z \cdot 3}}\right)\right) + \left(\left(\frac{\color{blue}{\frac{1}{z} \cdot \frac{t}{3}}}{1 \cdot y} - y \cdot \frac{1}{z \cdot 3}\right) + \frac{y}{z \cdot 3}\right)\]
    17. Applied times-frac0.7

      \[\leadsto \mathsf{fma}\left(1, x, -\left(\sqrt[3]{\frac{1}{z}} \cdot \sqrt[3]{\frac{y}{3}}\right) \cdot \left(\sqrt[3]{\frac{y}{z \cdot 3}} \cdot \sqrt[3]{\frac{y}{z \cdot 3}}\right)\right) + \left(\left(\color{blue}{\frac{\frac{1}{z}}{1} \cdot \frac{\frac{t}{3}}{y}} - y \cdot \frac{1}{z \cdot 3}\right) + \frac{y}{z \cdot 3}\right)\]
    18. Applied prod-diff0.7

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

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

    if 1.79350208309002e-49 < (* 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. Taylor expanded around 0 0.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot 3 \le -4.502749454027008170957276628426245652531 \cdot 10^{-149}:\\ \;\;\;\;\mathsf{fma}\left(0.3333333333333333148296162562473909929395, \frac{t}{y \cdot z} - \frac{y}{z}, x\right)\\ \mathbf{elif}\;z \cdot 3 \le 1.793502083090020071754782731555646800707 \cdot 10^{-49}:\\ \;\;\;\;\left(\left(\frac{y}{z \cdot 3} + \mathsf{fma}\left(-\frac{1}{z \cdot 3}, y, y \cdot \frac{1}{z \cdot 3}\right)\right) + \mathsf{fma}\left(\frac{1}{z}, \frac{\frac{t}{3}}{y}, \left(-y\right) \cdot \frac{1}{z \cdot 3}\right)\right) + \mathsf{fma}\left(1, x, \left(\sqrt[3]{\frac{y}{z \cdot 3}} \cdot \sqrt[3]{\frac{y}{z \cdot 3}}\right) \cdot \left(\sqrt[3]{\frac{y}{3}} \cdot \left(-\sqrt[3]{\frac{1}{z}}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(y \cdot z\right) \cdot 3}\\ \end{array}\]

Reproduce

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