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

Percentage Accurate: 84.1% → 95.8%
Time: 7.6s
Alternatives: 7
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 7 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.1% 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.8% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 8.6 \cdot 10^{-112}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x 8.6e-112) (- x (/ (* x z) y)) (- x (/ x (/ y z)))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= 8.6e-112) {
		tmp = x - ((x * z) / y);
	} else {
		tmp = x - (x / (y / z));
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 8.6d-112) then
        tmp = x - ((x * z) / y)
    else
        tmp = x - (x / (y / z))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= 8.6e-112) {
		tmp = x - ((x * z) / y);
	} else {
		tmp = x - (x / (y / z));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= 8.6e-112:
		tmp = x - ((x * z) / y)
	else:
		tmp = x - (x / (y / z))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= 8.6e-112)
		tmp = Float64(x - Float64(Float64(x * z) / y));
	else
		tmp = Float64(x - Float64(x / Float64(y / z)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= 8.6e-112)
		tmp = x - ((x * z) / y);
	else
		tmp = x - (x / (y / z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, 8.6e-112], N[(x - N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x - N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 8.5999999999999996e-112

    1. Initial program 90.5%

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(y - z\right)} \]
      2. distribute-rgt-out--76.5%

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

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

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

        \[\leadsto \color{blue}{1} \cdot x - z \cdot \frac{x}{y} \]
      6. *-lft-identity92.0%

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

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

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

    if 8.5999999999999996e-112 < x

    1. Initial program 79.6%

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(y - z\right)} \]
      2. distribute-rgt-out--83.1%

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

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

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

        \[\leadsto \color{blue}{1} \cdot x - z \cdot \frac{x}{y} \]
      6. *-lft-identity90.7%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 8.6 \cdot 10^{-112}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \end{array} \]

Alternative 2: 72.9% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;y \leq 13500000000000:\\
\;\;\;\;z \cdot \frac{-x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.90000000000000026e-6 or 1.35e13 < y

    1. Initial program 76.0%

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(y - z\right)} \]
      2. distribute-rgt-out--78.8%

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

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

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

        \[\leadsto \color{blue}{1} \cdot x - z \cdot \frac{x}{y} \]
      6. *-lft-identity96.3%

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

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

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

    if -5.90000000000000026e-6 < y < 1.35e13

    1. Initial program 96.2%

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(y - z\right)} \]
      2. distribute-rgt-out--78.9%

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

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

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

        \[\leadsto \color{blue}{1} \cdot x - z \cdot \frac{x}{y} \]
      6. *-lft-identity87.2%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.9 \cdot 10^{-6}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 13500000000000:\\ \;\;\;\;z \cdot \frac{-x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 3: 73.0% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;y \leq 31000000000000:\\
\;\;\;\;\frac{-z}{\frac{y}{x}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.3000000000000002e-7 or 3.1e13 < y

    1. Initial program 76.0%

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(y - z\right)} \]
      2. distribute-rgt-out--78.8%

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

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

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

        \[\leadsto \color{blue}{1} \cdot x - z \cdot \frac{x}{y} \]
      6. *-lft-identity96.3%

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

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

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

    if -3.3000000000000002e-7 < y < 3.1e13

    1. Initial program 96.2%

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(y - z\right)} \]
      2. distribute-rgt-out--78.9%

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

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

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

        \[\leadsto \color{blue}{1} \cdot x - z \cdot \frac{x}{y} \]
      6. *-lft-identity87.2%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{z}{y} \cdot \left(-x\right)} \]
    7. Step-by-step derivation
      1. distribute-rgt-neg-out73.2%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.3 \cdot 10^{-7}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 31000000000000:\\ \;\;\;\;\frac{-z}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 4: 72.9% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.054:\\
\;\;\;\;x\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -0.0539999999999999994 or 3.1e12 < y

    1. Initial program 76.0%

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(y - z\right)} \]
      2. distribute-rgt-out--78.8%

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

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

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

        \[\leadsto \color{blue}{1} \cdot x - z \cdot \frac{x}{y} \]
      6. *-lft-identity96.3%

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

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

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

    if -0.0539999999999999994 < y < 3.1e12

    1. Initial program 96.2%

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(y - z\right)} \]
      2. distribute-rgt-out--78.9%

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

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

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

        \[\leadsto \color{blue}{1} \cdot x - z \cdot \frac{x}{y} \]
      6. *-lft-identity87.2%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -0.054:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3100000000000:\\ \;\;\;\;\frac{z \cdot \left(-x\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 5: 95.8% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.7 \cdot 10^{+225}:\\
\;\;\;\;x - \frac{x}{\frac{y}{z}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 1.70000000000000009e225

    1. Initial program 86.2%

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(y - z\right)} \]
      2. distribute-rgt-out--78.7%

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

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

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

        \[\leadsto \color{blue}{1} \cdot x - z \cdot \frac{x}{y} \]
      6. *-lft-identity91.6%

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

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

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

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

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

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

    if 1.70000000000000009e225 < z

    1. Initial program 90.6%

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(y - z\right)} \]
      2. distribute-rgt-out--81.3%

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

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

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

        \[\leadsto \color{blue}{1} \cdot x - z \cdot \frac{x}{y} \]
      6. *-lft-identity90.8%

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

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

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

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

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

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

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

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

Alternative 6: 93.5% accurate, 1.0× speedup?

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

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

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

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(y - z\right)} \]
    2. distribute-rgt-out--78.9%

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

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

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

      \[\leadsto \color{blue}{1} \cdot x - z \cdot \frac{x}{y} \]
    6. *-lft-identity91.5%

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

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

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

Alternative 7: 51.4% 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 86.6%

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

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(y - z\right)} \]
    2. distribute-rgt-out--78.9%

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

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

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

      \[\leadsto \color{blue}{1} \cdot x - z \cdot \frac{x}{y} \]
    6. *-lft-identity91.5%

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

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

    \[\leadsto \color{blue}{x} \]
  5. Final simplification47.9%

    \[\leadsto x \]

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 2023176 
(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))