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

Percentage Accurate: 84.7% → 95.9%
Time: 5.6s
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: 95.9% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.2 \cdot 10^{-148} \lor \neg \left(y \leq 6 \cdot 10^{-13}\right):\\
\;\;\;\;x \cdot \frac{y - z}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -9.1999999999999999e-148 or 5.99999999999999968e-13 < y

    1. Initial program 81.4%

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

        \[\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}} \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{x \cdot \frac{y - z}{y}} \]
    4. Add Preprocessing

    if -9.1999999999999999e-148 < y < 5.99999999999999968e-13

    1. Initial program 94.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.2 \cdot 10^{-148} \lor \neg \left(y \leq 6 \cdot 10^{-13}\right):\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 95.7% accurate, 0.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 x (-.f64 y z)) y) < -4.99999999999999967e145

    1. Initial program 69.1%

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \frac{y - z}{y}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. *-commutative87.3%

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

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

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

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

    if -4.99999999999999967e145 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 89.7%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq -5 \cdot 10^{+145}:\\ \;\;\;\;\frac{y - z}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 71.6% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.6 \cdot 10^{-92} \lor \neg \left(z \leq 0.014\right):\\
\;\;\;\;z \cdot \frac{-x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.6e-92 or 0.0140000000000000003 < z

    1. Initial program 89.6%

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

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

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

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

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

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

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

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

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

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

    if -2.6e-92 < z < 0.0140000000000000003

    1. Initial program 80.0%

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \frac{y - z}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 88.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.6 \cdot 10^{-92} \lor \neg \left(z \leq 0.014\right):\\ \;\;\;\;z \cdot \frac{-x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 72.2% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.4 \cdot 10^{-84} \lor \neg \left(z \leq 2.7 \cdot 10^{-5}\right):\\
\;\;\;\;\frac{z \cdot \left(-x\right)}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.40000000000000021e-84 or 2.6999999999999999e-5 < z

    1. Initial program 90.1%

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 73.0%

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

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

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

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

    if -3.40000000000000021e-84 < z < 2.6999999999999999e-5

    1. Initial program 79.5%

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \frac{y - z}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 88.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.4 \cdot 10^{-84} \lor \neg \left(z \leq 2.7 \cdot 10^{-5}\right):\\ \;\;\;\;\frac{z \cdot \left(-x\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 70.9% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;z \leq 0.0027:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -2.19999999999999987e-92

    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/95.8%

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

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

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

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

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

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

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

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

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

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

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

    if -2.19999999999999987e-92 < z < 0.0027000000000000001

    1. Initial program 80.0%

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \frac{y - z}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 88.6%

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

    if 0.0027000000000000001 < z

    1. Initial program 90.1%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.2 \cdot 10^{-92}:\\ \;\;\;\;\frac{-x}{\frac{y}{z}}\\ \mathbf{elif}\;z \leq 0.0027:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{-x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 51.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 120:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 120

    1. Initial program 86.1%

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \frac{y - z}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 53.9%

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

    if 120 < x

    1. Initial program 83.9%

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

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

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot y} \]
    5. Applied egg-rr60.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 120:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 51.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.3 \cdot 10^{+82}:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.2999999999999999e82

    1. Initial program 86.7%

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \frac{y - z}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 55.2%

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

    if 1.2999999999999999e82 < x

    1. Initial program 81.1%

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

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

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot y} \]
    5. Applied egg-rr58.2%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot y} \]
    6. Step-by-step derivation
      1. *-commutative58.2%

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

        \[\leadsto y \cdot \color{blue}{\frac{1}{\frac{y}{x}}} \]
      3. div-inv58.2%

        \[\leadsto \color{blue}{\frac{y}{\frac{y}{x}}} \]
    7. Applied egg-rr58.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.3 \cdot 10^{+82}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{y}{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 95.7% 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 85.5%

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

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

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

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

    \[\leadsto \color{blue}{x \cdot \frac{y - z}{y}} \]
  4. Add Preprocessing
  5. Final simplification96.3%

    \[\leadsto x \cdot \frac{y - z}{y} \]
  6. Add Preprocessing

Alternative 9: 96.0% 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 85.5%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
  7. Final simplification96.8%

    \[\leadsto \frac{x}{\frac{y}{y - z}} \]
  8. Add Preprocessing

Alternative 10: 50.8% 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 85.5%

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

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

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

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

    \[\leadsto \color{blue}{x \cdot \frac{y - z}{y}} \]
  4. Add Preprocessing
  5. Taylor expanded in y around inf 52.5%

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

    \[\leadsto x \]
  7. Add Preprocessing

Developer target: 95.9% 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 2024010 
(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))