Average Error: 12.6 → 2.3
Time: 14.0s
Precision: binary64
Cost: 1480
\[\frac{x \cdot \left(y - z\right)}{y} \]
\[\begin{array}{l} t_0 := \frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;\frac{x}{y} \cdot \left(y - z\right)\\ \mathbf{elif}\;t_0 \leq -4 \cdot 10^{+158}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \frac{z}{y}\right) \cdot x\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (* x (- y z)) y)))
   (if (<= t_0 (- INFINITY))
     (* (/ x y) (- y z))
     (if (<= t_0 -4e+158) t_0 (* (- 1.0 (/ z y)) x)))))
double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
double code(double x, double y, double z) {
	double t_0 = (x * (y - z)) / y;
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = (x / y) * (y - z);
	} else if (t_0 <= -4e+158) {
		tmp = t_0;
	} else {
		tmp = (1.0 - (z / y)) * x;
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
public static double code(double x, double y, double z) {
	double t_0 = (x * (y - z)) / y;
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = (x / y) * (y - z);
	} else if (t_0 <= -4e+158) {
		tmp = t_0;
	} else {
		tmp = (1.0 - (z / y)) * x;
	}
	return tmp;
}
def code(x, y, z):
	return (x * (y - z)) / y
def code(x, y, z):
	t_0 = (x * (y - z)) / y
	tmp = 0
	if t_0 <= -math.inf:
		tmp = (x / y) * (y - z)
	elif t_0 <= -4e+158:
		tmp = t_0
	else:
		tmp = (1.0 - (z / y)) * x
	return tmp
function code(x, y, z)
	return Float64(Float64(x * Float64(y - z)) / y)
end
function code(x, y, z)
	t_0 = Float64(Float64(x * Float64(y - z)) / y)
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(Float64(x / y) * Float64(y - z));
	elseif (t_0 <= -4e+158)
		tmp = t_0;
	else
		tmp = Float64(Float64(1.0 - Float64(z / y)) * x);
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = (x * (y - z)) / y;
end
function tmp_2 = code(x, y, z)
	t_0 = (x * (y - z)) / y;
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = (x / y) * (y - z);
	elseif (t_0 <= -4e+158)
		tmp = t_0;
	else
		tmp = (1.0 - (z / y)) * x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(x / y), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -4e+158], t$95$0, N[(N[(1.0 - N[(z / y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]]]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
t_0 := \frac{x \cdot \left(y - z\right)}{y}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\frac{x}{y} \cdot \left(y - z\right)\\

\mathbf{elif}\;t_0 \leq -4 \cdot 10^{+158}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\left(1 - \frac{z}{y}\right) \cdot x\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.6
Target2.9
Herbie2.3
\[\begin{array}{l} \mathbf{if}\;z < -2.060202331921739 \cdot 10^{+104}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{elif}\;z < 1.6939766013828526 \cdot 10^{+213}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \end{array} \]

Derivation

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

    1. Initial program 64.0

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Applied egg-rr0.2

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

    if -inf.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < -3.99999999999999981e158

    1. Initial program 0.2

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

    if -3.99999999999999981e158 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 9.4

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Taylor expanded in y around 0 4.0

      \[\leadsto \color{blue}{-1 \cdot \frac{z \cdot x}{y} + x} \]
    3. Simplified4.0

      \[\leadsto \color{blue}{\left(-\frac{z \cdot x}{y}\right) + x} \]
      Proof
    4. Taylor expanded in x around 0 2.7

      \[\leadsto \color{blue}{\left(1 - \frac{z}{y}\right) \cdot x} \]
  3. Recombined 3 regimes into one program.

Alternatives

Alternative 1
Error20.0
Cost648
\[\begin{array}{l} t_0 := \left(-\frac{z}{y}\right) \cdot x\\ \mathbf{if}\;z \leq -3.8 \cdot 10^{+111}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{+93}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error19.0
Cost648
\[\begin{array}{l} \mathbf{if}\;z \leq -2.7 \cdot 10^{+110}:\\ \;\;\;\;\left(-\frac{z}{y}\right) \cdot x\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+91}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(-z\right)\\ \end{array} \]
Alternative 3
Error3.3
Cost448
\[\left(1 - \frac{z}{y}\right) \cdot x \]
Alternative 4
Error25.0
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2023010 
(FPCore (x y z)
  :name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
  :precision binary64

  :herbie-target
  (if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))

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