Average Error: 24.7 → 7.6
Time: 28.5s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;a \le -9.2070849134408133 \cdot 10^{-179} \lor \neg \left(a \le 1.3751750426910988 \cdot 10^{-213}\right):\\ \;\;\;\;t \cdot \frac{1}{\frac{a - z}{y - z}} + \mathsf{fma}\left(\frac{1}{\frac{a - z}{y - z}}, -x, x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(\frac{x}{z} - \frac{t}{z}\right) + t\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;a \le -9.2070849134408133 \cdot 10^{-179} \lor \neg \left(a \le 1.3751750426910988 \cdot 10^{-213}\right):\\
\;\;\;\;t \cdot \frac{1}{\frac{a - z}{y - z}} + \mathsf{fma}\left(\frac{1}{\frac{a - z}{y - z}}, -x, x\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r403073 = x;
        double r403074 = y;
        double r403075 = z;
        double r403076 = r403074 - r403075;
        double r403077 = t;
        double r403078 = r403077 - r403073;
        double r403079 = r403076 * r403078;
        double r403080 = a;
        double r403081 = r403080 - r403075;
        double r403082 = r403079 / r403081;
        double r403083 = r403073 + r403082;
        return r403083;
}

double f(double x, double y, double z, double t, double a) {
        double r403084 = a;
        double r403085 = -9.207084913440813e-179;
        bool r403086 = r403084 <= r403085;
        double r403087 = 1.3751750426910988e-213;
        bool r403088 = r403084 <= r403087;
        double r403089 = !r403088;
        bool r403090 = r403086 || r403089;
        double r403091 = t;
        double r403092 = 1.0;
        double r403093 = z;
        double r403094 = r403084 - r403093;
        double r403095 = y;
        double r403096 = r403095 - r403093;
        double r403097 = r403094 / r403096;
        double r403098 = r403092 / r403097;
        double r403099 = r403091 * r403098;
        double r403100 = x;
        double r403101 = -r403100;
        double r403102 = fma(r403098, r403101, r403100);
        double r403103 = r403099 + r403102;
        double r403104 = r403100 / r403093;
        double r403105 = r403091 / r403093;
        double r403106 = r403104 - r403105;
        double r403107 = r403095 * r403106;
        double r403108 = r403107 + r403091;
        double r403109 = r403090 ? r403103 : r403108;
        return r403109;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.7
Target12.1
Herbie7.6
\[\begin{array}{l} \mathbf{if}\;z \lt -1.25361310560950359 \cdot 10^{188}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \mathbf{elif}\;z \lt 4.44670236911381103 \cdot 10^{64}:\\ \;\;\;\;x + \frac{y - z}{\frac{a - z}{t - x}}\\ \mathbf{else}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if a < -9.207084913440813e-179 or 1.3751750426910988e-213 < a

    1. Initial program 23.6

      \[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
    2. Simplified10.4

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y - z}{a - z}, t - x, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef10.4

      \[\leadsto \color{blue}{\frac{y - z}{a - z} \cdot \left(t - x\right) + x}\]
    5. Using strategy rm
    6. Applied sub-neg10.4

      \[\leadsto \frac{y - z}{a - z} \cdot \color{blue}{\left(t + \left(-x\right)\right)} + x\]
    7. Applied distribute-rgt-in10.4

      \[\leadsto \color{blue}{\left(t \cdot \frac{y - z}{a - z} + \left(-x\right) \cdot \frac{y - z}{a - z}\right)} + x\]
    8. Applied associate-+l+7.2

      \[\leadsto \color{blue}{t \cdot \frac{y - z}{a - z} + \left(\left(-x\right) \cdot \frac{y - z}{a - z} + x\right)}\]
    9. Simplified7.2

      \[\leadsto t \cdot \frac{y - z}{a - z} + \color{blue}{\mathsf{fma}\left(\frac{y - z}{a - z}, -x, x\right)}\]
    10. Using strategy rm
    11. Applied clear-num7.2

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

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

    if -9.207084913440813e-179 < a < 1.3751750426910988e-213

    1. Initial program 30.6

      \[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
    2. Simplified21.9

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y - z}{a - z}, t - x, x\right)}\]
    3. Taylor expanded around inf 11.1

      \[\leadsto \color{blue}{\left(\frac{x \cdot y}{z} + t\right) - \frac{t \cdot y}{z}}\]
    4. Simplified9.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -9.2070849134408133 \cdot 10^{-179} \lor \neg \left(a \le 1.3751750426910988 \cdot 10^{-213}\right):\\ \;\;\;\;t \cdot \frac{1}{\frac{a - z}{y - z}} + \mathsf{fma}\left(\frac{1}{\frac{a - z}{y - z}}, -x, x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(\frac{x}{z} - \frac{t}{z}\right) + t\\ \end{array}\]

Reproduce

herbie shell --seed 2019199 +o rules:numerics
(FPCore (x y z t a)
  :name "Graphics.Rendering.Chart.Axis.Types:invLinMap from Chart-1.5.3"

  :herbie-target
  (if (< z -1.2536131056095036e+188) (- t (* (/ y z) (- t x))) (if (< z 4.446702369113811e+64) (+ x (/ (- y z) (/ (- a z) (- t x)))) (- t (* (/ y z) (- t x)))))

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