Average Error: 2.0 → 1.5
Time: 7.2s
Precision: binary64
\[x + \left(y - x\right) \cdot \frac{z}{t} \]
\[\begin{array}{l} \mathbf{if}\;t \leq -2.5268772841685277 \cdot 10^{-157} \lor \neg \left(t \leq 2.3295563362690378 \cdot 10^{-58}\right):\\ \;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \end{array} \]
x + \left(y - x\right) \cdot \frac{z}{t}
\begin{array}{l}
\mathbf{if}\;t \leq -2.5268772841685277 \cdot 10^{-157} \lor \neg \left(t \leq 2.3295563362690378 \cdot 10^{-58}\right):\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)\\

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


\end{array}
(FPCore (x y z t) :precision binary64 (+ x (* (- y x) (/ z t))))
(FPCore (x y z t)
 :precision binary64
 (if (or (<= t -2.5268772841685277e-157) (not (<= t 2.3295563362690378e-58)))
   (fma (- y x) (/ z t) x)
   (+ x (/ (* (- y x) z) t))))
double code(double x, double y, double z, double t) {
	return x + ((y - x) * (z / t));
}
double code(double x, double y, double z, double t) {
	double tmp;
	if ((t <= -2.5268772841685277e-157) || !(t <= 2.3295563362690378e-58)) {
		tmp = fma((y - x), (z / t), x);
	} else {
		tmp = x + (((y - x) * z) / t);
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original2.0
Target2.2
Herbie1.5
\[\begin{array}{l} \mathbf{if}\;\left(y - x\right) \cdot \frac{z}{t} < -1013646692435.8867:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{elif}\;\left(y - x\right) \cdot \frac{z}{t} < 0:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \end{array} \]

Derivation

  1. Split input into 2 regimes
  2. if t < -2.52687728416852767e-157 or 2.3295563362690378e-58 < t

    1. Initial program 1.1

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

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

    if -2.52687728416852767e-157 < t < 2.3295563362690378e-58

    1. Initial program 5.1

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

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

      \[\leadsto \color{blue}{\left(\frac{y \cdot z}{t} + x\right) - \frac{z \cdot x}{t}} \]
    4. Applied add-cube-cbrt_binary643.1

      \[\leadsto \left(\frac{y \cdot z}{t} + x\right) - \color{blue}{\left(\sqrt[3]{\frac{z \cdot x}{t}} \cdot \sqrt[3]{\frac{z \cdot x}{t}}\right) \cdot \sqrt[3]{\frac{z \cdot x}{t}}} \]
    5. Applied add-cube-cbrt_binary643.8

      \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{y \cdot z}{t} + x} \cdot \sqrt[3]{\frac{y \cdot z}{t} + x}\right) \cdot \sqrt[3]{\frac{y \cdot z}{t} + x}} - \left(\sqrt[3]{\frac{z \cdot x}{t}} \cdot \sqrt[3]{\frac{z \cdot x}{t}}\right) \cdot \sqrt[3]{\frac{z \cdot x}{t}} \]
    6. Applied prod-diff_binary643.8

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt[3]{\frac{y \cdot z}{t} + x} \cdot \sqrt[3]{\frac{y \cdot z}{t} + x}, \sqrt[3]{\frac{y \cdot z}{t} + x}, -\sqrt[3]{\frac{z \cdot x}{t}} \cdot \left(\sqrt[3]{\frac{z \cdot x}{t}} \cdot \sqrt[3]{\frac{z \cdot x}{t}}\right)\right) + \mathsf{fma}\left(-\sqrt[3]{\frac{z \cdot x}{t}}, \sqrt[3]{\frac{z \cdot x}{t}} \cdot \sqrt[3]{\frac{z \cdot x}{t}}, \sqrt[3]{\frac{z \cdot x}{t}} \cdot \left(\sqrt[3]{\frac{z \cdot x}{t}} \cdot \sqrt[3]{\frac{z \cdot x}{t}}\right)\right)} \]
    7. Simplified2.7

      \[\leadsto \color{blue}{\left(x + \frac{z \cdot \left(y - x\right)}{t}\right)} + \mathsf{fma}\left(-\sqrt[3]{\frac{z \cdot x}{t}}, \sqrt[3]{\frac{z \cdot x}{t}} \cdot \sqrt[3]{\frac{z \cdot x}{t}}, \sqrt[3]{\frac{z \cdot x}{t}} \cdot \left(\sqrt[3]{\frac{z \cdot x}{t}} \cdot \sqrt[3]{\frac{z \cdot x}{t}}\right)\right) \]
    8. Simplified2.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -2.5268772841685277 \cdot 10^{-157} \lor \neg \left(t \leq 2.3295563362690378 \cdot 10^{-58}\right):\\ \;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \end{array} \]

Reproduce

herbie shell --seed 2022068 
(FPCore (x y z t)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:tickPosition from plot-0.2.3.4"
  :precision binary64

  :herbie-target
  (if (< (* (- y x) (/ z t)) -1013646692435.8867) (+ x (/ (- y x) (/ t z))) (if (< (* (- y x) (/ z t)) 0.0) (+ x (/ (* (- y x) z) t)) (+ x (/ (- y x) (/ t z)))))

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