?

Average Accuracy: 80.4% → 99.0%
Time: 7.1s
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 -5 \cdot 10^{+283}:\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \mathbf{elif}\;t_0 \leq -1 \cdot 10^{+31} \lor \neg \left(t_0 \leq 10^{+39}\right) \land t_0 \leq 10^{+266}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot \frac{z}{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 (<= t_0 -5e+283)
     (- x (/ x (/ y z)))
     (if (or (<= t_0 -1e+31) (and (not (<= t_0 1e+39)) (<= t_0 1e+266)))
       t_0
       (- x (* x (/ z 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 <= -5e+283) {
		tmp = x - (x / (y / z));
	} else if ((t_0 <= -1e+31) || (!(t_0 <= 1e+39) && (t_0 <= 1e+266))) {
		tmp = t_0;
	} else {
		tmp = x - (x * (z / y));
	}
	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 <= (-5d+283)) then
        tmp = x - (x / (y / z))
    else if ((t_0 <= (-1d+31)) .or. (.not. (t_0 <= 1d+39)) .and. (t_0 <= 1d+266)) then
        tmp = t_0
    else
        tmp = x - (x * (z / y))
    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 <= -5e+283) {
		tmp = x - (x / (y / z));
	} else if ((t_0 <= -1e+31) || (!(t_0 <= 1e+39) && (t_0 <= 1e+266))) {
		tmp = t_0;
	} else {
		tmp = x - (x * (z / 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 <= -5e+283:
		tmp = x - (x / (y / z))
	elif (t_0 <= -1e+31) or (not (t_0 <= 1e+39) and (t_0 <= 1e+266)):
		tmp = t_0
	else:
		tmp = x - (x * (z / 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 <= -5e+283)
		tmp = Float64(x - Float64(x / Float64(y / z)));
	elseif ((t_0 <= -1e+31) || (!(t_0 <= 1e+39) && (t_0 <= 1e+266)))
		tmp = t_0;
	else
		tmp = Float64(x - Float64(x * Float64(z / 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 <= -5e+283)
		tmp = x - (x / (y / z));
	elseif ((t_0 <= -1e+31) || (~((t_0 <= 1e+39)) && (t_0 <= 1e+266)))
		tmp = t_0;
	else
		tmp = x - (x * (z / 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[LessEqual[t$95$0, -5e+283], N[(x - N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$0, -1e+31], And[N[Not[LessEqual[t$95$0, 1e+39]], $MachinePrecision], LessEqual[t$95$0, 1e+266]]], t$95$0, N[(x - N[(x * N[(z / 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 -5 \cdot 10^{+283}:\\
\;\;\;\;x - \frac{x}{\frac{y}{z}}\\

\mathbf{elif}\;t_0 \leq -1 \cdot 10^{+31} \lor \neg \left(t_0 \leq 10^{+39}\right) \land t_0 \leq 10^{+266}:\\
\;\;\;\;t_0\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original80.4%
Target95.0%
Herbie99.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 3 regimes
  2. if (/.f64 (*.f64 x (-.f64 y z)) y) < -5.0000000000000004e283

    1. Initial program 15.7%

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

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

      [Start]15.7

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

      associate-*r/ [<=]96.9

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

      div-sub [=>]96.9

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

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

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

      *-inverses [=>]96.9

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

      *-lft-identity [=>]96.9

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

      associate-*l/ [=>]69.1

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

      *-commutative [<=]69.1

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

      associate-/l* [=>]97.1

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

    if -5.0000000000000004e283 < (/.f64 (*.f64 x (-.f64 y z)) y) < -9.9999999999999996e30 or 9.9999999999999994e38 < (/.f64 (*.f64 x (-.f64 y z)) y) < 1e266

    1. Initial program 99.7%

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

    if -9.9999999999999996e30 < (/.f64 (*.f64 x (-.f64 y z)) y) < 9.9999999999999994e38 or 1e266 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 79.6%

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

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

      [Start]79.6

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

      associate-*r/ [<=]98.8

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

      div-sub [=>]98.8

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

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

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

      *-inverses [=>]98.9

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

      *-lft-identity [=>]98.9

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

      associate-*l/ [=>]91.8

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

      *-commutative [<=]91.8

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

      associate-/l* [=>]98.9

      \[ x - \color{blue}{\frac{x}{\frac{y}{z}}} \]
    3. Applied egg-rr98.9%

      \[\leadsto x - \color{blue}{\frac{z}{y} \cdot x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.0%

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

Alternatives

Alternative 1
Accuracy70.2%
Cost1179
\[\begin{array}{l} \mathbf{if}\;z \leq -3.7 \cdot 10^{+56} \lor \neg \left(z \leq -3.9 \cdot 10^{+24} \lor \neg \left(z \leq -4.3 \cdot 10^{-14}\right) \land \left(z \leq 0.0027 \lor \neg \left(z \leq 2.6 \cdot 10^{+38}\right) \land z \leq 1.8 \cdot 10^{+60}\right)\right):\\ \;\;\;\;z \cdot \left(-\frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Accuracy70.2%
Cost1177
\[\begin{array}{l} t_0 := z \cdot \left(-\frac{x}{y}\right)\\ \mathbf{if}\;z \leq -4.2 \cdot 10^{+56}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -4.4 \cdot 10^{+24}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{-14}:\\ \;\;\;\;x \cdot \left(-\frac{z}{y}\right)\\ \mathbf{elif}\;z \leq 0.016:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{+38} \lor \neg \left(z \leq 1.4 \cdot 10^{+60}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Accuracy70.2%
Cost1176
\[\begin{array}{l} t_0 := z \cdot \left(-\frac{x}{y}\right)\\ \mathbf{if}\;z \leq -3.8 \cdot 10^{+56}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{+24}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -4.4 \cdot 10^{-14}:\\ \;\;\;\;x \cdot \left(-\frac{z}{y}\right)\\ \mathbf{elif}\;z \leq 0.009:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{+38}:\\ \;\;\;\;\frac{x}{\frac{-y}{z}}\\ \mathbf{elif}\;z \leq 1.46 \cdot 10^{+60}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Accuracy70.2%
Cost1176
\[\begin{array}{l} \mathbf{if}\;z \leq -4.5 \cdot 10^{+56}:\\ \;\;\;\;\frac{x \cdot \left(-z\right)}{y}\\ \mathbf{elif}\;z \leq -4.4 \cdot 10^{+24}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -4 \cdot 10^{-14}:\\ \;\;\;\;x \cdot \left(-\frac{z}{y}\right)\\ \mathbf{elif}\;z \leq 0.0078:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.85 \cdot 10^{+38}:\\ \;\;\;\;\frac{x}{\frac{-y}{z}}\\ \mathbf{elif}\;z \leq 8.2 \cdot 10^{+60}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-\frac{x}{y}\right)\\ \end{array} \]
Alternative 5
Accuracy94.0%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -3.5 \cdot 10^{-298} \lor \neg \left(x \leq 8.2 \cdot 10^{-297}\right):\\ \;\;\;\;x - x \cdot \frac{z}{y}\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-\frac{x}{y}\right)\\ \end{array} \]
Alternative 6
Accuracy58.9%
Cost64
\[x \]

Error

Reproduce?

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