Average Error: 1.4 → 1.3
Time: 6.4s
Precision: binary64
\[x + y \cdot \frac{z - t}{z - a} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -7.319216852213493 \cdot 10^{+57}:\\ \;\;\;\;x + \left(z - t\right) \cdot \frac{y}{z - a}\\ \mathbf{elif}\;y \leq 5.547445071430195 \cdot 10^{-141}:\\ \;\;\;\;x + \frac{y \cdot \left(z - t\right)}{z - a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{z - a}, x\right)\\ \end{array} \]
(FPCore (x y z t a) :precision binary64 (+ x (* y (/ (- z t) (- z a)))))
(FPCore (x y z t a)
 :precision binary64
 (if (<= y -7.319216852213493e+57)
   (+ x (* (- z t) (/ y (- z a))))
   (if (<= y 5.547445071430195e-141)
     (+ x (/ (* y (- z t)) (- z a)))
     (fma y (/ (- z t) (- z a)) x))))
double code(double x, double y, double z, double t, double a) {
	return x + (y * ((z - t) / (z - a)));
}
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (y <= -7.319216852213493e+57) {
		tmp = x + ((z - t) * (y / (z - a)));
	} else if (y <= 5.547445071430195e-141) {
		tmp = x + ((y * (z - t)) / (z - a));
	} else {
		tmp = fma(y, ((z - t) / (z - a)), x);
	}
	return tmp;
}
function code(x, y, z, t, a)
	return Float64(x + Float64(y * Float64(Float64(z - t) / Float64(z - a))))
end
function code(x, y, z, t, a)
	tmp = 0.0
	if (y <= -7.319216852213493e+57)
		tmp = Float64(x + Float64(Float64(z - t) * Float64(y / Float64(z - a))));
	elseif (y <= 5.547445071430195e-141)
		tmp = Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(z - a)));
	else
		tmp = fma(y, Float64(Float64(z - t) / Float64(z - a)), x);
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := If[LessEqual[y, -7.319216852213493e+57], N[(x + N[(N[(z - t), $MachinePrecision] * N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.547445071430195e-141], N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]]
x + y \cdot \frac{z - t}{z - a}
\begin{array}{l}
\mathbf{if}\;y \leq -7.319216852213493 \cdot 10^{+57}:\\
\;\;\;\;x + \left(z - t\right) \cdot \frac{y}{z - a}\\

\mathbf{elif}\;y \leq 5.547445071430195 \cdot 10^{-141}:\\
\;\;\;\;x + \frac{y \cdot \left(z - t\right)}{z - a}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{z - a}, 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.4
Target1.2
Herbie1.3
\[x + \frac{y}{\frac{z - a}{z - t}} \]

Derivation

  1. Split input into 3 regimes
  2. if y < -7.3192168522134934e57

    1. Initial program 0.4

      \[x + y \cdot \frac{z - t}{z - a} \]
    2. Taylor expanded in y around 0 29.1

      \[\leadsto x + \color{blue}{\frac{\left(z - t\right) \cdot y}{z - a}} \]
    3. Applied *-un-lft-identity_binary6429.1

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

      \[\leadsto x + \color{blue}{\frac{z - t}{1} \cdot \frac{y}{z - a}} \]
    5. Simplified3.3

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

    if -7.3192168522134934e57 < y < 5.5474450714301953e-141

    1. Initial program 2.1

      \[x + y \cdot \frac{z - t}{z - a} \]
    2. Taylor expanded in y around 0 0.9

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

    if 5.5474450714301953e-141 < y

    1. Initial program 0.8

      \[x + y \cdot \frac{z - t}{z - a} \]
    2. Simplified0.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7.319216852213493 \cdot 10^{+57}:\\ \;\;\;\;x + \left(z - t\right) \cdot \frac{y}{z - a}\\ \mathbf{elif}\;y \leq 5.547445071430195 \cdot 10^{-141}:\\ \;\;\;\;x + \frac{y \cdot \left(z - t\right)}{z - a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{z - a}, x\right)\\ \end{array} \]

Reproduce

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

  :herbie-target
  (+ x (/ y (/ (- z a) (- z t))))

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