Average Error: 24.6 → 10.0
Time: 6.3s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.2165983826730228 \cdot 10^{246} \lor \neg \left(z \le 9.10019436889470365 \cdot 10^{191}\right):\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t - x}{\frac{a - z}{y - z}} + x\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;z \le -3.2165983826730228 \cdot 10^{246} \lor \neg \left(z \le 9.10019436889470365 \cdot 10^{191}\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{t - x}{\frac{a - z}{y - z}} + x\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r602740 = x;
        double r602741 = y;
        double r602742 = z;
        double r602743 = r602741 - r602742;
        double r602744 = t;
        double r602745 = r602744 - r602740;
        double r602746 = r602743 * r602745;
        double r602747 = a;
        double r602748 = r602747 - r602742;
        double r602749 = r602746 / r602748;
        double r602750 = r602740 + r602749;
        return r602750;
}

double f(double x, double y, double z, double t, double a) {
        double r602751 = z;
        double r602752 = -3.216598382673023e+246;
        bool r602753 = r602751 <= r602752;
        double r602754 = 9.100194368894704e+191;
        bool r602755 = r602751 <= r602754;
        double r602756 = !r602755;
        bool r602757 = r602753 || r602756;
        double r602758 = y;
        double r602759 = x;
        double r602760 = r602759 / r602751;
        double r602761 = t;
        double r602762 = r602761 / r602751;
        double r602763 = r602760 - r602762;
        double r602764 = fma(r602758, r602763, r602761);
        double r602765 = r602761 - r602759;
        double r602766 = a;
        double r602767 = r602766 - r602751;
        double r602768 = r602758 - r602751;
        double r602769 = r602767 / r602768;
        double r602770 = r602765 / r602769;
        double r602771 = r602770 + r602759;
        double r602772 = r602757 ? r602764 : r602771;
        return r602772;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.6
Target11.5
Herbie10.0
\[\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 z < -3.216598382673023e+246 or 9.100194368894704e+191 < z

    1. Initial program 50.3

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

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

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

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

    if -3.216598382673023e+246 < z < 9.100194368894704e+191

    1. Initial program 19.6

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a - z}{y - z}} \cdot \left(t - x\right) + x}\]
    7. Simplified9.3

      \[\leadsto \color{blue}{\frac{t - x}{\frac{a - z}{y - z}}} + x\]
  3. Recombined 2 regimes into one program.
  4. Final simplification10.0

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

Reproduce

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