Average Error: 24.6 → 8.9
Time: 4.9s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -9.4142096943048169 \cdot 10^{-269} \lor \neg \left(x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 1.57255 \cdot 10^{-235}\right):\\ \;\;\;\;\mathsf{fma}\left({\left(\frac{y - z}{a - z}\right)}^{1}, t - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -9.4142096943048169 \cdot 10^{-269} \lor \neg \left(x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 1.57255 \cdot 10^{-235}\right):\\
\;\;\;\;\mathsf{fma}\left({\left(\frac{y - z}{a - z}\right)}^{1}, t - x, x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r696773 = x;
        double r696774 = y;
        double r696775 = z;
        double r696776 = r696774 - r696775;
        double r696777 = t;
        double r696778 = r696777 - r696773;
        double r696779 = r696776 * r696778;
        double r696780 = a;
        double r696781 = r696780 - r696775;
        double r696782 = r696779 / r696781;
        double r696783 = r696773 + r696782;
        return r696783;
}

double f(double x, double y, double z, double t, double a) {
        double r696784 = x;
        double r696785 = y;
        double r696786 = z;
        double r696787 = r696785 - r696786;
        double r696788 = t;
        double r696789 = r696788 - r696784;
        double r696790 = r696787 * r696789;
        double r696791 = a;
        double r696792 = r696791 - r696786;
        double r696793 = r696790 / r696792;
        double r696794 = r696784 + r696793;
        double r696795 = -9.414209694304817e-269;
        bool r696796 = r696794 <= r696795;
        double r696797 = 1.5725460863274251e-235;
        bool r696798 = r696794 <= r696797;
        double r696799 = !r696798;
        bool r696800 = r696796 || r696799;
        double r696801 = r696787 / r696792;
        double r696802 = 1.0;
        double r696803 = pow(r696801, r696802);
        double r696804 = fma(r696803, r696789, r696784);
        double r696805 = r696784 / r696786;
        double r696806 = r696788 / r696786;
        double r696807 = r696805 - r696806;
        double r696808 = fma(r696785, r696807, r696788);
        double r696809 = r696800 ? r696804 : r696808;
        return r696809;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.6
Target12.0
Herbie8.9
\[\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 (+ x (/ (* (- y z) (- t x)) (- a z))) < -9.414209694304817e-269 or 1.5725460863274251e-235 < (+ x (/ (* (- y z) (- t x)) (- a z)))

    1. Initial program 21.4

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(y - z\right) \cdot \frac{1}{a - z}}, t - x, x\right)\]
    5. Using strategy rm
    6. Applied pow17.1

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(y - z\right)}^{1}} \cdot {\left(\frac{1}{a - z}\right)}^{1}, t - x, x\right)\]
    8. Applied pow-prod-down7.1

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

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

    if -9.414209694304817e-269 < (+ x (/ (* (- y z) (- t x)) (- a z))) < 1.5725460863274251e-235

    1. Initial program 52.2

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification8.9

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

Reproduce

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

  :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))))