Average Error: 24.4 → 11.3
Time: 18.8s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -1.17452910125923031 \cdot 10^{237}:\\ \;\;\;\;\left(y + \frac{x \cdot z}{t}\right) - \frac{z \cdot y}{t}\\ \mathbf{elif}\;t \le 2.1292815435723623 \cdot 10^{229}:\\ \;\;\;\;\mathsf{fma}\left(y - x, \left(z - t\right) \cdot \frac{1}{a - t}, x\right)\\ \mathbf{elif}\;t \le 4.0194876181204073 \cdot 10^{298}:\\ \;\;\;\;\left(y + \frac{x \cdot z}{t}\right) - \frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\frac{y - x}{a - t}, z - t, x\right)} \cdot \sqrt{\mathsf{fma}\left(\frac{y - x}{a - t}, z - t, x\right)}\\ \end{array}\]
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
\mathbf{if}\;t \le -1.17452910125923031 \cdot 10^{237}:\\
\;\;\;\;\left(y + \frac{x \cdot z}{t}\right) - \frac{z \cdot y}{t}\\

\mathbf{elif}\;t \le 2.1292815435723623 \cdot 10^{229}:\\
\;\;\;\;\mathsf{fma}\left(y - x, \left(z - t\right) \cdot \frac{1}{a - t}, x\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r386501 = x;
        double r386502 = y;
        double r386503 = r386502 - r386501;
        double r386504 = z;
        double r386505 = t;
        double r386506 = r386504 - r386505;
        double r386507 = r386503 * r386506;
        double r386508 = a;
        double r386509 = r386508 - r386505;
        double r386510 = r386507 / r386509;
        double r386511 = r386501 + r386510;
        return r386511;
}

double f(double x, double y, double z, double t, double a) {
        double r386512 = t;
        double r386513 = -1.1745291012592303e+237;
        bool r386514 = r386512 <= r386513;
        double r386515 = y;
        double r386516 = x;
        double r386517 = z;
        double r386518 = r386516 * r386517;
        double r386519 = r386518 / r386512;
        double r386520 = r386515 + r386519;
        double r386521 = r386517 * r386515;
        double r386522 = r386521 / r386512;
        double r386523 = r386520 - r386522;
        double r386524 = 2.1292815435723623e+229;
        bool r386525 = r386512 <= r386524;
        double r386526 = r386515 - r386516;
        double r386527 = r386517 - r386512;
        double r386528 = 1.0;
        double r386529 = a;
        double r386530 = r386529 - r386512;
        double r386531 = r386528 / r386530;
        double r386532 = r386527 * r386531;
        double r386533 = fma(r386526, r386532, r386516);
        double r386534 = 4.0194876181204073e+298;
        bool r386535 = r386512 <= r386534;
        double r386536 = r386526 / r386530;
        double r386537 = fma(r386536, r386527, r386516);
        double r386538 = sqrt(r386537);
        double r386539 = r386538 * r386538;
        double r386540 = r386535 ? r386523 : r386539;
        double r386541 = r386525 ? r386533 : r386540;
        double r386542 = r386514 ? r386523 : r386541;
        return r386542;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.4
Target9.3
Herbie11.3
\[\begin{array}{l} \mathbf{if}\;a \lt -1.6153062845442575 \cdot 10^{-142}:\\ \;\;\;\;x + \frac{y - x}{1} \cdot \frac{z - t}{a - t}\\ \mathbf{elif}\;a \lt 3.7744031700831742 \cdot 10^{-182}:\\ \;\;\;\;y - \frac{z}{t} \cdot \left(y - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{1} \cdot \frac{z - t}{a - t}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if t < -1.1745291012592303e+237 or 2.1292815435723623e+229 < t < 4.0194876181204073e+298

    1. Initial program 52.7

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

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

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

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

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

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

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

    if -1.1745291012592303e+237 < t < 2.1292815435723623e+229

    1. Initial program 19.8

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

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

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

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

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

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

      \[\leadsto \left(y - x\right) \cdot \color{blue}{\left(\left(z - t\right) \cdot \frac{1}{a - t}\right)} + x\]
    11. Using strategy rm
    12. Applied fma-def9.2

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

    if 4.0194876181204073e+298 < t

    1. Initial program 49.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -1.17452910125923031 \cdot 10^{237}:\\ \;\;\;\;\left(y + \frac{x \cdot z}{t}\right) - \frac{z \cdot y}{t}\\ \mathbf{elif}\;t \le 2.1292815435723623 \cdot 10^{229}:\\ \;\;\;\;\mathsf{fma}\left(y - x, \left(z - t\right) \cdot \frac{1}{a - t}, x\right)\\ \mathbf{elif}\;t \le 4.0194876181204073 \cdot 10^{298}:\\ \;\;\;\;\left(y + \frac{x \cdot z}{t}\right) - \frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\frac{y - x}{a - t}, z - t, x\right)} \cdot \sqrt{\mathsf{fma}\left(\frac{y - x}{a - t}, z - t, x\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2020043 +o rules:numerics
(FPCore (x y z t a)
  :name "Graphics.Rendering.Chart.Axis.Types:linMap from Chart-1.5.3"
  :precision binary64

  :herbie-target
  (if (< a -1.6153062845442575e-142) (+ x (* (/ (- y x) 1) (/ (- z t) (- a t)))) (if (< a 3.774403170083174e-182) (- y (* (/ z t) (- y x))) (+ x (* (/ (- y x) 1) (/ (- z t) (- a t))))))

  (+ x (/ (* (- y x) (- z t)) (- a t))))