Average Error: 23.8 → 9.3
Time: 23.1s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;a \le -1.2559578325599803 \cdot 10^{-148}:\\ \;\;\;\;x + \frac{1}{\frac{a - z}{y - z}} \cdot \left(t - x\right)\\ \mathbf{elif}\;a \le 9.426461174744231 \cdot 10^{-94}:\\ \;\;\;\;\left(\frac{x}{z} - \frac{t}{z}\right) \cdot y + t\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{\frac{a - z}{y - z}} \cdot \left(t - x\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;a \le -1.2559578325599803 \cdot 10^{-148}:\\
\;\;\;\;x + \frac{1}{\frac{a - z}{y - z}} \cdot \left(t - x\right)\\

\mathbf{elif}\;a \le 9.426461174744231 \cdot 10^{-94}:\\
\;\;\;\;\left(\frac{x}{z} - \frac{t}{z}\right) \cdot y + t\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r26988363 = x;
        double r26988364 = y;
        double r26988365 = z;
        double r26988366 = r26988364 - r26988365;
        double r26988367 = t;
        double r26988368 = r26988367 - r26988363;
        double r26988369 = r26988366 * r26988368;
        double r26988370 = a;
        double r26988371 = r26988370 - r26988365;
        double r26988372 = r26988369 / r26988371;
        double r26988373 = r26988363 + r26988372;
        return r26988373;
}

double f(double x, double y, double z, double t, double a) {
        double r26988374 = a;
        double r26988375 = -1.2559578325599803e-148;
        bool r26988376 = r26988374 <= r26988375;
        double r26988377 = x;
        double r26988378 = 1.0;
        double r26988379 = z;
        double r26988380 = r26988374 - r26988379;
        double r26988381 = y;
        double r26988382 = r26988381 - r26988379;
        double r26988383 = r26988380 / r26988382;
        double r26988384 = r26988378 / r26988383;
        double r26988385 = t;
        double r26988386 = r26988385 - r26988377;
        double r26988387 = r26988384 * r26988386;
        double r26988388 = r26988377 + r26988387;
        double r26988389 = 9.426461174744231e-94;
        bool r26988390 = r26988374 <= r26988389;
        double r26988391 = r26988377 / r26988379;
        double r26988392 = r26988385 / r26988379;
        double r26988393 = r26988391 - r26988392;
        double r26988394 = r26988393 * r26988381;
        double r26988395 = r26988394 + r26988385;
        double r26988396 = r26988390 ? r26988395 : r26988388;
        double r26988397 = r26988376 ? r26988388 : r26988396;
        return r26988397;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original23.8
Target11.9
Herbie9.3
\[\begin{array}{l} \mathbf{if}\;z \lt -1.2536131056095036 \cdot 10^{+188}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \mathbf{elif}\;z \lt 4.446702369113811 \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 < -1.2559578325599803e-148 or 9.426461174744231e-94 < a

    1. Initial program 21.6

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

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

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

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

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

      \[\leadsto \left(t - x\right) \cdot \color{blue}{\frac{y - z}{a - z}} + x\]
    9. Using strategy rm
    10. Applied clear-num8.7

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

    if -1.2559578325599803e-148 < a < 9.426461174744231e-94

    1. Initial program 29.8

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

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

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

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

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

      \[\leadsto \left(t - x\right) \cdot \color{blue}{\frac{y - z}{a - z}} + x\]
    9. Taylor expanded around inf 14.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -1.2559578325599803 \cdot 10^{-148}:\\ \;\;\;\;x + \frac{1}{\frac{a - z}{y - z}} \cdot \left(t - x\right)\\ \mathbf{elif}\;a \le 9.426461174744231 \cdot 10^{-94}:\\ \;\;\;\;\left(\frac{x}{z} - \frac{t}{z}\right) \cdot y + t\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{\frac{a - z}{y - z}} \cdot \left(t - x\right)\\ \end{array}\]

Reproduce

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