Average Error: 23.8 → 10.1
Time: 24.5s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;a \le -9.775356164441544470158858032480564423106 \cdot 10^{-50} \lor \neg \left(a \le 2.555615459190409481576440428568032248898 \cdot 10^{-179}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{a - z} \cdot \left(y - z\right), t - 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.775356164441544470158858032480564423106 \cdot 10^{-50} \lor \neg \left(a \le 2.555615459190409481576440428568032248898 \cdot 10^{-179}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{a - z} \cdot \left(y - z\right), t - 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 r418035 = x;
        double r418036 = y;
        double r418037 = z;
        double r418038 = r418036 - r418037;
        double r418039 = t;
        double r418040 = r418039 - r418035;
        double r418041 = r418038 * r418040;
        double r418042 = a;
        double r418043 = r418042 - r418037;
        double r418044 = r418041 / r418043;
        double r418045 = r418035 + r418044;
        return r418045;
}

double f(double x, double y, double z, double t, double a) {
        double r418046 = a;
        double r418047 = -9.775356164441544e-50;
        bool r418048 = r418046 <= r418047;
        double r418049 = 2.5556154591904095e-179;
        bool r418050 = r418046 <= r418049;
        double r418051 = !r418050;
        bool r418052 = r418048 || r418051;
        double r418053 = 1.0;
        double r418054 = z;
        double r418055 = r418046 - r418054;
        double r418056 = r418053 / r418055;
        double r418057 = y;
        double r418058 = r418057 - r418054;
        double r418059 = r418056 * r418058;
        double r418060 = t;
        double r418061 = x;
        double r418062 = r418060 - r418061;
        double r418063 = fma(r418059, r418062, r418061);
        double r418064 = r418061 / r418054;
        double r418065 = r418060 / r418054;
        double r418066 = r418064 - r418065;
        double r418067 = r418057 * r418066;
        double r418068 = r418067 + r418060;
        double r418069 = r418052 ? r418063 : r418068;
        return r418069;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original23.8
Target11.4
Herbie10.1
\[\begin{array}{l} \mathbf{if}\;z \lt -1.253613105609503593846459977496550767343 \cdot 10^{188}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \mathbf{elif}\;z \lt 4.446702369113811028051510715777703865332 \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.775356164441544e-50 or 2.5556154591904095e-179 < a

    1. Initial program 21.9

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

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

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

    if -9.775356164441544e-50 < a < 2.5556154591904095e-179

    1. Initial program 28.5

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

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

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

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

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

Reproduce

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