Average Error: 1.7 → 0.2
Time: 3.9s
Precision: 64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \le -3.141065750945845758760211222436365665667 \cdot 10^{-15} \lor \neg \left(x \le 4.40041470183000606091280929473849033149 \cdot 10^{-62}\right):\\ \;\;\;\;\left|\frac{x + 4}{y} - {\left(x \cdot \frac{z}{y}\right)}^{1}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \end{array}\]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
\mathbf{if}\;x \le -3.141065750945845758760211222436365665667 \cdot 10^{-15} \lor \neg \left(x \le 4.40041470183000606091280929473849033149 \cdot 10^{-62}\right):\\
\;\;\;\;\left|\frac{x + 4}{y} - {\left(x \cdot \frac{z}{y}\right)}^{1}\right|\\

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

\end{array}
double f(double x, double y, double z) {
        double r31622 = x;
        double r31623 = 4.0;
        double r31624 = r31622 + r31623;
        double r31625 = y;
        double r31626 = r31624 / r31625;
        double r31627 = r31622 / r31625;
        double r31628 = z;
        double r31629 = r31627 * r31628;
        double r31630 = r31626 - r31629;
        double r31631 = fabs(r31630);
        return r31631;
}

double f(double x, double y, double z) {
        double r31632 = x;
        double r31633 = -3.1410657509458458e-15;
        bool r31634 = r31632 <= r31633;
        double r31635 = 4.400414701830006e-62;
        bool r31636 = r31632 <= r31635;
        double r31637 = !r31636;
        bool r31638 = r31634 || r31637;
        double r31639 = 4.0;
        double r31640 = r31632 + r31639;
        double r31641 = y;
        double r31642 = r31640 / r31641;
        double r31643 = z;
        double r31644 = r31643 / r31641;
        double r31645 = r31632 * r31644;
        double r31646 = 1.0;
        double r31647 = pow(r31645, r31646);
        double r31648 = r31642 - r31647;
        double r31649 = fabs(r31648);
        double r31650 = r31632 * r31643;
        double r31651 = r31640 - r31650;
        double r31652 = r31651 / r31641;
        double r31653 = fabs(r31652);
        double r31654 = r31638 ? r31649 : r31653;
        return r31654;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if x < -3.1410657509458458e-15 or 4.400414701830006e-62 < x

    1. Initial program 0.2

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Using strategy rm
    3. Applied *-un-lft-identity0.2

      \[\leadsto \left|\frac{x + 4}{y} - \frac{x}{\color{blue}{1 \cdot y}} \cdot z\right|\]
    4. Applied add-cube-cbrt0.6

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

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\left(\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{1} \cdot \frac{\sqrt[3]{x}}{y}\right)} \cdot z\right|\]
    6. Applied associate-*l*0.7

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{1} \cdot \left(\frac{\sqrt[3]{x}}{y} \cdot z\right)}\right|\]
    7. Using strategy rm
    8. Applied pow10.7

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

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

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

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

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{{\left(\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{1} \cdot \left(\frac{\sqrt[3]{x}}{y} \cdot z\right)\right)}^{1}}\right|\]
    13. Simplified0.3

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

    if -3.1410657509458458e-15 < x < 4.400414701830006e-62

    1. Initial program 2.9

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Using strategy rm
    3. Applied associate-*l/0.1

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right|\]
    4. Applied sub-div0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -3.141065750945845758760211222436365665667 \cdot 10^{-15} \lor \neg \left(x \le 4.40041470183000606091280929473849033149 \cdot 10^{-62}\right):\\ \;\;\;\;\left|\frac{x + 4}{y} - {\left(x \cdot \frac{z}{y}\right)}^{1}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \end{array}\]

Reproduce

herbie shell --seed 2020001 +o rules:numerics
(FPCore (x y z)
  :name "fabs fraction 1"
  :precision binary64
  (fabs (- (/ (+ x 4) y) (* (/ x y) z))))