Average Error: 10.2 → 0.8
Time: 4.9s
Precision: binary64
\[x + \frac{y \cdot \left(z - t\right)}{a - t} \]
\[\begin{array}{l} t_1 := \frac{y \cdot \left(z - t\right)}{a - t}\\ \mathbf{if}\;t_1 \leq -4.7126067703191754 \cdot 10^{+24}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{a - t}, z - t, x\right)\\ \mathbf{elif}\;t_1 \leq 3.3293842485947703 \cdot 10^{+274}:\\ \;\;\;\;t_1 + x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{a - t}{z - t}}\\ \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 (/ (* y (- z t)) (- a t))))
   (if (<= t_1 -4.7126067703191754e+24)
     (fma (/ y (- a t)) (- z t) x)
     (if (<= t_1 3.3293842485947703e+274)
       (+ t_1 x)
       (+ x (/ y (/ (- a t) (- z t))))))))
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 = (y * (z - t)) / (a - t);
	double tmp;
	if (t_1 <= -4.7126067703191754e+24) {
		tmp = fma((y / (a - t)), (z - t), x);
	} else if (t_1 <= 3.3293842485947703e+274) {
		tmp = t_1 + x;
	} else {
		tmp = x + (y / ((a - t) / (z - t)));
	}
	return tmp;
}
function code(x, y, z, t, a)
	return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(a - t)))
end
function code(x, y, z, t, a)
	t_1 = Float64(Float64(y * Float64(z - t)) / Float64(a - t))
	tmp = 0.0
	if (t_1 <= -4.7126067703191754e+24)
		tmp = fma(Float64(y / Float64(a - t)), Float64(z - t), x);
	elseif (t_1 <= 3.3293842485947703e+274)
		tmp = Float64(t_1 + x);
	else
		tmp = Float64(x + Float64(y / Float64(Float64(a - t) / Float64(z - t))));
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4.7126067703191754e+24], N[(N[(y / N[(a - t), $MachinePrecision]), $MachinePrecision] * N[(z - t), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$1, 3.3293842485947703e+274], N[(t$95$1 + x), $MachinePrecision], N[(x + N[(y / N[(N[(a - t), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
x + \frac{y \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a - t}\\
\mathbf{if}\;t_1 \leq -4.7126067703191754 \cdot 10^{+24}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a - t}, z - t, x\right)\\

\mathbf{elif}\;t_1 \leq 3.3293842485947703 \cdot 10^{+274}:\\
\;\;\;\;t_1 + x\\

\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\frac{a - t}{z - t}}\\


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.2
Target1.3
Herbie0.8
\[x + \frac{y}{\frac{a - t}{z - t}} \]

Derivation

  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t)) < -4.71260677031917545e24

    1. Initial program 24.8

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{{\left(\frac{a - t}{z - t}\right)}^{-1}}, x\right) \]
    4. Applied egg-rr2.2

      \[\leadsto \color{blue}{x + \frac{y}{\frac{a - t}{z - t}}} \]
    5. Applied egg-rr2.5

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

    if -4.71260677031917545e24 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t)) < 3.32938424859477035e274

    1. Initial program 0.3

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

    if 3.32938424859477035e274 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t))

    1. Initial program 59.0

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{{\left(\frac{a - t}{z - t}\right)}^{-1}}, x\right) \]
    4. Applied egg-rr0.7

      \[\leadsto \color{blue}{x + \frac{y}{\frac{a - t}{z - t}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.8

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

Reproduce

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

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

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