Average Error: 7.4 → 0.7
Time: 9.4s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t = -\infty \lor \neg \left(x \cdot y - z \cdot t \le 1.8044303056911245 \cdot 10^{305}\right):\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{z}{\sqrt[3]{a}}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y - z \cdot t\right) \cdot \frac{1}{a}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t = -\infty \lor \neg \left(x \cdot y - z \cdot t \le 1.8044303056911245 \cdot 10^{305}\right):\\
\;\;\;\;x \cdot \frac{y}{a} - \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{z}{\sqrt[3]{a}}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r859012 = x;
        double r859013 = y;
        double r859014 = r859012 * r859013;
        double r859015 = z;
        double r859016 = t;
        double r859017 = r859015 * r859016;
        double r859018 = r859014 - r859017;
        double r859019 = a;
        double r859020 = r859018 / r859019;
        return r859020;
}

double f(double x, double y, double z, double t, double a) {
        double r859021 = x;
        double r859022 = y;
        double r859023 = r859021 * r859022;
        double r859024 = z;
        double r859025 = t;
        double r859026 = r859024 * r859025;
        double r859027 = r859023 - r859026;
        double r859028 = -inf.0;
        bool r859029 = r859027 <= r859028;
        double r859030 = 1.8044303056911245e+305;
        bool r859031 = r859027 <= r859030;
        double r859032 = !r859031;
        bool r859033 = r859029 || r859032;
        double r859034 = a;
        double r859035 = r859022 / r859034;
        double r859036 = r859021 * r859035;
        double r859037 = cbrt(r859034);
        double r859038 = r859037 * r859037;
        double r859039 = r859025 / r859038;
        double r859040 = r859024 / r859037;
        double r859041 = r859039 * r859040;
        double r859042 = r859036 - r859041;
        double r859043 = 1.0;
        double r859044 = r859043 / r859034;
        double r859045 = r859027 * r859044;
        double r859046 = r859033 ? r859042 : r859045;
        return r859046;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.4
Target6.0
Herbie0.7
\[\begin{array}{l} \mathbf{if}\;z \lt -2.46868496869954822 \cdot 10^{170}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \mathbf{elif}\;z \lt 6.30983112197837121 \cdot 10^{-71}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (- (* x y) (* z t)) < -inf.0 or 1.8044303056911245e+305 < (- (* x y) (* z t))

    1. Initial program 63.0

      \[\frac{x \cdot y - z \cdot t}{a}\]
    2. Using strategy rm
    3. Applied div-sub63.0

      \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}}\]
    4. Simplified63.0

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{t \cdot z}{a}}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt63.0

      \[\leadsto \frac{x \cdot y}{a} - \frac{t \cdot z}{\color{blue}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}}\]
    7. Applied times-frac33.8

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{z}{\sqrt[3]{a}}}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity33.8

      \[\leadsto \frac{x \cdot y}{\color{blue}{1 \cdot a}} - \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{z}{\sqrt[3]{a}}\]
    10. Applied times-frac0.8

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y}{a}} - \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{z}{\sqrt[3]{a}}\]
    11. Simplified0.8

      \[\leadsto \color{blue}{x} \cdot \frac{y}{a} - \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{z}{\sqrt[3]{a}}\]

    if -inf.0 < (- (* x y) (* z t)) < 1.8044303056911245e+305

    1. Initial program 0.6

      \[\frac{x \cdot y - z \cdot t}{a}\]
    2. Using strategy rm
    3. Applied div-inv0.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t = -\infty \lor \neg \left(x \cdot y - z \cdot t \le 1.8044303056911245 \cdot 10^{305}\right):\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{z}{\sqrt[3]{a}}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y - z \cdot t\right) \cdot \frac{1}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020043 +o rules:numerics
(FPCore (x y z t a)
  :name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
  :precision binary64

  :herbie-target
  (if (< z -2.468684968699548e+170) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z))))

  (/ (- (* x y) (* z t)) a))