Average Error: 24.1 → 10.1
Time: 4.2s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} = -\infty:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \frac{1}{\left(a - z\right) \cdot \frac{1}{y - z}}, t - x, x\right)\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -2.83283552082506149 \cdot 10^{-308}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t - x}{a - z} \cdot \left(y - z\right) + x\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} = -\infty:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \frac{1}{\left(a - z\right) \cdot \frac{1}{y - z}}, t - x, x\right)\\

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

\mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r601256 = x;
        double r601257 = y;
        double r601258 = z;
        double r601259 = r601257 - r601258;
        double r601260 = t;
        double r601261 = r601260 - r601256;
        double r601262 = r601259 * r601261;
        double r601263 = a;
        double r601264 = r601263 - r601258;
        double r601265 = r601262 / r601264;
        double r601266 = r601256 + r601265;
        return r601266;
}

double f(double x, double y, double z, double t, double a) {
        double r601267 = x;
        double r601268 = y;
        double r601269 = z;
        double r601270 = r601268 - r601269;
        double r601271 = t;
        double r601272 = r601271 - r601267;
        double r601273 = r601270 * r601272;
        double r601274 = a;
        double r601275 = r601274 - r601269;
        double r601276 = r601273 / r601275;
        double r601277 = r601267 + r601276;
        double r601278 = -inf.0;
        bool r601279 = r601277 <= r601278;
        double r601280 = 1.0;
        double r601281 = r601280 / r601270;
        double r601282 = r601275 * r601281;
        double r601283 = r601280 / r601282;
        double r601284 = r601280 * r601283;
        double r601285 = fma(r601284, r601272, r601267);
        double r601286 = -2.8328355208250615e-308;
        bool r601287 = r601277 <= r601286;
        double r601288 = 0.0;
        bool r601289 = r601277 <= r601288;
        double r601290 = r601267 / r601269;
        double r601291 = r601271 / r601269;
        double r601292 = r601290 - r601291;
        double r601293 = fma(r601268, r601292, r601271);
        double r601294 = r601272 / r601275;
        double r601295 = r601294 * r601270;
        double r601296 = r601295 + r601267;
        double r601297 = r601289 ? r601293 : r601296;
        double r601298 = r601287 ? r601277 : r601297;
        double r601299 = r601279 ? r601285 : r601298;
        return r601299;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.1
Target11.9
Herbie10.1
\[\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 4 regimes
  2. if (+ x (/ (* (- y z) (- t x)) (- a z))) < -inf.0

    1. Initial program 64.0

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

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

      \[\leadsto \mathsf{fma}\left(\frac{y - z}{\color{blue}{1 \cdot \left(a - z\right)}}, t - x, x\right)\]
    5. Applied *-un-lft-identity17.2

      \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{1 \cdot \left(y - z\right)}}{1 \cdot \left(a - z\right)}, t - x, x\right)\]
    6. Applied times-frac17.2

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \frac{y - z}{a - z}, t - x, x\right)\]
    8. Using strategy rm
    9. Applied clear-num17.2

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

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

    if -inf.0 < (+ x (/ (* (- y z) (- t x)) (- a z))) < -2.8328355208250615e-308

    1. Initial program 1.9

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

    if -2.8328355208250615e-308 < (+ x (/ (* (- y z) (- t x)) (- a z))) < 0.0

    1. Initial program 61.3

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

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

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

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

    if 0.0 < (+ x (/ (* (- y z) (- t x)) (- a z)))

    1. Initial program 21.1

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \frac{y - z}{a - z}, t - x, x\right)\]
    8. Using strategy rm
    9. Applied clear-num8.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} = -\infty:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \frac{1}{\left(a - z\right) \cdot \frac{1}{y - z}}, t - x, x\right)\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -2.83283552082506149 \cdot 10^{-308}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t - x}{a - z} \cdot \left(y - z\right) + x\\ \end{array}\]

Reproduce

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