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

Percentage Accurate: 84.2% → 96.3%
Time: 4.7s
Alternatives: 6
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 6 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.2% 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.3% 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 84.2%

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

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

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

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

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

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

Alternative 2: 67.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{-25}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -4.3 \cdot 10^{-95} \lor \neg \left(y \leq -1.25 \cdot 10^{-146}\right) \land y \leq 9.5 \cdot 10^{-103}:\\ \;\;\;\;x \cdot \frac{-z}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -2e-25)
   x
   (if (or (<= y -4.3e-95) (and (not (<= y -1.25e-146)) (<= y 9.5e-103)))
     (* x (/ (- z) y))
     x)))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -2e-25) {
		tmp = x;
	} else if ((y <= -4.3e-95) || (!(y <= -1.25e-146) && (y <= 9.5e-103))) {
		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 (y <= (-2d-25)) then
        tmp = x
    else if ((y <= (-4.3d-95)) .or. (.not. (y <= (-1.25d-146))) .and. (y <= 9.5d-103)) 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 (y <= -2e-25) {
		tmp = x;
	} else if ((y <= -4.3e-95) || (!(y <= -1.25e-146) && (y <= 9.5e-103))) {
		tmp = x * (-z / y);
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -2e-25:
		tmp = x
	elif (y <= -4.3e-95) or (not (y <= -1.25e-146) and (y <= 9.5e-103)):
		tmp = x * (-z / y)
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -2e-25)
		tmp = x;
	elseif ((y <= -4.3e-95) || (!(y <= -1.25e-146) && (y <= 9.5e-103)))
		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 (y <= -2e-25)
		tmp = x;
	elseif ((y <= -4.3e-95) || (~((y <= -1.25e-146)) && (y <= 9.5e-103)))
		tmp = x * (-z / y);
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -2e-25], x, If[Or[LessEqual[y, -4.3e-95], And[N[Not[LessEqual[y, -1.25e-146]], $MachinePrecision], LessEqual[y, 9.5e-103]]], N[(x * N[((-z) / y), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -4.3 \cdot 10^{-95} \lor \neg \left(y \leq -1.25 \cdot 10^{-146}\right) \land y \leq 9.5 \cdot 10^{-103}:\\
\;\;\;\;x \cdot \frac{-z}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.00000000000000008e-25 or -4.29999999999999997e-95 < y < -1.24999999999999989e-146 or 9.50000000000000065e-103 < y

    1. Initial program 80.5%

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(\frac{y}{y} - \frac{z}{y}\right)} \]
      5. *-inverses99.3%

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

      \[\leadsto \color{blue}{x \cdot \left(1 - \frac{z}{y}\right)} \]
    4. Taylor expanded in z around 0 78.3%

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

    if -2.00000000000000008e-25 < y < -4.29999999999999997e-95 or -1.24999999999999989e-146 < y < 9.50000000000000065e-103

    1. Initial program 90.8%

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{y - z}{y}} \]
      4. div-sub92.8%

        \[\leadsto x \cdot \color{blue}{\left(\frac{y}{y} - \frac{z}{y}\right)} \]
      5. *-inverses92.8%

        \[\leadsto x \cdot \left(\color{blue}{1} - \frac{z}{y}\right) \]
    3. Simplified92.8%

      \[\leadsto \color{blue}{x \cdot \left(1 - \frac{z}{y}\right)} \]
    4. Taylor expanded in z around inf 78.0%

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

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

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

        \[\leadsto \frac{\color{blue}{x \cdot \left(-z\right)}}{y} \]
      4. associate-*r/76.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{-25}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -4.3 \cdot 10^{-95} \lor \neg \left(y \leq -1.25 \cdot 10^{-146}\right) \land y \leq 9.5 \cdot 10^{-103}:\\ \;\;\;\;x \cdot \frac{-z}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 3: 69.5% accurate, 0.5× speedup?

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

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

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

\mathbf{elif}\;y \leq -1.25 \cdot 10^{-146}:\\
\;\;\;\;x\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -8.50000000000000004e-26 or -1.95e-95 < y < -1.24999999999999989e-146 or 1.09999999999999995e-100 < y

    1. Initial program 80.5%

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(\frac{y}{y} - \frac{z}{y}\right)} \]
      5. *-inverses99.3%

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

      \[\leadsto \color{blue}{x \cdot \left(1 - \frac{z}{y}\right)} \]
    4. Taylor expanded in z around 0 78.3%

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

    if -8.50000000000000004e-26 < y < -1.95e-95

    1. Initial program 99.6%

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{y - z}{y}} \]
      4. div-sub99.9%

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

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

      \[\leadsto \color{blue}{x \cdot \left(1 - \frac{z}{y}\right)} \]
    4. Taylor expanded in z around inf 72.1%

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

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

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

        \[\leadsto \frac{\color{blue}{x \cdot \left(-z\right)}}{y} \]
      4. associate-*r/72.5%

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

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

    if -1.24999999999999989e-146 < y < 1.09999999999999995e-100

    1. Initial program 89.3%

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{y - z}{y}} \]
      4. div-sub91.5%

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

        \[\leadsto x \cdot \left(\color{blue}{1} - \frac{z}{y}\right) \]
    3. Simplified91.5%

      \[\leadsto \color{blue}{x \cdot \left(1 - \frac{z}{y}\right)} \]
    4. Taylor expanded in z around inf 79.0%

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

        \[\leadsto \color{blue}{-\frac{x \cdot z}{y}} \]
      2. *-commutative79.0%

        \[\leadsto -\frac{\color{blue}{z \cdot x}}{y} \]
      3. associate-*r/82.6%

        \[\leadsto -\color{blue}{z \cdot \frac{x}{y}} \]
      4. distribute-lft-neg-out82.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8.5 \cdot 10^{-26}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.95 \cdot 10^{-95}:\\ \;\;\;\;x \cdot \frac{-z}{y}\\ \mathbf{elif}\;y \leq -1.25 \cdot 10^{-146}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-100}:\\ \;\;\;\;z \cdot \frac{-x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 4: 69.6% accurate, 0.5× speedup?

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

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

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

\mathbf{elif}\;y \leq -1.25 \cdot 10^{-146}:\\
\;\;\;\;x\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.45e-25 or -6.1999999999999998e-96 < y < -1.24999999999999989e-146 or 1.10000000000000002e-99 < y

    1. Initial program 80.5%

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(\frac{y}{y} - \frac{z}{y}\right)} \]
      5. *-inverses99.3%

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

      \[\leadsto \color{blue}{x \cdot \left(1 - \frac{z}{y}\right)} \]
    4. Taylor expanded in z around 0 78.3%

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

    if -1.45e-25 < y < -6.1999999999999998e-96

    1. Initial program 99.6%

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

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

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(y - z\right)} \]
    4. Step-by-step derivation
      1. associate-/r/100.0%

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    5. Applied egg-rr100.0%

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

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

        \[\leadsto \frac{x}{\color{blue}{\frac{-1 \cdot y}{z}}} \]
      2. neg-mul-172.6%

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

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

    if -1.24999999999999989e-146 < y < 1.10000000000000002e-99

    1. Initial program 89.3%

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{y - z}{y}} \]
      4. div-sub91.5%

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

        \[\leadsto x \cdot \left(\color{blue}{1} - \frac{z}{y}\right) \]
    3. Simplified91.5%

      \[\leadsto \color{blue}{x \cdot \left(1 - \frac{z}{y}\right)} \]
    4. Taylor expanded in z around inf 79.0%

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

        \[\leadsto \color{blue}{-\frac{x \cdot z}{y}} \]
      2. *-commutative79.0%

        \[\leadsto -\frac{\color{blue}{z \cdot x}}{y} \]
      3. associate-*r/82.6%

        \[\leadsto -\color{blue}{z \cdot \frac{x}{y}} \]
      4. distribute-lft-neg-out82.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.45 \cdot 10^{-25}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -6.2 \cdot 10^{-96}:\\ \;\;\;\;\frac{x}{\frac{-y}{z}}\\ \mathbf{elif}\;y \leq -1.25 \cdot 10^{-146}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-99}:\\ \;\;\;\;z \cdot \frac{-x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 5: 95.9% accurate, 1.0× speedup?

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

\\
x \cdot \left(1 - \frac{z}{y}\right)
\end{array}
Derivation
  1. Initial program 84.2%

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

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

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

      \[\leadsto \color{blue}{x \cdot \frac{y - z}{y}} \]
    4. div-sub97.0%

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

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

    \[\leadsto \color{blue}{x \cdot \left(1 - \frac{z}{y}\right)} \]
  4. Final simplification97.0%

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

Alternative 6: 49.5% 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 84.2%

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

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

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

      \[\leadsto \color{blue}{x \cdot \frac{y - z}{y}} \]
    4. div-sub97.0%

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

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

    \[\leadsto \color{blue}{x \cdot \left(1 - \frac{z}{y}\right)} \]
  4. Taylor expanded in z around 0 56.0%

    \[\leadsto \color{blue}{x} \]
  5. Final simplification56.0%

    \[\leadsto x \]

Developer target: 96.0% 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 2023331 
(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))