Average Error: 24.5 → 7.8
Time: 5.4s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;a \le -5.066922348712068 \cdot 10^{-130} \lor \neg \left(a \le 4.2491195251940242 \cdot 10^{-188}\right):\\ \;\;\;\;t \cdot \frac{y - z}{a - z} + \mathsf{fma}\left(-x, \left(y - z\right) \cdot \frac{1}{a - z}, 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}\;a \le -5.066922348712068 \cdot 10^{-130} \lor \neg \left(a \le 4.2491195251940242 \cdot 10^{-188}\right):\\
\;\;\;\;t \cdot \frac{y - z}{a - z} + \mathsf{fma}\left(-x, \left(y - z\right) \cdot \frac{1}{a - z}, 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 r627073 = x;
        double r627074 = y;
        double r627075 = z;
        double r627076 = r627074 - r627075;
        double r627077 = t;
        double r627078 = r627077 - r627073;
        double r627079 = r627076 * r627078;
        double r627080 = a;
        double r627081 = r627080 - r627075;
        double r627082 = r627079 / r627081;
        double r627083 = r627073 + r627082;
        return r627083;
}

double f(double x, double y, double z, double t, double a) {
        double r627084 = a;
        double r627085 = -5.066922348712068e-130;
        bool r627086 = r627084 <= r627085;
        double r627087 = 4.249119525194024e-188;
        bool r627088 = r627084 <= r627087;
        double r627089 = !r627088;
        bool r627090 = r627086 || r627089;
        double r627091 = t;
        double r627092 = y;
        double r627093 = z;
        double r627094 = r627092 - r627093;
        double r627095 = r627084 - r627093;
        double r627096 = r627094 / r627095;
        double r627097 = r627091 * r627096;
        double r627098 = x;
        double r627099 = -r627098;
        double r627100 = 1.0;
        double r627101 = r627100 / r627095;
        double r627102 = r627094 * r627101;
        double r627103 = fma(r627099, r627102, r627098);
        double r627104 = r627097 + r627103;
        double r627105 = r627098 / r627093;
        double r627106 = r627091 / r627093;
        double r627107 = r627105 - r627106;
        double r627108 = fma(r627092, r627107, r627091);
        double r627109 = r627090 ? r627104 : r627108;
        return r627109;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.5
Target11.7
Herbie7.8
\[\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 < -5.066922348712068e-130 or 4.249119525194024e-188 < a

    1. Initial program 23.0

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

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

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

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

      \[\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+6.6

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

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

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

    if -5.066922348712068e-130 < a < 4.249119525194024e-188

    1. Initial program 30.1

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

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

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

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

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

Reproduce

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