?

Average Accuracy: 81.0% → 96.1%
Time: 6.6s
Precision: binary64
Cost: 712

?

\[\frac{x \cdot \left(y - z\right)}{y} \]
\[\begin{array}{l} \mathbf{if}\;x \leq 1.45 \cdot 10^{-274}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-62}:\\ \;\;\;\;x - z \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
 :precision binary64
 (if (<= x 1.45e-274)
   (/ x (/ y (- y z)))
   (if (<= x 2e-62) (- x (* z (/ x y))) (* x (- 1.0 (/ z y))))))
double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
double code(double x, double y, double z) {
	double tmp;
	if (x <= 1.45e-274) {
		tmp = x / (y / (y - z));
	} else if (x <= 2e-62) {
		tmp = x - (z * (x / y));
	} else {
		tmp = x * (1.0 - (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) :: tmp
    if (x <= 1.45d-274) then
        tmp = x / (y / (y - z))
    else if (x <= 2d-62) then
        tmp = x - (z * (x / y))
    else
        tmp = x * (1.0d0 - (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 tmp;
	if (x <= 1.45e-274) {
		tmp = x / (y / (y - z));
	} else if (x <= 2e-62) {
		tmp = x - (z * (x / y));
	} else {
		tmp = x * (1.0 - (z / y));
	}
	return tmp;
}
def code(x, y, z):
	return (x * (y - z)) / y
def code(x, y, z):
	tmp = 0
	if x <= 1.45e-274:
		tmp = x / (y / (y - z))
	elif x <= 2e-62:
		tmp = x - (z * (x / y))
	else:
		tmp = x * (1.0 - (z / y))
	return tmp
function code(x, y, z)
	return Float64(Float64(x * Float64(y - z)) / y)
end
function code(x, y, z)
	tmp = 0.0
	if (x <= 1.45e-274)
		tmp = Float64(x / Float64(y / Float64(y - z)));
	elseif (x <= 2e-62)
		tmp = Float64(x - Float64(z * Float64(x / y)));
	else
		tmp = Float64(x * Float64(1.0 - 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)
	tmp = 0.0;
	if (x <= 1.45e-274)
		tmp = x / (y / (y - z));
	elseif (x <= 2e-62)
		tmp = x - (z * (x / y));
	else
		tmp = x * (1.0 - (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_] := If[LessEqual[x, 1.45e-274], N[(x / N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2e-62], N[(x - N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;x \leq 1.45 \cdot 10^{-274}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\

\mathbf{elif}\;x \leq 2 \cdot 10^{-62}:\\
\;\;\;\;x - z \cdot \frac{x}{y}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original81.0%
Target95.2%
Herbie96.1%
\[\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 x < 1.44999999999999988e-274

    1. Initial program 80.6%

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

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

      [Start]80.6

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

      associate-*l/ [<=]80.2

      \[ \color{blue}{\frac{x}{y} \cdot \left(y - z\right)} \]
    3. Applied egg-rr95.0%

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

      [Start]80.2

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

      associate-*l/ [=>]80.6

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

      associate-/l* [=>]95.0

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

    if 1.44999999999999988e-274 < x < 2.0000000000000001e-62

    1. Initial program 92.1%

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

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

      [Start]92.1

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

      associate-*l/ [<=]74.9

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

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

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

      associate-*r/ [=>]90.3

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

      associate-*l/ [<=]94.5

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

      *-inverses [=>]94.5

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

      *-lft-identity [=>]94.5

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

    if 2.0000000000000001e-62 < x

    1. Initial program 73.4%

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

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

      [Start]73.4

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

      associate-*l/ [<=]89.1

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

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

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

      associate-*r/ [=>]65.9

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

      associate-*l/ [<=]90.2

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

      *-inverses [=>]90.2

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

      *-lft-identity [=>]90.2

      \[ \color{blue}{x} - z \cdot \frac{x}{y} \]
    3. Taylor expanded in x around 0 99.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.45 \cdot 10^{-274}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-62}:\\ \;\;\;\;x - z \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\ \end{array} \]

Alternatives

Alternative 1
Accuracy95.8%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq 5.8 \cdot 10^{-273} \lor \neg \left(x \leq 2 \cdot 10^{-62}\right):\\ \;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot \frac{x}{y}\\ \end{array} \]
Alternative 2
Accuracy67.9%
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{+83}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{-108}:\\ \;\;\;\;z \cdot \frac{-x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Accuracy65.8%
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{+83}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.45 \cdot 10^{-108}:\\ \;\;\;\;x \cdot \frac{-z}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Accuracy66.2%
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{+83}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-108}:\\ \;\;\;\;\frac{-x}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Accuracy95.1%
Cost448
\[x \cdot \left(1 - \frac{z}{y}\right) \]
Alternative 6
Accuracy60.0%
Cost64
\[x \]

Error

Reproduce?

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