Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3

Percentage Accurate: 84.7% → 96.2%
Time: 5.2s
Alternatives: 10
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \frac{x \cdot \left(y - z\right)}{y} \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
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
public static double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
def code(x, y, z):
	return (x * (y - z)) / y
function code(x, y, z)
	return Float64(Float64(x * Float64(y - z)) / y)
end
function tmp = code(x, y, z)
	tmp = (x * (y - z)) / y;
end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}

\\
\frac{x \cdot \left(y - z\right)}{y}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 10 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 84.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x \cdot \left(y - z\right)}{y} \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
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
public static double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
def code(x, y, z):
	return (x * (y - z)) / y
function code(x, y, z)
	return Float64(Float64(x * Float64(y - z)) / y)
end
function tmp = code(x, y, z)
	tmp = (x * (y - z)) / y;
end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}

\\
\frac{x \cdot \left(y - z\right)}{y}
\end{array}

Alternative 1: 96.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x}{\frac{y}{y - z}} \end{array} \]
(FPCore (x y z) :precision binary64 (/ x (/ y (- y z))))
double code(double x, double y, double z) {
	return x / (y / (y - z));
}
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 / (y - z))
end function
public static double code(double x, double y, double z) {
	return x / (y / (y - z));
}
def code(x, y, z):
	return x / (y / (y - z))
function code(x, y, z)
	return Float64(x / Float64(y / Float64(y - z)))
end
function tmp = code(x, y, z)
	tmp = x / (y / (y - z));
end
code[x_, y_, z_] := N[(x / N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x}{\frac{y}{y - z}}
\end{array}
Derivation
  1. Initial program 82.5%

    \[\frac{x \cdot \left(y - z\right)}{y} \]
  2. Step-by-step derivation
    1. associate-/l*98.1%

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
  3. Simplified98.1%

    \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
  4. Final simplification98.1%

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

Alternative 2: 71.5% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.45 \cdot 10^{+32} \lor \neg \left(z \leq 4.9 \cdot 10^{-29}\right):\\ \;\;\;\;x \cdot \frac{-z}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -1.45e+32) (not (<= z 4.9e-29))) (* x (/ (- z) y)) x))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.45e+32) || !(z <= 4.9e-29)) {
		tmp = x * (-z / y);
	} else {
		tmp = x;
	}
	return tmp;
}
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 ((z <= (-1.45d+32)) .or. (.not. (z <= 4.9d-29))) then
        tmp = x * (-z / y)
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.45e+32) || !(z <= 4.9e-29)) {
		tmp = x * (-z / y);
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -1.45e+32) or not (z <= 4.9e-29):
		tmp = x * (-z / y)
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -1.45e+32) || !(z <= 4.9e-29))
		tmp = Float64(x * Float64(Float64(-z) / y));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -1.45e+32) || ~((z <= 4.9e-29)))
		tmp = x * (-z / y);
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.45e+32], N[Not[LessEqual[z, 4.9e-29]], $MachinePrecision]], N[(x * N[((-z) / y), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.45 \cdot 10^{+32} \lor \neg \left(z \leq 4.9 \cdot 10^{-29}\right):\\
\;\;\;\;x \cdot \frac{-z}{y}\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.45000000000000001e32 or 4.8999999999999998e-29 < z

    1. Initial program 87.2%

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Step-by-step derivation
      1. associate-*r/94.6%

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

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

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{z}{y}\right)} \]
    5. Step-by-step derivation
      1. neg-mul-172.0%

        \[\leadsto x \cdot \color{blue}{\left(-\frac{z}{y}\right)} \]
      2. distribute-neg-frac72.0%

        \[\leadsto x \cdot \color{blue}{\frac{-z}{y}} \]
    6. Simplified72.0%

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

    if -1.45000000000000001e32 < z < 4.8999999999999998e-29

    1. Initial program 77.9%

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Step-by-step derivation
      1. associate-/l*99.9%

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    4. Taylor expanded in y around inf 79.6%

      \[\leadsto \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification75.8%

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

Alternative 3: 71.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.8 \cdot 10^{+36} \lor \neg \left(z \leq 1.35 \cdot 10^{-30}\right):\\ \;\;\;\;\frac{x}{\frac{-y}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -1.8e+36) (not (<= z 1.35e-30))) (/ x (/ (- y) z)) x))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.8e+36) || !(z <= 1.35e-30)) {
		tmp = x / (-y / z);
	} else {
		tmp = x;
	}
	return tmp;
}
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 ((z <= (-1.8d+36)) .or. (.not. (z <= 1.35d-30))) then
        tmp = x / (-y / z)
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.8e+36) || !(z <= 1.35e-30)) {
		tmp = x / (-y / z);
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -1.8e+36) or not (z <= 1.35e-30):
		tmp = x / (-y / z)
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -1.8e+36) || !(z <= 1.35e-30))
		tmp = Float64(x / Float64(Float64(-y) / z));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -1.8e+36) || ~((z <= 1.35e-30)))
		tmp = x / (-y / z);
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.8e+36], N[Not[LessEqual[z, 1.35e-30]], $MachinePrecision]], N[(x / N[((-y) / z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.8 \cdot 10^{+36} \lor \neg \left(z \leq 1.35 \cdot 10^{-30}\right):\\
\;\;\;\;\frac{x}{\frac{-y}{z}}\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.7999999999999999e36 or 1.34999999999999994e-30 < z

    1. Initial program 87.2%

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Step-by-step derivation
      1. associate-/l*96.1%

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    3. Simplified96.1%

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    4. Taylor expanded in y around 0 73.5%

      \[\leadsto \frac{x}{\color{blue}{-1 \cdot \frac{y}{z}}} \]
    5. Step-by-step derivation
      1. mul-1-neg73.5%

        \[\leadsto \frac{x}{\color{blue}{-\frac{y}{z}}} \]
      2. distribute-frac-neg73.5%

        \[\leadsto \frac{x}{\color{blue}{\frac{-y}{z}}} \]
    6. Simplified73.5%

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

    if -1.7999999999999999e36 < z < 1.34999999999999994e-30

    1. Initial program 77.9%

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Step-by-step derivation
      1. associate-/l*99.9%

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    4. Taylor expanded in y around inf 79.6%

      \[\leadsto \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification76.6%

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

Alternative 4: 72.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -8.8 \cdot 10^{+33}:\\ \;\;\;\;\left(-z\right) \cdot \frac{x}{y}\\ \mathbf{elif}\;z \leq 8.8 \cdot 10^{-29}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{-z}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -8.8e+33)
   (* (- z) (/ x y))
   (if (<= z 8.8e-29) x (* x (/ (- z) y)))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -8.8e+33) {
		tmp = -z * (x / y);
	} else if (z <= 8.8e-29) {
		tmp = x;
	} else {
		tmp = 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
    real(8) :: tmp
    if (z <= (-8.8d+33)) then
        tmp = -z * (x / y)
    else if (z <= 8.8d-29) then
        tmp = x
    else
        tmp = x * (-z / y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -8.8e+33) {
		tmp = -z * (x / y);
	} else if (z <= 8.8e-29) {
		tmp = x;
	} else {
		tmp = x * (-z / y);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -8.8e+33:
		tmp = -z * (x / y)
	elif z <= 8.8e-29:
		tmp = x
	else:
		tmp = x * (-z / y)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -8.8e+33)
		tmp = Float64(Float64(-z) * Float64(x / y));
	elseif (z <= 8.8e-29)
		tmp = x;
	else
		tmp = Float64(x * Float64(Float64(-z) / y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -8.8e+33)
		tmp = -z * (x / y);
	elseif (z <= 8.8e-29)
		tmp = x;
	else
		tmp = x * (-z / y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -8.8e+33], N[((-z) * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 8.8e-29], x, N[(x * N[((-z) / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.8 \cdot 10^{+33}:\\
\;\;\;\;\left(-z\right) \cdot \frac{x}{y}\\

\mathbf{elif}\;z \leq 8.8 \cdot 10^{-29}:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -8.79999999999999975e33

    1. Initial program 87.9%

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Step-by-step derivation
      1. associate-/l*95.8%

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    3. Simplified95.8%

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    4. Taylor expanded in y around 0 76.9%

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot z}{y}} \]
    5. Step-by-step derivation
      1. mul-1-neg76.9%

        \[\leadsto \color{blue}{-\frac{x \cdot z}{y}} \]
      2. associate-*l/74.7%

        \[\leadsto -\color{blue}{\frac{x}{y} \cdot z} \]
      3. distribute-rgt-neg-out74.7%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(-z\right)} \]
    6. Simplified74.7%

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

    if -8.79999999999999975e33 < z < 8.79999999999999961e-29

    1. Initial program 77.9%

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Step-by-step derivation
      1. associate-/l*99.9%

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    4. Taylor expanded in y around inf 79.6%

      \[\leadsto \color{blue}{x} \]

    if 8.79999999999999961e-29 < z

    1. Initial program 86.4%

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Step-by-step derivation
      1. associate-*r/94.9%

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

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

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{z}{y}\right)} \]
    5. Step-by-step derivation
      1. neg-mul-169.4%

        \[\leadsto x \cdot \color{blue}{\left(-\frac{z}{y}\right)} \]
      2. distribute-neg-frac69.4%

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

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

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

Alternative 5: 72.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -4.05 \cdot 10^{+33}:\\ \;\;\;\;\frac{x \cdot \left(-z\right)}{y}\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{-37}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{-y}{z}}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -4.05e+33)
   (/ (* x (- z)) y)
   (if (<= z 7.2e-37) x (/ x (/ (- y) z)))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -4.05e+33) {
		tmp = (x * -z) / y;
	} else if (z <= 7.2e-37) {
		tmp = x;
	} else {
		tmp = 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
    real(8) :: tmp
    if (z <= (-4.05d+33)) then
        tmp = (x * -z) / y
    else if (z <= 7.2d-37) then
        tmp = x
    else
        tmp = x / (-y / z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -4.05e+33) {
		tmp = (x * -z) / y;
	} else if (z <= 7.2e-37) {
		tmp = x;
	} else {
		tmp = x / (-y / z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -4.05e+33:
		tmp = (x * -z) / y
	elif z <= 7.2e-37:
		tmp = x
	else:
		tmp = x / (-y / z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -4.05e+33)
		tmp = Float64(Float64(x * Float64(-z)) / y);
	elseif (z <= 7.2e-37)
		tmp = x;
	else
		tmp = Float64(x / Float64(Float64(-y) / z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -4.05e+33)
		tmp = (x * -z) / y;
	elseif (z <= 7.2e-37)
		tmp = x;
	else
		tmp = x / (-y / z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -4.05e+33], N[(N[(x * (-z)), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[z, 7.2e-37], x, N[(x / N[((-y) / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.05 \cdot 10^{+33}:\\
\;\;\;\;\frac{x \cdot \left(-z\right)}{y}\\

\mathbf{elif}\;z \leq 7.2 \cdot 10^{-37}:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -4.05000000000000015e33

    1. Initial program 87.9%

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Step-by-step derivation
      1. associate-/l*95.8%

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    3. Simplified95.8%

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    4. Taylor expanded in y around 0 76.9%

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot z}{y}} \]
    5. Step-by-step derivation
      1. associate-*r/76.9%

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(x \cdot z\right)}{y}} \]
      2. mul-1-neg76.9%

        \[\leadsto \frac{\color{blue}{-x \cdot z}}{y} \]
      3. distribute-rgt-neg-out76.9%

        \[\leadsto \frac{\color{blue}{x \cdot \left(-z\right)}}{y} \]
    6. Simplified76.9%

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

    if -4.05000000000000015e33 < z < 7.20000000000000014e-37

    1. Initial program 77.9%

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Step-by-step derivation
      1. associate-/l*99.9%

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    4. Taylor expanded in y around inf 79.6%

      \[\leadsto \color{blue}{x} \]

    if 7.20000000000000014e-37 < z

    1. Initial program 86.4%

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Step-by-step derivation
      1. associate-/l*96.5%

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    3. Simplified96.5%

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    4. Taylor expanded in y around 0 71.1%

      \[\leadsto \frac{x}{\color{blue}{-1 \cdot \frac{y}{z}}} \]
    5. Step-by-step derivation
      1. mul-1-neg71.1%

        \[\leadsto \frac{x}{\color{blue}{-\frac{y}{z}}} \]
      2. distribute-frac-neg71.1%

        \[\leadsto \frac{x}{\color{blue}{\frac{-y}{z}}} \]
    6. Simplified71.1%

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

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

Alternative 6: 52.8% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{-36}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-229}:\\ \;\;\;\;y \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -5e-36) x (if (<= y 1.1e-229) (* y (/ x y)) x)))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -5e-36) {
		tmp = x;
	} else if (y <= 1.1e-229) {
		tmp = y * (x / y);
	} else {
		tmp = x;
	}
	return tmp;
}
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 (y <= (-5d-36)) then
        tmp = x
    else if (y <= 1.1d-229) then
        tmp = y * (x / y)
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -5e-36) {
		tmp = x;
	} else if (y <= 1.1e-229) {
		tmp = y * (x / y);
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -5e-36:
		tmp = x
	elif y <= 1.1e-229:
		tmp = y * (x / y)
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -5e-36)
		tmp = x;
	elseif (y <= 1.1e-229)
		tmp = Float64(y * Float64(x / y));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -5e-36)
		tmp = x;
	elseif (y <= 1.1e-229)
		tmp = y * (x / y);
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -5e-36], x, If[LessEqual[y, 1.1e-229], N[(y * N[(x / y), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-36}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 1.1 \cdot 10^{-229}:\\
\;\;\;\;y \cdot \frac{x}{y}\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.00000000000000004e-36 or 1.0999999999999999e-229 < y

    1. Initial program 80.4%

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Step-by-step derivation
      1. associate-/l*99.9%

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    4. Taylor expanded in y around inf 66.4%

      \[\leadsto \color{blue}{x} \]

    if -5.00000000000000004e-36 < y < 1.0999999999999999e-229

    1. Initial program 88.0%

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Taylor expanded in y around inf 11.0%

      \[\leadsto \frac{\color{blue}{x \cdot y}}{y} \]
    3. Step-by-step derivation
      1. associate-/l*13.9%

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{y}}} \]
      2. associate-/r/29.7%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot y} \]
    4. Applied egg-rr29.7%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification56.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{-36}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-229}:\\ \;\;\;\;y \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 7: 52.6% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -9.2 \cdot 10^{-92}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 6.4 \cdot 10^{-236}:\\ \;\;\;\;\frac{y}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -9.2e-92) x (if (<= y 6.4e-236) (/ y (/ y x)) x)))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -9.2e-92) {
		tmp = x;
	} else if (y <= 6.4e-236) {
		tmp = y / (y / x);
	} else {
		tmp = x;
	}
	return tmp;
}
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 (y <= (-9.2d-92)) then
        tmp = x
    else if (y <= 6.4d-236) then
        tmp = y / (y / x)
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -9.2e-92) {
		tmp = x;
	} else if (y <= 6.4e-236) {
		tmp = y / (y / x);
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -9.2e-92:
		tmp = x
	elif y <= 6.4e-236:
		tmp = y / (y / x)
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -9.2e-92)
		tmp = x;
	elseif (y <= 6.4e-236)
		tmp = Float64(y / Float64(y / x));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -9.2e-92)
		tmp = x;
	elseif (y <= 6.4e-236)
		tmp = y / (y / x);
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -9.2e-92], x, If[LessEqual[y, 6.4e-236], N[(y / N[(y / x), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.2 \cdot 10^{-92}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 6.4 \cdot 10^{-236}:\\
\;\;\;\;\frac{y}{\frac{y}{x}}\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -9.20000000000000064e-92 or 6.3999999999999999e-236 < y

    1. Initial program 80.8%

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Step-by-step derivation
      1. associate-/l*99.9%

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    4. Taylor expanded in y around inf 64.0%

      \[\leadsto \color{blue}{x} \]

    if -9.20000000000000064e-92 < y < 6.3999999999999999e-236

    1. Initial program 87.7%

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Taylor expanded in y around inf 10.6%

      \[\leadsto \frac{\color{blue}{x \cdot y}}{y} \]
    3. Step-by-step derivation
      1. associate-/l*13.8%

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{y}}} \]
      2. associate-/r/31.9%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot y} \]
    4. Applied egg-rr31.9%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot y} \]
    5. Step-by-step derivation
      1. *-commutative31.9%

        \[\leadsto \color{blue}{y \cdot \frac{x}{y}} \]
      2. clear-num31.8%

        \[\leadsto y \cdot \color{blue}{\frac{1}{\frac{y}{x}}} \]
      3. un-div-inv31.9%

        \[\leadsto \color{blue}{\frac{y}{\frac{y}{x}}} \]
    6. Applied egg-rr31.9%

      \[\leadsto \color{blue}{\frac{y}{\frac{y}{x}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification56.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.2 \cdot 10^{-92}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 6.4 \cdot 10^{-236}:\\ \;\;\;\;\frac{y}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 8: 95.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x \cdot \frac{y - z}{y} \end{array} \]
(FPCore (x y z) :precision binary64 (* x (/ (- y z) y)))
double code(double x, double y, double z) {
	return x * ((y - z) / y);
}
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
public static double code(double x, double y, double z) {
	return x * ((y - z) / y);
}
def code(x, y, z):
	return x * ((y - z) / y)
function code(x, y, z)
	return Float64(x * Float64(Float64(y - z) / y))
end
function tmp = code(x, y, z)
	tmp = x * ((y - z) / y);
end
code[x_, y_, z_] := N[(x * N[(N[(y - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \frac{y - z}{y}
\end{array}
Derivation
  1. Initial program 82.5%

    \[\frac{x \cdot \left(y - z\right)}{y} \]
  2. Step-by-step derivation
    1. associate-*r/97.3%

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

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

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

Alternative 9: 96.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x - \frac{x}{\frac{y}{z}} \end{array} \]
(FPCore (x y z) :precision binary64 (- x (/ x (/ y z))))
double code(double x, double y, double z) {
	return x - (x / (y / z));
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x - (x / (y / z))
end function
public static double code(double x, double y, double z) {
	return x - (x / (y / z));
}
def code(x, y, z):
	return x - (x / (y / z))
function code(x, y, z)
	return Float64(x - Float64(x / Float64(y / z)))
end
function tmp = code(x, y, z)
	tmp = x - (x / (y / z));
end
code[x_, y_, z_] := N[(x - N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x - \frac{x}{\frac{y}{z}}
\end{array}
Derivation
  1. Initial program 82.5%

    \[\frac{x \cdot \left(y - z\right)}{y} \]
  2. Step-by-step derivation
    1. --rgt-identity82.5%

      \[\leadsto \color{blue}{\frac{x \cdot \left(y - z\right)}{y} - 0} \]
    2. associate-*l/85.3%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(y - z\right)} - 0 \]
    3. sub-neg85.3%

      \[\leadsto \frac{x}{y} \cdot \color{blue}{\left(y + \left(-z\right)\right)} - 0 \]
    4. distribute-rgt-in82.4%

      \[\leadsto \color{blue}{\left(y \cdot \frac{x}{y} + \left(-z\right) \cdot \frac{x}{y}\right)} - 0 \]
    5. *-commutative82.4%

      \[\leadsto \left(\color{blue}{\frac{x}{y} \cdot y} + \left(-z\right) \cdot \frac{x}{y}\right) - 0 \]
    6. distribute-lft-neg-out82.4%

      \[\leadsto \left(\frac{x}{y} \cdot y + \color{blue}{\left(-z \cdot \frac{x}{y}\right)}\right) - 0 \]
    7. unsub-neg82.4%

      \[\leadsto \color{blue}{\left(\frac{x}{y} \cdot y - z \cdot \frac{x}{y}\right)} - 0 \]
    8. associate--r+82.4%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot y - \left(z \cdot \frac{x}{y} + 0\right)} \]
    9. associate-*l/75.2%

      \[\leadsto \color{blue}{\frac{x \cdot y}{y}} - \left(z \cdot \frac{x}{y} + 0\right) \]
    10. associate-/l*92.6%

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y}}} - \left(z \cdot \frac{x}{y} + 0\right) \]
    11. *-inverses92.6%

      \[\leadsto \frac{x}{\color{blue}{1}} - \left(z \cdot \frac{x}{y} + 0\right) \]
    12. /-rgt-identity92.6%

      \[\leadsto \color{blue}{x} - \left(z \cdot \frac{x}{y} + 0\right) \]
    13. +-rgt-identity92.6%

      \[\leadsto x - \color{blue}{z \cdot \frac{x}{y}} \]
    14. *-commutative92.6%

      \[\leadsto x - \color{blue}{\frac{x}{y} \cdot z} \]
    15. associate-/r/98.0%

      \[\leadsto x - \color{blue}{\frac{x}{\frac{y}{z}}} \]
  3. Simplified98.0%

    \[\leadsto \color{blue}{x - \frac{x}{\frac{y}{z}}} \]
  4. Final simplification98.0%

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

Alternative 10: 50.6% accurate, 7.0× speedup?

\[\begin{array}{l} \\ x \end{array} \]
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
	return x;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x
end function
public static double code(double x, double y, double z) {
	return x;
}
def code(x, y, z):
	return x
function code(x, y, z)
	return x
end
function tmp = code(x, y, z)
	tmp = x;
end
code[x_, y_, z_] := x
\begin{array}{l}

\\
x
\end{array}
Derivation
  1. Initial program 82.5%

    \[\frac{x \cdot \left(y - z\right)}{y} \]
  2. Step-by-step derivation
    1. associate-/l*98.1%

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
  3. Simplified98.1%

    \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
  4. Taylor expanded in y around inf 51.6%

    \[\leadsto \color{blue}{x} \]
  5. Final simplification51.6%

    \[\leadsto x \]

Developer target: 95.7% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \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} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (< z -2.060202331921739e+104)
   (- x (/ (* z x) y))
   (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y)))))
double code(double x, double y, double z) {
	double tmp;
	if (z < -2.060202331921739e+104) {
		tmp = x - ((z * x) / y);
	} else if (z < 1.6939766013828526e+213) {
		tmp = x / (y / (y - z));
	} else {
		tmp = (y - z) * (x / 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
    real(8) :: tmp
    if (z < (-2.060202331921739d+104)) then
        tmp = x - ((z * x) / y)
    else if (z < 1.6939766013828526d+213) then
        tmp = x / (y / (y - z))
    else
        tmp = (y - z) * (x / y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z < -2.060202331921739e+104) {
		tmp = x - ((z * x) / y);
	} else if (z < 1.6939766013828526e+213) {
		tmp = x / (y / (y - z));
	} else {
		tmp = (y - z) * (x / y);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z < -2.060202331921739e+104:
		tmp = x - ((z * x) / y)
	elif z < 1.6939766013828526e+213:
		tmp = x / (y / (y - z))
	else:
		tmp = (y - z) * (x / y)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z < -2.060202331921739e+104)
		tmp = Float64(x - Float64(Float64(z * x) / y));
	elseif (z < 1.6939766013828526e+213)
		tmp = Float64(x / Float64(y / Float64(y - z)));
	else
		tmp = Float64(Float64(y - z) * Float64(x / y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z < -2.060202331921739e+104)
		tmp = x - ((z * x) / y);
	elseif (z < 1.6939766013828526e+213)
		tmp = x / (y / (y - z));
	else
		tmp = (y - z) * (x / y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Less[z, -2.060202331921739e+104], N[(x - N[(N[(z * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[Less[z, 1.6939766013828526e+213], N[(x / N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y - z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\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}
\end{array}

Reproduce

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