Average Error: 12.5 → 1.8
Time: 7.6s
Precision: binary64
Cost: 1609
\[\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 \lor \neg \left(t_0 \leq -5 \cdot 10^{+95}\right):\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;x + \left(x \cdot z\right) \cdot \frac{-1}{y}\\ \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 (or (<= t_0 (- INFINITY)) (not (<= t_0 -5e+95)))
     (- x (/ x (/ y z)))
     (+ x (* (* x z) (/ -1.0 y))))))
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)) || !(t_0 <= -5e+95)) {
		tmp = x - (x / (y / z));
	} else {
		tmp = x + ((x * z) * (-1.0 / y));
	}
	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) || !(t_0 <= -5e+95)) {
		tmp = x - (x / (y / z));
	} else {
		tmp = x + ((x * z) * (-1.0 / y));
	}
	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) or not (t_0 <= -5e+95):
		tmp = x - (x / (y / z))
	else:
		tmp = x + ((x * z) * (-1.0 / y))
	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)) || !(t_0 <= -5e+95))
		tmp = Float64(x - Float64(x / Float64(y / z)));
	else
		tmp = Float64(x + Float64(Float64(x * z) * Float64(-1.0 / y)));
	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) || ~((t_0 <= -5e+95)))
		tmp = x - (x / (y / z));
	else
		tmp = x + ((x * z) * (-1.0 / y));
	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[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, -5e+95]], $MachinePrecision]], N[(x - N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(x * z), $MachinePrecision] * N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]), $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 \lor \neg \left(t_0 \leq -5 \cdot 10^{+95}\right):\\
\;\;\;\;x - \frac{x}{\frac{y}{z}}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.5
Target3.0
Herbie1.8
\[\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 2 regimes
  2. if (/.f64 (*.f64 x (-.f64 y z)) y) < -inf.0 or -5.00000000000000025e95 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 14.4

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

      \[\leadsto \color{blue}{x - \frac{x}{\frac{y}{z}}} \]
      Proof

      [Start]14.4

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

      associate-*r/ [<=]2.2

      \[ \color{blue}{x \cdot \frac{y - z}{y}} \]

      div-sub [=>]2.2

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

      distribute-rgt-out-- [<=]2.2

      \[ \color{blue}{\frac{y}{y} \cdot x - \frac{z}{y} \cdot x} \]

      *-inverses [=>]2.2

      \[ \color{blue}{1} \cdot x - \frac{z}{y} \cdot x \]

      *-lft-identity [=>]2.2

      \[ \color{blue}{x} - \frac{z}{y} \cdot x \]

      associate-*l/ [=>]5.2

      \[ x - \color{blue}{\frac{z \cdot x}{y}} \]

      *-commutative [<=]5.2

      \[ x - \frac{\color{blue}{x \cdot z}}{y} \]

      associate-/l* [=>]2.0

      \[ x - \color{blue}{\frac{x}{\frac{y}{z}}} \]

    if -inf.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < -5.00000000000000025e95

    1. Initial program 0.2

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Simplified9.1

      \[\leadsto \color{blue}{x - \frac{x}{\frac{y}{z}}} \]
      Proof

      [Start]0.2

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

      associate-*r/ [<=]9.8

      \[ \color{blue}{x \cdot \frac{y - z}{y}} \]

      div-sub [=>]9.8

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

      distribute-rgt-out-- [<=]9.8

      \[ \color{blue}{\frac{y}{y} \cdot x - \frac{z}{y} \cdot x} \]

      *-inverses [=>]9.8

      \[ \color{blue}{1} \cdot x - \frac{z}{y} \cdot x \]

      *-lft-identity [=>]9.8

      \[ \color{blue}{x} - \frac{z}{y} \cdot x \]

      associate-*l/ [=>]0.2

      \[ x - \color{blue}{\frac{z \cdot x}{y}} \]

      *-commutative [<=]0.2

      \[ x - \frac{\color{blue}{x \cdot z}}{y} \]

      associate-/l* [=>]9.1

      \[ x - \color{blue}{\frac{x}{\frac{y}{z}}} \]
    3. Applied egg-rr0.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq -\infty \lor \neg \left(\frac{x \cdot \left(y - z\right)}{y} \leq -5 \cdot 10^{+95}\right):\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;x + \left(x \cdot z\right) \cdot \frac{-1}{y}\\ \end{array} \]

Alternatives

Alternative 1
Error1.8
Cost1481
\[\begin{array}{l} t_0 := \frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{if}\;t_0 \leq -5 \cdot 10^{+303} \lor \neg \left(t_0 \leq -5 \cdot 10^{+95}\right):\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error19.3
Cost913
\[\begin{array}{l} \mathbf{if}\;y \leq -9 \cdot 10^{-64}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{-94} \lor \neg \left(y \leq 4.5 \cdot 10^{-24}\right) \land y \leq 6.8 \cdot 10^{+40}:\\ \;\;\;\;z \cdot \left(-\frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error19.3
Cost912
\[\begin{array}{l} \mathbf{if}\;y \leq -9.5 \cdot 10^{-63}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{-91}:\\ \;\;\;\;\frac{-z}{\frac{y}{x}}\\ \mathbf{elif}\;y \leq 5 \cdot 10^{-22}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.85 \cdot 10^{+41}:\\ \;\;\;\;z \cdot \left(-\frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error19.0
Cost912
\[\begin{array}{l} \mathbf{if}\;y \leq -1.02 \cdot 10^{-63}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{-103}:\\ \;\;\;\;\frac{x \cdot \left(-z\right)}{y}\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-23}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 7.3 \cdot 10^{+40}:\\ \;\;\;\;z \cdot \left(-\frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error8.3
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+90}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{+200}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error3.0
Cost448
\[x - \frac{x}{\frac{y}{z}} \]
Alternative 7
Error25.4
Cost64
\[x \]

Error

Reproduce

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