?

Average Error: 12.6 → 0.2
Time: 6.6s
Precision: binary64
Cost: 2513

?

\[\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:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{elif}\;t_0 \leq -5 \cdot 10^{+31} \lor \neg \left(t_0 \leq 5 \cdot 10^{-8}\right) \land t_0 \leq 10^{+297}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \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))
     (* (- y z) (/ x y))
     (if (or (<= t_0 -5e+31) (and (not (<= t_0 5e-8)) (<= t_0 1e+297)))
       t_0
       (- x (/ x (/ y z)))))))
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 = (y - z) * (x / y);
	} else if ((t_0 <= -5e+31) || (!(t_0 <= 5e-8) && (t_0 <= 1e+297))) {
		tmp = t_0;
	} else {
		tmp = x - (x / (y / z));
	}
	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 = (y - z) * (x / y);
	} else if ((t_0 <= -5e+31) || (!(t_0 <= 5e-8) && (t_0 <= 1e+297))) {
		tmp = t_0;
	} else {
		tmp = x - (x / (y / z));
	}
	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 = (y - z) * (x / y)
	elif (t_0 <= -5e+31) or (not (t_0 <= 5e-8) and (t_0 <= 1e+297)):
		tmp = t_0
	else:
		tmp = x - (x / (y / z))
	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(y - z) * Float64(x / y));
	elseif ((t_0 <= -5e+31) || (!(t_0 <= 5e-8) && (t_0 <= 1e+297)))
		tmp = t_0;
	else
		tmp = Float64(x - Float64(x / Float64(y / z)));
	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 = (y - z) * (x / y);
	elseif ((t_0 <= -5e+31) || (~((t_0 <= 5e-8)) && (t_0 <= 1e+297)))
		tmp = t_0;
	else
		tmp = x - (x / (y / z));
	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[(y - z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$0, -5e+31], And[N[Not[LessEqual[t$95$0, 5e-8]], $MachinePrecision], LessEqual[t$95$0, 1e+297]]], t$95$0, N[(x - N[(x / N[(y / z), $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:\\
\;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\

\mathbf{elif}\;t_0 \leq -5 \cdot 10^{+31} \lor \neg \left(t_0 \leq 5 \cdot 10^{-8}\right) \land t_0 \leq 10^{+297}:\\
\;\;\;\;t_0\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.6
Target3.0
Herbie0.2
\[\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. Simplified0.1

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

      [Start]64.0

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

      *-commutative [=>]64.0

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

      associate-*r/ [<=]0.1

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

    if -inf.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < -5.00000000000000027e31 or 4.9999999999999998e-8 < (/.f64 (*.f64 x (-.f64 y z)) y) < 1e297

    1. Initial program 0.2

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

    if -5.00000000000000027e31 < (/.f64 (*.f64 x (-.f64 y z)) y) < 4.9999999999999998e-8 or 1e297 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 14.9

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

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

      [Start]14.9

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

      associate-*r/ [<=]0.3

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

      div-sub [=>]0.3

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

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

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

      *-inverses [=>]0.3

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

      *-lft-identity [=>]0.3

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

      associate-*l/ [=>]6.2

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

      *-commutative [<=]6.2

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

      associate-/l* [=>]0.2

      \[ x - \color{blue}{\frac{x}{\frac{y}{z}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.2

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

Alternatives

Alternative 1
Error1.6
Cost7300
\[\begin{array}{l} t_0 := \frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{if}\;t_0 \leq -2 \cdot 10^{+294}:\\ \;\;\;\;\mathsf{fma}\left(x, -\frac{z}{y}, x\right)\\ \mathbf{elif}\;t_0 \leq -1 \cdot 10^{-40}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq 10^{-8}:\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y - z}{\frac{y}{x}}\\ \end{array} \]
Alternative 2
Error1.5
Cost1996
\[\begin{array}{l} t_0 := \frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{elif}\;t_0 \leq -1 \cdot 10^{-40}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq 10^{-8}:\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y - z}{\frac{y}{x}}\\ \end{array} \]
Alternative 3
Error19.9
Cost1178
\[\begin{array}{l} \mathbf{if}\;y \leq -7.5 \cdot 10^{+52}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.35 \cdot 10^{-26} \lor \neg \left(y \leq -8.5 \cdot 10^{-95}\right) \land \left(y \leq 5.8 \cdot 10^{-115} \lor \neg \left(y \leq 2.55 \cdot 10^{-81}\right) \land y \leq 4.5 \cdot 10^{-35}\right):\\ \;\;\;\;z \cdot \frac{-x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error19.9
Cost1177
\[\begin{array}{l} \mathbf{if}\;y \leq -2.4 \cdot 10^{+61}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -4.5 \cdot 10^{-27}:\\ \;\;\;\;x \cdot \left(-\frac{z}{y}\right)\\ \mathbf{elif}\;y \leq -7.5 \cdot 10^{-94}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4 \cdot 10^{-115} \lor \neg \left(y \leq 1.4 \cdot 10^{-79}\right) \land y \leq 1.26 \cdot 10^{-29}:\\ \;\;\;\;z \cdot \frac{-x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error19.2
Cost912
\[\begin{array}{l} \mathbf{if}\;y \leq -1.25 \cdot 10^{+61}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -2.4 \cdot 10^{-24}:\\ \;\;\;\;x \cdot \left(-\frac{z}{y}\right)\\ \mathbf{elif}\;y \leq -2.4 \cdot 10^{-77}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{-29}:\\ \;\;\;\;\frac{x \cdot \left(-z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error3.3
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -2.15 \cdot 10^{-165} \lor \neg \left(y \leq 3 \cdot 10^{-41}\right):\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \end{array} \]
Alternative 7
Error7.8
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.28 \cdot 10^{+123}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{+183}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error26.1
Cost64
\[x \]

Error

Reproduce?

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