Average Error: 1.5 → 0.8
Time: 5.2s
Precision: binary64
\[x + y \cdot \frac{z - t}{a - t} \]
\[\begin{array}{l} t_1 := \frac{z - t}{a - t}\\ \mathbf{if}\;y \leq -7.12267444498305 \cdot 10^{+45}:\\ \;\;\;\;x + y \cdot t_1\\ \mathbf{elif}\;y \leq 1.6341701951976104 \cdot 10^{-198}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(z - t\right), \frac{1}{a - t}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t_1, y, x\right)\\ \end{array} \]
(FPCore (x y z t a) :precision binary64 (+ x (* y (/ (- z t) (- a t)))))
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (/ (- z t) (- a t))))
   (if (<= y -7.12267444498305e+45)
     (+ x (* y t_1))
     (if (<= y 1.6341701951976104e-198)
       (fma (* y (- z t)) (/ 1.0 (- a t)) x)
       (fma t_1 y x)))))
double code(double x, double y, double z, double t, double a) {
	return x + (y * ((z - t) / (a - t)));
}
double code(double x, double y, double z, double t, double a) {
	double t_1 = (z - t) / (a - t);
	double tmp;
	if (y <= -7.12267444498305e+45) {
		tmp = x + (y * t_1);
	} else if (y <= 1.6341701951976104e-198) {
		tmp = fma((y * (z - t)), (1.0 / (a - t)), x);
	} else {
		tmp = fma(t_1, y, x);
	}
	return tmp;
}
function code(x, y, z, t, a)
	return Float64(x + Float64(y * Float64(Float64(z - t) / Float64(a - t))))
end
function code(x, y, z, t, a)
	t_1 = Float64(Float64(z - t) / Float64(a - t))
	tmp = 0.0
	if (y <= -7.12267444498305e+45)
		tmp = Float64(x + Float64(y * t_1));
	elseif (y <= 1.6341701951976104e-198)
		tmp = fma(Float64(y * Float64(z - t)), Float64(1.0 / Float64(a - t)), x);
	else
		tmp = fma(t_1, y, x);
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -7.12267444498305e+45], N[(x + N[(y * t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.6341701951976104e-198], N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(a - t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(t$95$1 * y + x), $MachinePrecision]]]]
x + y \cdot \frac{z - t}{a - t}
\begin{array}{l}
t_1 := \frac{z - t}{a - t}\\
\mathbf{if}\;y \leq -7.12267444498305 \cdot 10^{+45}:\\
\;\;\;\;x + y \cdot t_1\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_1, y, x\right)\\


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original1.5
Target0.5
Herbie0.8
\[\begin{array}{l} \mathbf{if}\;y < -8.508084860551241 \cdot 10^{-17}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \mathbf{elif}\;y < 2.894426862792089 \cdot 10^{-49}:\\ \;\;\;\;x + \left(y \cdot \left(z - t\right)\right) \cdot \frac{1}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \end{array} \]

Derivation

  1. Split input into 3 regimes
  2. if y < -7.12267444498305042e45

    1. Initial program 0.6

      \[x + y \cdot \frac{z - t}{a - t} \]

    if -7.12267444498305042e45 < y < 1.6341701951976104e-198

    1. Initial program 2.5

      \[x + y \cdot \frac{z - t}{a - t} \]
    2. Applied egg-rr2.5

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

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

    if 1.6341701951976104e-198 < y

    1. Initial program 0.9

      \[x + y \cdot \frac{z - t}{a - t} \]
    2. Applied egg-rr0.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7.12267444498305 \cdot 10^{+45}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \mathbf{elif}\;y \leq 1.6341701951976104 \cdot 10^{-198}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(z - t\right), \frac{1}{a - t}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z - t}{a - t}, y, x\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022153 
(FPCore (x y z t a)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisLine from plot-0.2.3.4, B"
  :precision binary64

  :herbie-target
  (if (< y -8.508084860551241e-17) (+ x (* y (/ (- z t) (- a t)))) (if (< y 2.894426862792089e-49) (+ x (* (* y (- z t)) (/ 1.0 (- a t)))) (+ x (* y (/ (- z t) (- a t))))))

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