Average Error: 24.4 → 10.0
Time: 4.3s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.144165143768362991760089872609493676713 \cdot 10^{186} \lor \neg \left(z \le 2.076744265404525669788852177351907204291 \cdot 10^{154}\right):\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \frac{y - z}{a - z}, t - x, x\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;z \le -2.144165143768362991760089872609493676713 \cdot 10^{186} \lor \neg \left(z \le 2.076744265404525669788852177351907204291 \cdot 10^{154}\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \frac{y - z}{a - z}, t - x, x\right)\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r536198 = x;
        double r536199 = y;
        double r536200 = z;
        double r536201 = r536199 - r536200;
        double r536202 = t;
        double r536203 = r536202 - r536198;
        double r536204 = r536201 * r536203;
        double r536205 = a;
        double r536206 = r536205 - r536200;
        double r536207 = r536204 / r536206;
        double r536208 = r536198 + r536207;
        return r536208;
}

double f(double x, double y, double z, double t, double a) {
        double r536209 = z;
        double r536210 = -2.144165143768363e+186;
        bool r536211 = r536209 <= r536210;
        double r536212 = 2.0767442654045257e+154;
        bool r536213 = r536209 <= r536212;
        double r536214 = !r536213;
        bool r536215 = r536211 || r536214;
        double r536216 = y;
        double r536217 = x;
        double r536218 = r536217 / r536209;
        double r536219 = t;
        double r536220 = r536219 / r536209;
        double r536221 = r536218 - r536220;
        double r536222 = fma(r536216, r536221, r536219);
        double r536223 = 1.0;
        double r536224 = r536216 - r536209;
        double r536225 = a;
        double r536226 = r536225 - r536209;
        double r536227 = r536224 / r536226;
        double r536228 = r536223 * r536227;
        double r536229 = r536219 - r536217;
        double r536230 = fma(r536228, r536229, r536217);
        double r536231 = r536215 ? r536222 : r536230;
        return r536231;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.4
Target11.9
Herbie10.0
\[\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 z < -2.144165143768363e+186 or 2.0767442654045257e+154 < z

    1. Initial program 48.0

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

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

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

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

    if -2.144165143768363e+186 < z < 2.0767442654045257e+154

    1. Initial program 16.7

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(y - z\right) \cdot \frac{1}{a - z}}, t - x, x\right)\]
    5. Using strategy rm
    6. Applied *-un-lft-identity8.0

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(1 \cdot \left(y - z\right)\right)} \cdot \frac{1}{a - z}, t - x, x\right)\]
    7. Applied associate-*l*8.0

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

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

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

Reproduce

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