Average Error: 24.2 → 7.4
Time: 6.3s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;a \le -3.6365486485991055 \cdot 10^{-160} \lor \neg \left(a \le 7.07551916214290112 \cdot 10^{-178}\right):\\ \;\;\;\;\frac{y - z}{a - z} \cdot t + \mathsf{fma}\left(-x, \left(y - z\right) \cdot \frac{1}{a - z}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{y - z}{a - z} \cdot t + \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.6365486485991055 \cdot 10^{-160} \lor \neg \left(a \le 7.07551916214290112 \cdot 10^{-178}\right):\\
\;\;\;\;\frac{y - z}{a - z} \cdot t + \mathsf{fma}\left(-x, \left(y - z\right) \cdot \frac{1}{a - z}, x\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r631215 = x;
        double r631216 = y;
        double r631217 = z;
        double r631218 = r631216 - r631217;
        double r631219 = t;
        double r631220 = r631219 - r631215;
        double r631221 = r631218 * r631220;
        double r631222 = a;
        double r631223 = r631222 - r631217;
        double r631224 = r631221 / r631223;
        double r631225 = r631215 + r631224;
        return r631225;
}

double f(double x, double y, double z, double t, double a) {
        double r631226 = a;
        double r631227 = -3.6365486485991055e-160;
        bool r631228 = r631226 <= r631227;
        double r631229 = 7.075519162142901e-178;
        bool r631230 = r631226 <= r631229;
        double r631231 = !r631230;
        bool r631232 = r631228 || r631231;
        double r631233 = y;
        double r631234 = z;
        double r631235 = r631233 - r631234;
        double r631236 = r631226 - r631234;
        double r631237 = r631235 / r631236;
        double r631238 = t;
        double r631239 = r631237 * r631238;
        double r631240 = x;
        double r631241 = -r631240;
        double r631242 = 1.0;
        double r631243 = r631242 / r631236;
        double r631244 = r631235 * r631243;
        double r631245 = fma(r631241, r631244, r631240);
        double r631246 = r631239 + r631245;
        double r631247 = r631240 * r631233;
        double r631248 = r631247 / r631234;
        double r631249 = r631239 + r631248;
        double r631250 = r631232 ? r631246 : r631249;
        return r631250;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.2
Target12.0
Herbie7.4
\[\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 < -3.6365486485991055e-160 or 7.075519162142901e-178 < a

    1. Initial program 22.9

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

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

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

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

      \[\leadsto \color{blue}{\left(\frac{y - z}{a - z} \cdot t + \frac{y - z}{a - z} \cdot \left(-x\right)\right)} + x\]
    8. Applied associate-+l+6.8

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

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

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

    if -3.6365486485991055e-160 < a < 7.075519162142901e-178

    1. Initial program 29.7

      \[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. Using strategy rm
    4. Applied fma-udef19.7

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

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

      \[\leadsto \color{blue}{\left(\frac{y - z}{a - z} \cdot t + \frac{y - z}{a - z} \cdot \left(-x\right)\right)} + x\]
    8. Applied associate-+l+10.3

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

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

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

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

Reproduce

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