Average Error: 2.9 → 0.1
Time: 29.2s
Precision: binary64
Cost: 968
\[\frac{x}{y - z \cdot t} \]
\[\begin{array}{l} \mathbf{if}\;z \cdot t \leq -\infty:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;x \ne 0:\\ \;\;\;\;\frac{\frac{-1}{t}}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;-\frac{\frac{x}{z}}{t}\\ \end{array}\\ \mathbf{elif}\;z \cdot t \leq 10^{+282}:\\ \;\;\;\;\frac{x}{y - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t} \cdot \frac{-1}{z}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (/ x (- y (* z t))))
(FPCore (x y z t)
 :precision binary64
 (if (<= (* z t) (- INFINITY))
   (if (!= x 0.0) (/ (/ -1.0 t) (/ z x)) (- (/ (/ x z) t)))
   (if (<= (* z t) 1e+282) (/ x (- y (* z t))) (* (/ x t) (/ -1.0 z)))))
double code(double x, double y, double z, double t) {
	return x / (y - (z * t));
}
double code(double x, double y, double z, double t) {
	double tmp_1;
	if ((z * t) <= -((double) INFINITY)) {
		double tmp_2;
		if (x != 0.0) {
			tmp_2 = (-1.0 / t) / (z / x);
		} else {
			tmp_2 = -((x / z) / t);
		}
		tmp_1 = tmp_2;
	} else if ((z * t) <= 1e+282) {
		tmp_1 = x / (y - (z * t));
	} else {
		tmp_1 = (x / t) * (-1.0 / z);
	}
	return tmp_1;
}
public static double code(double x, double y, double z, double t) {
	return x / (y - (z * t));
}
public static double code(double x, double y, double z, double t) {
	double tmp_1;
	if ((z * t) <= -Double.POSITIVE_INFINITY) {
		double tmp_2;
		if (x != 0.0) {
			tmp_2 = (-1.0 / t) / (z / x);
		} else {
			tmp_2 = -((x / z) / t);
		}
		tmp_1 = tmp_2;
	} else if ((z * t) <= 1e+282) {
		tmp_1 = x / (y - (z * t));
	} else {
		tmp_1 = (x / t) * (-1.0 / z);
	}
	return tmp_1;
}
def code(x, y, z, t):
	return x / (y - (z * t))
def code(x, y, z, t):
	tmp_1 = 0
	if (z * t) <= -math.inf:
		tmp_2 = 0
		if x != 0.0:
			tmp_2 = (-1.0 / t) / (z / x)
		else:
			tmp_2 = -((x / z) / t)
		tmp_1 = tmp_2
	elif (z * t) <= 1e+282:
		tmp_1 = x / (y - (z * t))
	else:
		tmp_1 = (x / t) * (-1.0 / z)
	return tmp_1
function code(x, y, z, t)
	return Float64(x / Float64(y - Float64(z * t)))
end
function code(x, y, z, t)
	tmp_1 = 0.0
	if (Float64(z * t) <= Float64(-Inf))
		tmp_2 = 0.0
		if (x != 0.0)
			tmp_2 = Float64(Float64(-1.0 / t) / Float64(z / x));
		else
			tmp_2 = Float64(-Float64(Float64(x / z) / t));
		end
		tmp_1 = tmp_2;
	elseif (Float64(z * t) <= 1e+282)
		tmp_1 = Float64(x / Float64(y - Float64(z * t)));
	else
		tmp_1 = Float64(Float64(x / t) * Float64(-1.0 / z));
	end
	return tmp_1
end
function tmp = code(x, y, z, t)
	tmp = x / (y - (z * t));
end
function tmp_4 = code(x, y, z, t)
	tmp_2 = 0.0;
	if ((z * t) <= -Inf)
		tmp_3 = 0.0;
		if (x ~= 0.0)
			tmp_3 = (-1.0 / t) / (z / x);
		else
			tmp_3 = -((x / z) / t);
		end
		tmp_2 = tmp_3;
	elseif ((z * t) <= 1e+282)
		tmp_2 = x / (y - (z * t));
	else
		tmp_2 = (x / t) * (-1.0 / z);
	end
	tmp_4 = tmp_2;
end
code[x_, y_, z_, t_] := N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := If[LessEqual[N[(z * t), $MachinePrecision], (-Infinity)], If[Unequal[x, 0.0], N[(N[(-1.0 / t), $MachinePrecision] / N[(z / x), $MachinePrecision]), $MachinePrecision], (-N[(N[(x / z), $MachinePrecision] / t), $MachinePrecision])], If[LessEqual[N[(z * t), $MachinePrecision], 1e+282], N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / t), $MachinePrecision] * N[(-1.0 / z), $MachinePrecision]), $MachinePrecision]]]
\frac{x}{y - z \cdot t}
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -\infty:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;x \ne 0:\\
\;\;\;\;\frac{\frac{-1}{t}}{\frac{z}{x}}\\

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


\end{array}\\

\mathbf{elif}\;z \cdot t \leq 10^{+282}:\\
\;\;\;\;\frac{x}{y - z \cdot t}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{t} \cdot \frac{-1}{z}\\


\end{array}

Error

Target

Original2.9
Target1.6
Herbie0.1
\[\begin{array}{l} \mathbf{if}\;x < -1.618195973607049 \cdot 10^{+50}:\\ \;\;\;\;\frac{1}{\frac{y}{x} - \frac{z}{x} \cdot t}\\ \mathbf{elif}\;x < 2.1378306434876444 \cdot 10^{+131}:\\ \;\;\;\;\frac{x}{y - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{y}{x} - \frac{z}{x} \cdot t}\\ \end{array} \]

Derivation

  1. Split input into 3 regimes
  2. if (*.f64 z t) < -inf.0

    1. Initial program 22.5

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

      \[\leadsto \color{blue}{\frac{1}{\mathsf{fma}\left(t, -z, y\right)} \cdot x} \]
    3. Taylor expanded in t around inf 22.5

      \[\leadsto \color{blue}{\frac{-1}{t \cdot z}} \cdot x \]
    4. Applied egg-rr0.1

      \[\leadsto \color{blue}{\begin{array}{l} \color{blue}{\mathbf{if}\;x \ne 0:\\ \;\;\;\;\frac{\frac{-1}{t}}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;-\frac{\frac{x}{z}}{t}\\ } \end{array}} \]

    if -inf.0 < (*.f64 z t) < 1.00000000000000003e282

    1. Initial program 0.1

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

    if 1.00000000000000003e282 < (*.f64 z t)

    1. Initial program 16.9

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

      \[\leadsto \color{blue}{\frac{1}{\mathsf{fma}\left(t, -z, y\right)} \cdot x} \]
    3. Taylor expanded in t around inf 16.9

      \[\leadsto \color{blue}{\frac{-1}{t \cdot z}} \cdot x \]
    4. Applied egg-rr0.1

      \[\leadsto \color{blue}{\frac{x}{t} \cdot \frac{-1}{z}} \]
  3. Recombined 3 regimes into one program.

Alternatives

Alternative 1
Error0.1
Cost968
\[\begin{array}{l} t_1 := \frac{x}{t} \cdot \frac{-1}{z}\\ \mathbf{if}\;z \cdot t \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \cdot t \leq 10^{+282}:\\ \;\;\;\;\frac{x}{y - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error18.0
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -4.2 \cdot 10^{+63}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{-22}:\\ \;\;\;\;\frac{x}{-t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 3
Error18.7
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -1.16 \cdot 10^{+64}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{-73}:\\ \;\;\;\;\frac{\frac{x}{z}}{-t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 4
Error29.7
Cost192
\[\frac{x}{y} \]

Error

Reproduce

herbie shell --seed 2023010 
(FPCore (x y z t)
  :name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, B"
  :precision binary64

  :herbie-target
  (if (< x -1.618195973607049e+50) (/ 1.0 (- (/ y x) (* (/ z x) t))) (if (< x 2.1378306434876444e+131) (/ x (- y (* z t))) (/ 1.0 (- (/ y x) (* (/ z x) t)))))

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