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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{y}{\frac{y}{x}} - \frac{z}{\frac{y}{x}}} \]
    4. associate-/r/78.1%

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

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

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

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

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

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

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

Alternative 2: 68.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \frac{-z}{y}\\ \mathbf{if}\;z \leq -3.5 \cdot 10^{-14}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -7 \cdot 10^{-133}:\\ \;\;\;\;y \cdot \frac{x}{y}\\ \mathbf{elif}\;z \leq -1.05 \cdot 10^{-188} \lor \neg \left(z \leq 820000\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (/ (- z) y))))
   (if (<= z -3.5e-14)
     t_0
     (if (<= z -7e-133)
       (* y (/ x y))
       (if (or (<= z -1.05e-188) (not (<= z 820000.0))) t_0 x)))))
double code(double x, double y, double z) {
	double t_0 = x * (-z / y);
	double tmp;
	if (z <= -3.5e-14) {
		tmp = t_0;
	} else if (z <= -7e-133) {
		tmp = y * (x / y);
	} else if ((z <= -1.05e-188) || !(z <= 820000.0)) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = x * (-z / y)
    if (z <= (-3.5d-14)) then
        tmp = t_0
    else if (z <= (-7d-133)) then
        tmp = y * (x / y)
    else if ((z <= (-1.05d-188)) .or. (.not. (z <= 820000.0d0))) then
        tmp = t_0
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x * (-z / y);
	double tmp;
	if (z <= -3.5e-14) {
		tmp = t_0;
	} else if (z <= -7e-133) {
		tmp = y * (x / y);
	} else if ((z <= -1.05e-188) || !(z <= 820000.0)) {
		tmp = t_0;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (-z / y)
	tmp = 0
	if z <= -3.5e-14:
		tmp = t_0
	elif z <= -7e-133:
		tmp = y * (x / y)
	elif (z <= -1.05e-188) or not (z <= 820000.0):
		tmp = t_0
	else:
		tmp = x
	return tmp
function code(x, y, z)
	t_0 = Float64(x * Float64(Float64(-z) / y))
	tmp = 0.0
	if (z <= -3.5e-14)
		tmp = t_0;
	elseif (z <= -7e-133)
		tmp = Float64(y * Float64(x / y));
	elseif ((z <= -1.05e-188) || !(z <= 820000.0))
		tmp = t_0;
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * (-z / y);
	tmp = 0.0;
	if (z <= -3.5e-14)
		tmp = t_0;
	elseif (z <= -7e-133)
		tmp = y * (x / y);
	elseif ((z <= -1.05e-188) || ~((z <= 820000.0)))
		tmp = t_0;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[((-z) / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.5e-14], t$95$0, If[LessEqual[z, -7e-133], N[(y * N[(x / y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, -1.05e-188], N[Not[LessEqual[z, 820000.0]], $MachinePrecision]], t$95$0, x]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \frac{-z}{y}\\
\mathbf{if}\;z \leq -3.5 \cdot 10^{-14}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;z \leq -1.05 \cdot 10^{-188} \lor \neg \left(z \leq 820000\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -3.5000000000000002e-14 or -7.00000000000000006e-133 < z < -1.05e-188 or 8.2e5 < z

    1. Initial program 88.2%

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

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

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

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

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

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

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

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

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

    if -3.5000000000000002e-14 < z < -7.00000000000000006e-133

    1. Initial program 90.9%

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

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

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

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

    if -1.05e-188 < z < 8.2e5

    1. Initial program 78.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.5 \cdot 10^{-14}:\\ \;\;\;\;x \cdot \frac{-z}{y}\\ \mathbf{elif}\;z \leq -7 \cdot 10^{-133}:\\ \;\;\;\;y \cdot \frac{x}{y}\\ \mathbf{elif}\;z \leq -1.05 \cdot 10^{-188} \lor \neg \left(z \leq 820000\right):\\ \;\;\;\;x \cdot \frac{-z}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 3: 73.3% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.8000000000000002e-14 or 3.6e6 < z

    1. Initial program 88.2%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{-y} \cdot z} \]
    8. Applied egg-rr75.9%

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

    if -3.8000000000000002e-14 < z < 3.6e6

    1. Initial program 80.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.8 \cdot 10^{-14} \lor \neg \left(z \leq 3600000\right):\\ \;\;\;\;z \cdot \frac{x}{-y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 4: 73.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -4.8 \cdot 10^{-14} \lor \neg \left(z \leq 1200000\right):\\ \;\;\;\;\frac{x \cdot \left(-z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -4.8e-14) (not (<= z 1200000.0))) (/ (* x (- z)) y) x))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -4.8e-14) || !(z <= 1200000.0)) {
		tmp = (x * -z) / y;
	} else {
		tmp = x;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((z <= (-4.8d-14)) .or. (.not. (z <= 1200000.0d0))) then
        tmp = (x * -z) / y
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -4.8e-14) || !(z <= 1200000.0)) {
		tmp = (x * -z) / y;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -4.8e-14) or not (z <= 1200000.0):
		tmp = (x * -z) / y
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -4.8e-14) || !(z <= 1200000.0))
		tmp = Float64(Float64(x * Float64(-z)) / y);
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -4.8e-14) || ~((z <= 1200000.0)))
		tmp = (x * -z) / y;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.8e-14], N[Not[LessEqual[z, 1200000.0]], $MachinePrecision]], N[(N[(x * (-z)), $MachinePrecision] / y), $MachinePrecision], x]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -4.8e-14 or 1.2e6 < z

    1. Initial program 88.2%

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

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

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

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

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

    if -4.8e-14 < z < 1.2e6

    1. Initial program 80.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.8 \cdot 10^{-14} \lor \neg \left(z \leq 1200000\right):\\ \;\;\;\;\frac{x \cdot \left(-z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 5: 73.1% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 88.4%

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

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

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

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

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

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

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

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

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

    if -2e-14 < z < 52000

    1. Initial program 80.9%

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

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

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

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

    if 52000 < z

    1. Initial program 88.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 87.8% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 5.40000000000000023e166

    1. Initial program 86.5%

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

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

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

    if 5.40000000000000023e166 < y

    1. Initial program 69.5%

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

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

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

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

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

Alternative 7: 50.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{+107}:\\
\;\;\;\;y \cdot \frac{x}{y}\\

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


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

    1. Initial program 80.6%

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

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

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

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

    if -1.60000000000000015e107 < x

    1. Initial program 85.6%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{+107}:\\ \;\;\;\;y \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 8: 49.9% 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.6%

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

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

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

    \[\leadsto \color{blue}{x} \]
  5. Final simplification46.3%

    \[\leadsto x \]

Developer target: 96.1% 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 2023297 
(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))