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

\mathbf{elif}\;t \leq 6.3 \cdot 10^{+96}:\\
\;\;\;\;x + \mathsf{fma}\left(t_1, y, y \cdot \left(1 - \frac{t}{t - a}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{t} + \left(x - y \cdot \frac{a}{t}\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

Original16.7
Target8.4
Herbie5.0
\[\begin{array}{l} \mathbf{if}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} < -1.3664970889390727 \cdot 10^{-7}:\\ \;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\ \mathbf{elif}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} < 1.4754293444577233 \cdot 10^{-239}:\\ \;\;\;\;\frac{y \cdot \left(a - z\right) - x \cdot t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\ \end{array} \]

Derivation

  1. Split input into 3 regimes
  2. if t < -6e192

    1. Initial program 33.9

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

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

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

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

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

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

    if -6e192 < t < 6.3000000000000003e96

    1. Initial program 10.7

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

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

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

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

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

    if 6.3000000000000003e96 < t

    1. Initial program 30.7

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

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(y, \frac{z - t}{t - a}, y\right)} \]
    3. Applied egg-rr10.8

      \[\leadsto x + \mathsf{fma}\left(y, \color{blue}{{\left(\frac{t - a}{z - t}\right)}^{-1}}, y\right) \]
    4. Taylor expanded in t around inf 16.5

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

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

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

Reproduce

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

  :herbie-target
  (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) -1.3664970889390727e-7) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y)) (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) 1.4754293444577233e-239) (/ (- (* y (- a z)) (* x t)) (- a t)) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y))))

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