?

Average Accuracy: 80.4% → 96.0%
Time: 5.5s
Precision: binary64
Cost: 1481

?

\[\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 0 \lor \neg \left(t_0 \leq 4 \cdot 10^{+167}\right):\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \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 0.0) (not (<= t_0 4e+167))) (- x (/ x (/ y z))) t_0)))
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 <= 0.0) || !(t_0 <= 4e+167)) {
		tmp = x - (x / (y / z));
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * (y - z)) / y
end function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x * (y - z)) / y
    if ((t_0 <= 0.0d0) .or. (.not. (t_0 <= 4d+167))) then
        tmp = x - (x / (y / z))
    else
        tmp = t_0
    end if
    code = tmp
end function
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 <= 0.0) || !(t_0 <= 4e+167)) {
		tmp = x - (x / (y / z));
	} else {
		tmp = t_0;
	}
	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 <= 0.0) or not (t_0 <= 4e+167):
		tmp = x - (x / (y / z))
	else:
		tmp = t_0
	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 <= 0.0) || !(t_0 <= 4e+167))
		tmp = Float64(x - Float64(x / Float64(y / z)));
	else
		tmp = t_0;
	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 <= 0.0) || ~((t_0 <= 4e+167)))
		tmp = x - (x / (y / z));
	else
		tmp = t_0;
	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, 0.0], N[Not[LessEqual[t$95$0, 4e+167]], $MachinePrecision]], N[(x - N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\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 0 \lor \neg \left(t_0 \leq 4 \cdot 10^{+167}\right):\\
\;\;\;\;x - \frac{x}{\frac{y}{z}}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original80.4%
Target95.2%
Herbie96.0%
\[\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) < 0.0 or 4.0000000000000002e167 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 71.5%

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

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

      [Start]71.5

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

      associate-*r/ [<=]94.2

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

      div-sub [=>]94.2

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

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

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

      *-inverses [=>]94.2

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

      *-lft-identity [=>]94.2

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

      associate-*l/ [=>]89.1

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

      *-commutative [<=]89.1

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

      associate-/l* [=>]94.5

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

    if 0.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < 4.0000000000000002e167

    1. Initial program 99.3%

      \[\frac{x \cdot \left(y - z\right)}{y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification96.0%

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

Alternatives

Alternative 1
Accuracy68.6%
Cost913
\[\begin{array}{l} \mathbf{if}\;y \leq -4.6 \cdot 10^{+20}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -3.4 \cdot 10^{-74} \lor \neg \left(y \leq -6.4 \cdot 10^{-102}\right) \land y \leq 2.2 \cdot 10^{+29}:\\ \;\;\;\;\frac{x}{y} \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Accuracy68.8%
Cost912
\[\begin{array}{l} \mathbf{if}\;y \leq -4.6 \cdot 10^{+20}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.6 \cdot 10^{-76}:\\ \;\;\;\;\frac{x}{y} \cdot \left(-z\right)\\ \mathbf{elif}\;y \leq -3.2 \cdot 10^{-101}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.22 \cdot 10^{+28}:\\ \;\;\;\;\frac{-z}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Accuracy88.1%
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.45 \cdot 10^{+118}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+134}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Accuracy95.1%
Cost448
\[x - x \cdot \frac{z}{y} \]
Alternative 5
Accuracy95.5%
Cost448
\[x - \frac{x}{\frac{y}{z}} \]
Alternative 6
Accuracy59.9%
Cost64
\[x \]

Error

Reproduce?

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