Average Error: 23.1 → 9.5
Time: 13.9s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -1.4684889679652604 \cdot 10^{+138}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z}{\frac{t}{y}}\right)\\ \mathbf{elif}\;t \le 4.177099727216109 \cdot 10^{+188}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z - t}{a - t}, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z}{\frac{t}{y}}\right)\\ \end{array}\]
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
\mathbf{if}\;t \le -1.4684889679652604 \cdot 10^{+138}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z}{\frac{t}{y}}\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r10417677 = x;
        double r10417678 = y;
        double r10417679 = r10417678 - r10417677;
        double r10417680 = z;
        double r10417681 = t;
        double r10417682 = r10417680 - r10417681;
        double r10417683 = r10417679 * r10417682;
        double r10417684 = a;
        double r10417685 = r10417684 - r10417681;
        double r10417686 = r10417683 / r10417685;
        double r10417687 = r10417677 + r10417686;
        return r10417687;
}

double f(double x, double y, double z, double t, double a) {
        double r10417688 = t;
        double r10417689 = -1.4684889679652604e+138;
        bool r10417690 = r10417688 <= r10417689;
        double r10417691 = x;
        double r10417692 = r10417691 / r10417688;
        double r10417693 = z;
        double r10417694 = y;
        double r10417695 = r10417688 / r10417694;
        double r10417696 = r10417693 / r10417695;
        double r10417697 = r10417694 - r10417696;
        double r10417698 = fma(r10417692, r10417693, r10417697);
        double r10417699 = 4.177099727216109e+188;
        bool r10417700 = r10417688 <= r10417699;
        double r10417701 = r10417693 - r10417688;
        double r10417702 = a;
        double r10417703 = r10417702 - r10417688;
        double r10417704 = r10417701 / r10417703;
        double r10417705 = r10417694 - r10417691;
        double r10417706 = fma(r10417704, r10417705, r10417691);
        double r10417707 = r10417700 ? r10417706 : r10417698;
        double r10417708 = r10417690 ? r10417698 : r10417707;
        return r10417708;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original23.1
Target9.3
Herbie9.5
\[\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.774403170083174 \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 2 regimes
  2. if t < -1.4684889679652604e+138 or 4.177099727216109e+188 < t

    1. Initial program 46.3

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

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

      \[\leadsto \mathsf{fma}\left(\frac{z - t}{\color{blue}{\left(\sqrt[3]{a - t} \cdot \sqrt[3]{a - t}\right) \cdot \sqrt[3]{a - t}}}, y - x, x\right)\]
    5. Applied associate-/r*24.5

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

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

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

    if -1.4684889679652604e+138 < t < 4.177099727216109e+188

    1. Initial program 15.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -1.4684889679652604 \cdot 10^{+138}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z}{\frac{t}{y}}\right)\\ \mathbf{elif}\;t \le 4.177099727216109 \cdot 10^{+188}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z - t}{a - t}, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z}{\frac{t}{y}}\right)\\ \end{array}\]

Reproduce

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

  :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))))