?

Average Accuracy: 67.0% → 80.9%
Time: 10.1s
Precision: binary64
Cost: 1480

?

\[\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 -1 \cdot 10^{+297}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{elif}\;t_0 \leq -1 \cdot 10^{-77}:\\ \;\;\;\;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 -1e+297)
     (* (- y z) (/ x y))
     (if (<= t_0 -1e-77) 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 <= -1e+297) {
		tmp = (y - z) * (x / y);
	} else if (t_0 <= -1e-77) {
		tmp = t_0;
	} else {
		tmp = x - (x / (y / z));
	}
	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 <= (-1d+297)) then
        tmp = (y - z) * (x / y)
    else if (t_0 <= (-1d-77)) then
        tmp = t_0
    else
        tmp = x - (x / (y / z))
    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 <= -1e+297) {
		tmp = (y - z) * (x / y);
	} else if (t_0 <= -1e-77) {
		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 <= -1e+297:
		tmp = (y - z) * (x / y)
	elif t_0 <= -1e-77:
		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 <= -1e+297)
		tmp = Float64(Float64(y - z) * Float64(x / y));
	elseif (t_0 <= -1e-77)
		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 <= -1e+297)
		tmp = (y - z) * (x / y);
	elseif (t_0 <= -1e-77)
		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, -1e+297], N[(N[(y - z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -1e-77], 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 -1 \cdot 10^{+297}:\\
\;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\

\mathbf{elif}\;t_0 \leq -1 \cdot 10^{-77}:\\
\;\;\;\;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

Original67.0%
Target79.3%
Herbie80.9%
\[\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) < -1e297

    1. Initial program 2.4%

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

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(y - z\right)} \]
      Step-by-step derivation

      [Start]2.4

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

      associate-*l/ [<=]22.0

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

    if -1e297 < (/.f64 (*.f64 x (-.f64 y z)) y) < -9.9999999999999993e-78

    1. Initial program 99.7%

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

    if -9.9999999999999993e-78 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 78.5%

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

      \[\leadsto \color{blue}{x - z \cdot \frac{x}{y}} \]
      Step-by-step derivation

      [Start]78.5

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

      associate-*l/ [<=]69.0

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

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

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

      associate-*r/ [=>]76.6

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

      associate-*l/ [<=]85.7

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

      *-inverses [=>]85.7

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

      *-lft-identity [=>]85.7

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

      \[\leadsto x - \color{blue}{\frac{z \cdot x}{y}} \]
    4. Simplified90.3%

      \[\leadsto x - \color{blue}{\frac{x}{\frac{y}{z}}} \]
      Step-by-step derivation

      [Start]85.0

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

      *-commutative [=>]85.0

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

      associate-/l* [=>]90.3

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

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

Alternatives

Alternative 1
Accuracy72.3%
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -3.9 \cdot 10^{+206}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 7.8 \cdot 10^{+73}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Accuracy58.8%
Cost649
\[\begin{array}{l} \mathbf{if}\;z \leq -8.5 \cdot 10^{+134} \lor \neg \left(z \leq 9.5 \cdot 10^{+41}\right):\\ \;\;\;\;z \cdot \frac{-x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Accuracy58.7%
Cost648
\[\begin{array}{l} \mathbf{if}\;z \leq -6.5 \cdot 10^{+134}:\\ \;\;\;\;\frac{-z}{\frac{y}{x}}\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{+42}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{-x}{y}\\ \end{array} \]
Alternative 4
Accuracy77.2%
Cost448
\[x - z \cdot \frac{x}{y} \]
Alternative 5
Accuracy79.4%
Cost448
\[x - \frac{x}{\frac{y}{z}} \]
Alternative 6
Accuracy50.6%
Cost64
\[x \]

Error

Reproduce?

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