Average Error: 10.9 → 0.6
Time: 6.0s
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 -\infty:\\ \;\;\;\;y \cdot \frac{z - t}{a - t} + x\\ \mathbf{elif}\;t_1 \leq 7.510211159559017 \cdot 10^{+214}:\\ \;\;\;\;\left(x + \frac{y \cdot z}{a - t}\right) - \frac{y \cdot t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z - t, \frac{y}{a - t}, 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 (/ (* y (- z t)) (- a t))))
   (if (<= t_1 (- INFINITY))
     (+ (* y (/ (- z t) (- a t))) x)
     (if (<= t_1 7.510211159559017e+214)
       (- (+ x (/ (* y z) (- a t))) (/ (* y t) (- a t)))
       (fma (- z t) (/ y (- a t)) 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 = (y * (z - t)) / (a - t);
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = (y * ((z - t) / (a - t))) + x;
	} else if (t_1 <= 7.510211159559017e+214) {
		tmp = (x + ((y * z) / (a - t))) - ((y * t) / (a - t));
	} else {
		tmp = fma((z - t), (y / (a - t)), x);
	}
	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 <= Float64(-Inf))
		tmp = Float64(Float64(y * Float64(Float64(z - t) / Float64(a - t))) + x);
	elseif (t_1 <= 7.510211159559017e+214)
		tmp = Float64(Float64(x + Float64(Float64(y * z) / Float64(a - t))) - Float64(Float64(y * t) / Float64(a - t)));
	else
		tmp = fma(Float64(z - t), Float64(y / Float64(a - t)), x);
	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, (-Infinity)], N[(N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$1, 7.510211159559017e+214], N[(N[(x + N[(N[(y * z), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(y * t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z - t), $MachinePrecision] * N[(y / N[(a - t), $MachinePrecision]), $MachinePrecision] + x), $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 -\infty:\\
\;\;\;\;y \cdot \frac{z - t}{a - t} + x\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z - t, \frac{y}{a - t}, 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

Original10.9
Target1.2
Herbie0.6
\[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)) < -inf.0

    1. Initial program 64.0

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

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

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

    if -inf.0 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t)) < 7.51021115955901715e214

    1. Initial program 0.2

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

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

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

    if 7.51021115955901715e214 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t))

    1. Initial program 49.4

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

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

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

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

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

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

Reproduce

herbie shell --seed 2022133 
(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))))