Average Error: 24.3 → 7.1
Time: 6.5s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;a \le -3.98455454781632547146508606353667325472 \cdot 10^{-203} \lor \neg \left(a \le 2.425775369466867075001690962650091456756 \cdot 10^{-266}\right):\\ \;\;\;\;t \cdot \frac{1}{\frac{a - z}{y - z}} + \mathsf{fma}\left(-x, \frac{y - z}{a - z}, x\right)\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{y - z}{a - z} + \frac{x \cdot y}{z}\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;a \le -3.98455454781632547146508606353667325472 \cdot 10^{-203} \lor \neg \left(a \le 2.425775369466867075001690962650091456756 \cdot 10^{-266}\right):\\
\;\;\;\;t \cdot \frac{1}{\frac{a - z}{y - z}} + \mathsf{fma}\left(-x, \frac{y - z}{a - z}, x\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r738138 = x;
        double r738139 = y;
        double r738140 = z;
        double r738141 = r738139 - r738140;
        double r738142 = t;
        double r738143 = r738142 - r738138;
        double r738144 = r738141 * r738143;
        double r738145 = a;
        double r738146 = r738145 - r738140;
        double r738147 = r738144 / r738146;
        double r738148 = r738138 + r738147;
        return r738148;
}

double f(double x, double y, double z, double t, double a) {
        double r738149 = a;
        double r738150 = -3.9845545478163255e-203;
        bool r738151 = r738149 <= r738150;
        double r738152 = 2.425775369466867e-266;
        bool r738153 = r738149 <= r738152;
        double r738154 = !r738153;
        bool r738155 = r738151 || r738154;
        double r738156 = t;
        double r738157 = 1.0;
        double r738158 = z;
        double r738159 = r738149 - r738158;
        double r738160 = y;
        double r738161 = r738160 - r738158;
        double r738162 = r738159 / r738161;
        double r738163 = r738157 / r738162;
        double r738164 = r738156 * r738163;
        double r738165 = x;
        double r738166 = -r738165;
        double r738167 = r738161 / r738159;
        double r738168 = fma(r738166, r738167, r738165);
        double r738169 = r738164 + r738168;
        double r738170 = r738156 * r738167;
        double r738171 = r738165 * r738160;
        double r738172 = r738171 / r738158;
        double r738173 = r738170 + r738172;
        double r738174 = r738155 ? r738169 : r738173;
        return r738174;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.3
Target11.6
Herbie7.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 < -3.9845545478163255e-203 or 2.425775369466867e-266 < 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.5

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

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

      \[\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.0

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

      \[\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 clear-num7.0

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

    if -3.9845545478163255e-203 < a < 2.425775369466867e-266

    1. Initial program 30.8

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

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

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

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

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

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

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

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

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

Reproduce

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