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

Percentage Accurate: 84.7% → 97.0%
Time: 7.5s
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.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: 97.0% accurate, 0.4× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ x_s = \mathsf{copysign}\left(1, x\right) \\ \begin{array}{l} t_0 := \frac{x\_m \cdot \left(y - z\right)}{y}\\ x\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq -5 \cdot 10^{-189}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;x\_m - \frac{x\_m}{\frac{y}{z}}\\ \end{array} \end{array} \end{array} \]
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
 :precision binary64
 (let* ((t_0 (/ (* x_m (- y z)) y)))
   (* x_s (if (<= t_0 -5e-189) t_0 (- x_m (/ x_m (/ y z)))))))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
	double t_0 = (x_m * (y - z)) / y;
	double tmp;
	if (t_0 <= -5e-189) {
		tmp = t_0;
	} else {
		tmp = x_m - (x_m / (y / z));
	}
	return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x_m * (y - z)) / y
    if (t_0 <= (-5d-189)) then
        tmp = t_0
    else
        tmp = x_m - (x_m / (y / z))
    end if
    code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
	double t_0 = (x_m * (y - z)) / y;
	double tmp;
	if (t_0 <= -5e-189) {
		tmp = t_0;
	} else {
		tmp = x_m - (x_m / (y / z));
	}
	return x_s * tmp;
}
x_m = math.fabs(x)
x_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z):
	t_0 = (x_m * (y - z)) / y
	tmp = 0
	if t_0 <= -5e-189:
		tmp = t_0
	else:
		tmp = x_m - (x_m / (y / z))
	return x_s * tmp
x_m = abs(x)
x_s = copysign(1.0, x)
function code(x_s, x_m, y, z)
	t_0 = Float64(Float64(x_m * Float64(y - z)) / y)
	tmp = 0.0
	if (t_0 <= -5e-189)
		tmp = t_0;
	else
		tmp = Float64(x_m - Float64(x_m / Float64(y / z)));
	end
	return Float64(x_s * tmp)
end
x_m = abs(x);
x_s = sign(x) * abs(1.0);
function tmp_2 = code(x_s, x_m, y, z)
	t_0 = (x_m * (y - z)) / y;
	tmp = 0.0;
	if (t_0 <= -5e-189)
		tmp = t_0;
	else
		tmp = x_m - (x_m / (y / z));
	end
	tmp_2 = x_s * tmp;
end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := Block[{t$95$0 = N[(N[(x$95$m * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, N[(x$95$s * If[LessEqual[t$95$0, -5e-189], t$95$0, N[(x$95$m - N[(x$95$m / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)

\\
\begin{array}{l}
t_0 := \frac{x\_m \cdot \left(y - z\right)}{y}\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-189}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 80.0%

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Add Preprocessing

    if -4.9999999999999997e-189 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 79.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x + \color{blue}{\frac{x}{y} \cdot \left(-z\right)} \]
      2. add-sqr-sqrt38.1%

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

        \[\leadsto x + \frac{x}{y} \cdot \color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}} \]
      4. sqr-neg61.5%

        \[\leadsto x + \frac{x}{y} \cdot \sqrt{\color{blue}{z \cdot z}} \]
      5. sqrt-unprod28.8%

        \[\leadsto x + \frac{x}{y} \cdot \color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)} \]
      6. add-sqr-sqrt49.5%

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

        \[\leadsto x + \color{blue}{z \cdot \frac{x}{y}} \]
      8. cancel-sign-sub49.5%

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

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

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

        \[\leadsto x - \color{blue}{x \cdot \frac{-z}{y}} \]
      12. add-sqr-sqrt20.7%

        \[\leadsto x - x \cdot \frac{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}}{y} \]
      13. sqrt-unprod70.5%

        \[\leadsto x - x \cdot \frac{\color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}}{y} \]
      14. sqr-neg70.5%

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

        \[\leadsto x - x \cdot \frac{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}{y} \]
      16. add-sqr-sqrt94.5%

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

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

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

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

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

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

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

Alternative 2: 70.1% accurate, 0.3× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ x_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot \begin{array}{l} \mathbf{if}\;y \leq -6.4 \cdot 10^{+19}:\\ \;\;\;\;x\_m\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-110} \lor \neg \left(y \leq 8 \cdot 10^{-80}\right) \land y \leq 9.5 \cdot 10^{+36}:\\ \;\;\;\;x\_m \cdot \frac{z}{-y}\\ \mathbf{else}:\\ \;\;\;\;x\_m\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
 :precision binary64
 (*
  x_s
  (if (<= y -6.4e+19)
    x_m
    (if (or (<= y 2e-110) (and (not (<= y 8e-80)) (<= y 9.5e+36)))
      (* x_m (/ z (- y)))
      x_m))))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if (y <= -6.4e+19) {
		tmp = x_m;
	} else if ((y <= 2e-110) || (!(y <= 8e-80) && (y <= 9.5e+36))) {
		tmp = x_m * (z / -y);
	} else {
		tmp = x_m;
	}
	return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-6.4d+19)) then
        tmp = x_m
    else if ((y <= 2d-110) .or. (.not. (y <= 8d-80)) .and. (y <= 9.5d+36)) then
        tmp = x_m * (z / -y)
    else
        tmp = x_m
    end if
    code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if (y <= -6.4e+19) {
		tmp = x_m;
	} else if ((y <= 2e-110) || (!(y <= 8e-80) && (y <= 9.5e+36))) {
		tmp = x_m * (z / -y);
	} else {
		tmp = x_m;
	}
	return x_s * tmp;
}
x_m = math.fabs(x)
x_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z):
	tmp = 0
	if y <= -6.4e+19:
		tmp = x_m
	elif (y <= 2e-110) or (not (y <= 8e-80) and (y <= 9.5e+36)):
		tmp = x_m * (z / -y)
	else:
		tmp = x_m
	return x_s * tmp
x_m = abs(x)
x_s = copysign(1.0, x)
function code(x_s, x_m, y, z)
	tmp = 0.0
	if (y <= -6.4e+19)
		tmp = x_m;
	elseif ((y <= 2e-110) || (!(y <= 8e-80) && (y <= 9.5e+36)))
		tmp = Float64(x_m * Float64(z / Float64(-y)));
	else
		tmp = x_m;
	end
	return Float64(x_s * tmp)
end
x_m = abs(x);
x_s = sign(x) * abs(1.0);
function tmp_2 = code(x_s, x_m, y, z)
	tmp = 0.0;
	if (y <= -6.4e+19)
		tmp = x_m;
	elseif ((y <= 2e-110) || (~((y <= 8e-80)) && (y <= 9.5e+36)))
		tmp = x_m * (z / -y);
	else
		tmp = x_m;
	end
	tmp_2 = x_s * tmp;
end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[y, -6.4e+19], x$95$m, If[Or[LessEqual[y, 2e-110], And[N[Not[LessEqual[y, 8e-80]], $MachinePrecision], LessEqual[y, 9.5e+36]]], N[(x$95$m * N[(z / (-y)), $MachinePrecision]), $MachinePrecision], x$95$m]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)

\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -6.4 \cdot 10^{+19}:\\
\;\;\;\;x\_m\\

\mathbf{elif}\;y \leq 2 \cdot 10^{-110} \lor \neg \left(y \leq 8 \cdot 10^{-80}\right) \land y \leq 9.5 \cdot 10^{+36}:\\
\;\;\;\;x\_m \cdot \frac{z}{-y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.4e19 or 2.0000000000000001e-110 < y < 7.99999999999999969e-80 or 9.49999999999999974e36 < y

    1. Initial program 64.4%

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

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

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

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

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

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

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

        \[\leadsto x \cdot \left(-\color{blue}{\left(-\frac{y - z}{y}\right)}\right) \]
      8. remove-double-neg99.9%

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

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

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

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

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

    if -6.4e19 < y < 2.0000000000000001e-110 or 7.99999999999999969e-80 < y < 9.49999999999999974e36

    1. Initial program 93.1%

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

        \[\leadsto \color{blue}{x \cdot \frac{y - z}{y}} \]
      2. add-sqr-sqrt43.2%

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

        \[\leadsto \color{blue}{\sqrt{x} \cdot \left(\sqrt{x} \cdot \frac{y - z}{y}\right)} \]
    4. Applied egg-rr43.2%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.4 \cdot 10^{+19}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-110} \lor \neg \left(y \leq 8 \cdot 10^{-80}\right) \land y \leq 9.5 \cdot 10^{+36}:\\ \;\;\;\;x \cdot \frac{z}{-y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 72.3% accurate, 0.3× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ x_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot \begin{array}{l} \mathbf{if}\;y \leq -3.5 \cdot 10^{+14}:\\ \;\;\;\;x\_m\\ \mathbf{elif}\;y \leq 9.2 \cdot 10^{-110} \lor \neg \left(y \leq 1.3 \cdot 10^{-79}\right) \land y \leq 9.5 \cdot 10^{+36}:\\ \;\;\;\;z \cdot \frac{x\_m}{-y}\\ \mathbf{else}:\\ \;\;\;\;x\_m\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
 :precision binary64
 (*
  x_s
  (if (<= y -3.5e+14)
    x_m
    (if (or (<= y 9.2e-110) (and (not (<= y 1.3e-79)) (<= y 9.5e+36)))
      (* z (/ x_m (- y)))
      x_m))))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if (y <= -3.5e+14) {
		tmp = x_m;
	} else if ((y <= 9.2e-110) || (!(y <= 1.3e-79) && (y <= 9.5e+36))) {
		tmp = z * (x_m / -y);
	} else {
		tmp = x_m;
	}
	return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-3.5d+14)) then
        tmp = x_m
    else if ((y <= 9.2d-110) .or. (.not. (y <= 1.3d-79)) .and. (y <= 9.5d+36)) then
        tmp = z * (x_m / -y)
    else
        tmp = x_m
    end if
    code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if (y <= -3.5e+14) {
		tmp = x_m;
	} else if ((y <= 9.2e-110) || (!(y <= 1.3e-79) && (y <= 9.5e+36))) {
		tmp = z * (x_m / -y);
	} else {
		tmp = x_m;
	}
	return x_s * tmp;
}
x_m = math.fabs(x)
x_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z):
	tmp = 0
	if y <= -3.5e+14:
		tmp = x_m
	elif (y <= 9.2e-110) or (not (y <= 1.3e-79) and (y <= 9.5e+36)):
		tmp = z * (x_m / -y)
	else:
		tmp = x_m
	return x_s * tmp
x_m = abs(x)
x_s = copysign(1.0, x)
function code(x_s, x_m, y, z)
	tmp = 0.0
	if (y <= -3.5e+14)
		tmp = x_m;
	elseif ((y <= 9.2e-110) || (!(y <= 1.3e-79) && (y <= 9.5e+36)))
		tmp = Float64(z * Float64(x_m / Float64(-y)));
	else
		tmp = x_m;
	end
	return Float64(x_s * tmp)
end
x_m = abs(x);
x_s = sign(x) * abs(1.0);
function tmp_2 = code(x_s, x_m, y, z)
	tmp = 0.0;
	if (y <= -3.5e+14)
		tmp = x_m;
	elseif ((y <= 9.2e-110) || (~((y <= 1.3e-79)) && (y <= 9.5e+36)))
		tmp = z * (x_m / -y);
	else
		tmp = x_m;
	end
	tmp_2 = x_s * tmp;
end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[y, -3.5e+14], x$95$m, If[Or[LessEqual[y, 9.2e-110], And[N[Not[LessEqual[y, 1.3e-79]], $MachinePrecision], LessEqual[y, 9.5e+36]]], N[(z * N[(x$95$m / (-y)), $MachinePrecision]), $MachinePrecision], x$95$m]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)

\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -3.5 \cdot 10^{+14}:\\
\;\;\;\;x\_m\\

\mathbf{elif}\;y \leq 9.2 \cdot 10^{-110} \lor \neg \left(y \leq 1.3 \cdot 10^{-79}\right) \land y \leq 9.5 \cdot 10^{+36}:\\
\;\;\;\;z \cdot \frac{x\_m}{-y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.5e14 or 9.2000000000000006e-110 < y < 1.29999999999999997e-79 or 9.49999999999999974e36 < y

    1. Initial program 64.4%

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

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

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

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

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

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

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

        \[\leadsto x \cdot \left(-\color{blue}{\left(-\frac{y - z}{y}\right)}\right) \]
      8. remove-double-neg99.9%

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

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

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

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

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

    if -3.5e14 < y < 9.2000000000000006e-110 or 1.29999999999999997e-79 < y < 9.49999999999999974e36

    1. Initial program 93.1%

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

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

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

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

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

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

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

        \[\leadsto x \cdot \left(-\color{blue}{\left(-\frac{y - z}{y}\right)}\right) \]
      8. remove-double-neg90.9%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.5 \cdot 10^{+14}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 9.2 \cdot 10^{-110} \lor \neg \left(y \leq 1.3 \cdot 10^{-79}\right) \land y \leq 9.5 \cdot 10^{+36}:\\ \;\;\;\;z \cdot \frac{x}{-y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 72.2% accurate, 0.3× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ x_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot \begin{array}{l} \mathbf{if}\;y \leq -1.55 \cdot 10^{+19}:\\ \;\;\;\;x\_m\\ \mathbf{elif}\;y \leq 1.02 \cdot 10^{-109}:\\ \;\;\;\;\frac{x\_m \cdot \left(-z\right)}{y}\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{-79}:\\ \;\;\;\;x\_m\\ \mathbf{elif}\;y \leq 1.55 \cdot 10^{+38}:\\ \;\;\;\;z \cdot \frac{x\_m}{-y}\\ \mathbf{else}:\\ \;\;\;\;x\_m\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
 :precision binary64
 (*
  x_s
  (if (<= y -1.55e+19)
    x_m
    (if (<= y 1.02e-109)
      (/ (* x_m (- z)) y)
      (if (<= y 1.5e-79) x_m (if (<= y 1.55e+38) (* z (/ x_m (- y))) x_m))))))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if (y <= -1.55e+19) {
		tmp = x_m;
	} else if (y <= 1.02e-109) {
		tmp = (x_m * -z) / y;
	} else if (y <= 1.5e-79) {
		tmp = x_m;
	} else if (y <= 1.55e+38) {
		tmp = z * (x_m / -y);
	} else {
		tmp = x_m;
	}
	return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-1.55d+19)) then
        tmp = x_m
    else if (y <= 1.02d-109) then
        tmp = (x_m * -z) / y
    else if (y <= 1.5d-79) then
        tmp = x_m
    else if (y <= 1.55d+38) then
        tmp = z * (x_m / -y)
    else
        tmp = x_m
    end if
    code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if (y <= -1.55e+19) {
		tmp = x_m;
	} else if (y <= 1.02e-109) {
		tmp = (x_m * -z) / y;
	} else if (y <= 1.5e-79) {
		tmp = x_m;
	} else if (y <= 1.55e+38) {
		tmp = z * (x_m / -y);
	} else {
		tmp = x_m;
	}
	return x_s * tmp;
}
x_m = math.fabs(x)
x_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z):
	tmp = 0
	if y <= -1.55e+19:
		tmp = x_m
	elif y <= 1.02e-109:
		tmp = (x_m * -z) / y
	elif y <= 1.5e-79:
		tmp = x_m
	elif y <= 1.55e+38:
		tmp = z * (x_m / -y)
	else:
		tmp = x_m
	return x_s * tmp
x_m = abs(x)
x_s = copysign(1.0, x)
function code(x_s, x_m, y, z)
	tmp = 0.0
	if (y <= -1.55e+19)
		tmp = x_m;
	elseif (y <= 1.02e-109)
		tmp = Float64(Float64(x_m * Float64(-z)) / y);
	elseif (y <= 1.5e-79)
		tmp = x_m;
	elseif (y <= 1.55e+38)
		tmp = Float64(z * Float64(x_m / Float64(-y)));
	else
		tmp = x_m;
	end
	return Float64(x_s * tmp)
end
x_m = abs(x);
x_s = sign(x) * abs(1.0);
function tmp_2 = code(x_s, x_m, y, z)
	tmp = 0.0;
	if (y <= -1.55e+19)
		tmp = x_m;
	elseif (y <= 1.02e-109)
		tmp = (x_m * -z) / y;
	elseif (y <= 1.5e-79)
		tmp = x_m;
	elseif (y <= 1.55e+38)
		tmp = z * (x_m / -y);
	else
		tmp = x_m;
	end
	tmp_2 = x_s * tmp;
end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[y, -1.55e+19], x$95$m, If[LessEqual[y, 1.02e-109], N[(N[(x$95$m * (-z)), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[y, 1.5e-79], x$95$m, If[LessEqual[y, 1.55e+38], N[(z * N[(x$95$m / (-y)), $MachinePrecision]), $MachinePrecision], x$95$m]]]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)

\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -1.55 \cdot 10^{+19}:\\
\;\;\;\;x\_m\\

\mathbf{elif}\;y \leq 1.02 \cdot 10^{-109}:\\
\;\;\;\;\frac{x\_m \cdot \left(-z\right)}{y}\\

\mathbf{elif}\;y \leq 1.5 \cdot 10^{-79}:\\
\;\;\;\;x\_m\\

\mathbf{elif}\;y \leq 1.55 \cdot 10^{+38}:\\
\;\;\;\;z \cdot \frac{x\_m}{-y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.55e19 or 1.02e-109 < y < 1.5e-79 or 1.55000000000000009e38 < y

    1. Initial program 64.4%

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

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

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

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

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

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

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

        \[\leadsto x \cdot \left(-\color{blue}{\left(-\frac{y - z}{y}\right)}\right) \]
      8. remove-double-neg99.9%

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

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

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

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

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

    if -1.55e19 < y < 1.02e-109

    1. Initial program 91.8%

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

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

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

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

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

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

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

        \[\leadsto x \cdot \left(-\color{blue}{\left(-\frac{y - z}{y}\right)}\right) \]
      8. remove-double-neg89.7%

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

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

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

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

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

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

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

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

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

    if 1.5e-79 < y < 1.55000000000000009e38

    1. Initial program 98.4%

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

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

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

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

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

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

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

        \[\leadsto x \cdot \left(-\color{blue}{\left(-\frac{y - z}{y}\right)}\right) \]
      8. remove-double-neg96.0%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.55 \cdot 10^{+19}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.02 \cdot 10^{-109}:\\ \;\;\;\;\frac{x \cdot \left(-z\right)}{y}\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{-79}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.55 \cdot 10^{+38}:\\ \;\;\;\;z \cdot \frac{x}{-y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 95.9% accurate, 1.0× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ x_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot \left(x\_m \cdot \left(1 - \frac{z}{y}\right)\right) \end{array} \]
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z) :precision binary64 (* x_s (* x_m (- 1.0 (/ z y)))))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
	return x_s * (x_m * (1.0 - (z / y)));
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x_s * (x_m * (1.0d0 - (z / y)))
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
	return x_s * (x_m * (1.0 - (z / y)));
}
x_m = math.fabs(x)
x_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z):
	return x_s * (x_m * (1.0 - (z / y)))
x_m = abs(x)
x_s = copysign(1.0, x)
function code(x_s, x_m, y, z)
	return Float64(x_s * Float64(x_m * Float64(1.0 - Float64(z / y))))
end
x_m = abs(x);
x_s = sign(x) * abs(1.0);
function tmp = code(x_s, x_m, y, z)
	tmp = x_s * (x_m * (1.0 - (z / y)));
end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * N[(x$95$m * N[(1.0 - N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)

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

    \[\frac{x \cdot \left(y - z\right)}{y} \]
  2. Step-by-step derivation
    1. remove-double-neg79.9%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{x \cdot \left(1 - \frac{z}{y}\right)} \]
  4. Add Preprocessing
  5. Final simplification95.1%

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

Alternative 6: 96.1% accurate, 1.0× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ x_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot \left(x\_m - \frac{x\_m}{\frac{y}{z}}\right) \end{array} \]
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z) :precision binary64 (* x_s (- x_m (/ x_m (/ y z)))))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
	return x_s * (x_m - (x_m / (y / z)));
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x_s * (x_m - (x_m / (y / z)))
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
	return x_s * (x_m - (x_m / (y / z)));
}
x_m = math.fabs(x)
x_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z):
	return x_s * (x_m - (x_m / (y / z)))
x_m = abs(x)
x_s = copysign(1.0, x)
function code(x_s, x_m, y, z)
	return Float64(x_s * Float64(x_m - Float64(x_m / Float64(y / z))))
end
x_m = abs(x);
x_s = sign(x) * abs(1.0);
function tmp = code(x_s, x_m, y, z)
	tmp = x_s * (x_m - (x_m / (y / z)));
end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * N[(x$95$m - N[(x$95$m / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)

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

    \[\frac{x \cdot \left(y - z\right)}{y} \]
  2. Step-by-step derivation
    1. remove-double-neg79.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{x + \frac{x \cdot \left(-z\right)}{y}} \]
  8. Step-by-step derivation
    1. associate-*l/95.1%

      \[\leadsto x + \color{blue}{\frac{x}{y} \cdot \left(-z\right)} \]
    2. add-sqr-sqrt42.2%

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

      \[\leadsto x + \frac{x}{y} \cdot \color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}} \]
    4. sqr-neg60.8%

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

      \[\leadsto x + \frac{x}{y} \cdot \color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)} \]
    6. add-sqr-sqrt47.1%

      \[\leadsto x + \frac{x}{y} \cdot \color{blue}{z} \]
    7. *-commutative47.1%

      \[\leadsto x + \color{blue}{z \cdot \frac{x}{y}} \]
    8. cancel-sign-sub47.1%

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

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

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

      \[\leadsto x - \color{blue}{x \cdot \frac{-z}{y}} \]
    12. add-sqr-sqrt22.1%

      \[\leadsto x - x \cdot \frac{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}}{y} \]
    13. sqrt-unprod68.5%

      \[\leadsto x - x \cdot \frac{\color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}}{y} \]
    14. sqr-neg68.5%

      \[\leadsto x - x \cdot \frac{\sqrt{\color{blue}{z \cdot z}}}{y} \]
    15. sqrt-unprod52.4%

      \[\leadsto x - x \cdot \frac{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}{y} \]
    16. add-sqr-sqrt95.1%

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

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

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

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

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

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

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

Alternative 7: 50.7% accurate, 7.0× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ x_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot x\_m \end{array} \]
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z) :precision binary64 (* x_s x_m))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
	return x_s * x_m;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x_s * x_m
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
	return x_s * x_m;
}
x_m = math.fabs(x)
x_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z):
	return x_s * x_m
x_m = abs(x)
x_s = copysign(1.0, x)
function code(x_s, x_m, y, z)
	return Float64(x_s * x_m)
end
x_m = abs(x);
x_s = sign(x) * abs(1.0);
function tmp = code(x_s, x_m, y, z)
	tmp = x_s * x_m;
end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * x$95$m), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)

\\
x\_s \cdot x\_m
\end{array}
Derivation
  1. Initial program 79.9%

    \[\frac{x \cdot \left(y - z\right)}{y} \]
  2. Step-by-step derivation
    1. remove-double-neg79.9%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto x \]
  7. Add Preprocessing

Developer target: 96.0% accurate, 0.4× 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 2024041 
(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))