Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3

Percentage Accurate: 88.1% → 98.7%
Time: 5.7s
Alternatives: 10
Speedup: 0.8×

Specification

?
\[\begin{array}{l} \\ \frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
	return (x * ((y - z) + 1.0)) / z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
	return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z):
	return (x * ((y - z) + 1.0)) / z
function code(x, y, z)
	return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z)
end
function tmp = code(x, y, z)
	tmp = (x * ((y - z) + 1.0)) / z;
end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}

\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 10 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 88.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
	return (x * ((y - z) + 1.0)) / z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
	return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z):
	return (x * ((y - z) + 1.0)) / z
function code(x, y, z)
	return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z)
end
function tmp = code(x, y, z)
	tmp = (x * ((y - z) + 1.0)) / z;
end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}

\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}

Alternative 1: 98.7% accurate, 0.1× 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}\;\frac{x_m \cdot \left(\left(y - z\right) + 1\right)}{z} \leq -1 \cdot 10^{+289}:\\ \;\;\;\;x_m \cdot \left(\frac{y + 1}{z} + -1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x_m, y - z, x_m\right)}{z}\\ \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 (<= (/ (* x_m (+ (- y z) 1.0)) z) -1e+289)
    (* x_m (+ (/ (+ y 1.0) z) -1.0))
    (/ (fma x_m (- y z) x_m) z))))
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 (((x_m * ((y - z) + 1.0)) / z) <= -1e+289) {
		tmp = x_m * (((y + 1.0) / z) + -1.0);
	} else {
		tmp = fma(x_m, (y - z), x_m) / z;
	}
	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 (Float64(Float64(x_m * Float64(Float64(y - z) + 1.0)) / z) <= -1e+289)
		tmp = Float64(x_m * Float64(Float64(Float64(y + 1.0) / z) + -1.0));
	else
		tmp = Float64(fma(x_m, Float64(y - z), x_m) / z);
	end
	return Float64(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[N[(N[(x$95$m * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], -1e+289], N[(x$95$m * N[(N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x$95$m * N[(y - z), $MachinePrecision] + x$95$m), $MachinePrecision] / z), $MachinePrecision]]), $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}\;\frac{x_m \cdot \left(\left(y - z\right) + 1\right)}{z} \leq -1 \cdot 10^{+289}:\\
\;\;\;\;x_m \cdot \left(\frac{y + 1}{z} + -1\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x_m, y - z, x_m\right)}{z}\\


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

    1. Initial program 74.8%

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

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

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

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

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

        \[\leadsto x \cdot \frac{\color{blue}{1 + \left(y - z\right)}}{z} \]
      5. associate--l+100.0%

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

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

        \[\leadsto x \cdot \color{blue}{\left(\frac{1 + y}{z} + \left(-\frac{z}{z}\right)\right)} \]
      8. *-inverses100.0%

        \[\leadsto x \cdot \left(\frac{1 + y}{z} + \left(-\color{blue}{1}\right)\right) \]
      9. metadata-eval100.0%

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

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

    if -1.0000000000000001e289 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z)

    1. Initial program 93.2%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. distribute-lft-in93.2%

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, y - z, x \cdot 1\right)}}{z} \]
      3. *-rgt-identity93.2%

        \[\leadsto \frac{\mathsf{fma}\left(x, y - z, \color{blue}{x}\right)}{z} \]
    3. Simplified93.2%

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

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

Alternative 2: 98.7% accurate, 0.5× 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(\left(y - z\right) + 1\right)}{z}\\ x_s \cdot \begin{array}{l} \mathbf{if}\;t_0 \leq -1 \cdot 10^{+289}:\\ \;\;\;\;x_m \cdot \left(\frac{y + 1}{z} + -1\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \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) 1.0)) z)))
   (* x_s (if (<= t_0 -1e+289) (* x_m (+ (/ (+ y 1.0) z) -1.0)) t_0))))
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) + 1.0)) / z;
	double tmp;
	if (t_0 <= -1e+289) {
		tmp = x_m * (((y + 1.0) / z) + -1.0);
	} else {
		tmp = t_0;
	}
	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) + 1.0d0)) / z
    if (t_0 <= (-1d+289)) then
        tmp = x_m * (((y + 1.0d0) / z) + (-1.0d0))
    else
        tmp = t_0
    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) + 1.0)) / z;
	double tmp;
	if (t_0 <= -1e+289) {
		tmp = x_m * (((y + 1.0) / z) + -1.0);
	} else {
		tmp = t_0;
	}
	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) + 1.0)) / z
	tmp = 0
	if t_0 <= -1e+289:
		tmp = x_m * (((y + 1.0) / z) + -1.0)
	else:
		tmp = t_0
	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(Float64(y - z) + 1.0)) / z)
	tmp = 0.0
	if (t_0 <= -1e+289)
		tmp = Float64(x_m * Float64(Float64(Float64(y + 1.0) / z) + -1.0));
	else
		tmp = t_0;
	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) + 1.0)) / z;
	tmp = 0.0;
	if (t_0 <= -1e+289)
		tmp = x_m * (((y + 1.0) / z) + -1.0);
	else
		tmp = t_0;
	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[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, N[(x$95$s * If[LessEqual[t$95$0, -1e+289], N[(x$95$m * N[(N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], t$95$0]), $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(\left(y - z\right) + 1\right)}{z}\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;t_0 \leq -1 \cdot 10^{+289}:\\
\;\;\;\;x_m \cdot \left(\frac{y + 1}{z} + -1\right)\\

\mathbf{else}:\\
\;\;\;\;t_0\\


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

    1. Initial program 74.8%

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

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

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

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

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

        \[\leadsto x \cdot \frac{\color{blue}{1 + \left(y - z\right)}}{z} \]
      5. associate--l+100.0%

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

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

        \[\leadsto x \cdot \color{blue}{\left(\frac{1 + y}{z} + \left(-\frac{z}{z}\right)\right)} \]
      8. *-inverses100.0%

        \[\leadsto x \cdot \left(\frac{1 + y}{z} + \left(-\color{blue}{1}\right)\right) \]
      9. metadata-eval100.0%

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

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

    if -1.0000000000000001e289 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z)

    1. Initial program 93.2%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification94.0%

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

Alternative 3: 94.3% accurate, 0.7× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ x_s = \mathsf{copysign}\left(1, x\right) \\ \begin{array}{l} t_0 := x_m \cdot \left(-1 + \frac{y}{z}\right)\\ x_s \cdot \begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{+18}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.032:\\ \;\;\;\;\frac{x_m}{z} - x_m\\ \mathbf{elif}\;y \leq 5.1 \cdot 10^{+222}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x_m}{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 (+ -1.0 (/ y z)))))
   (*
    x_s
    (if (<= y -7e+18)
      t_0
      (if (<= y 0.032)
        (- (/ x_m z) x_m)
        (if (<= y 5.1e+222) t_0 (* y (/ x_m 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 * (-1.0 + (y / z));
	double tmp;
	if (y <= -7e+18) {
		tmp = t_0;
	} else if (y <= 0.032) {
		tmp = (x_m / z) - x_m;
	} else if (y <= 5.1e+222) {
		tmp = t_0;
	} else {
		tmp = y * (x_m / 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 * ((-1.0d0) + (y / z))
    if (y <= (-7d+18)) then
        tmp = t_0
    else if (y <= 0.032d0) then
        tmp = (x_m / z) - x_m
    else if (y <= 5.1d+222) then
        tmp = t_0
    else
        tmp = y * (x_m / 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 * (-1.0 + (y / z));
	double tmp;
	if (y <= -7e+18) {
		tmp = t_0;
	} else if (y <= 0.032) {
		tmp = (x_m / z) - x_m;
	} else if (y <= 5.1e+222) {
		tmp = t_0;
	} else {
		tmp = y * (x_m / 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 * (-1.0 + (y / z))
	tmp = 0
	if y <= -7e+18:
		tmp = t_0
	elif y <= 0.032:
		tmp = (x_m / z) - x_m
	elif y <= 5.1e+222:
		tmp = t_0
	else:
		tmp = y * (x_m / 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(x_m * Float64(-1.0 + Float64(y / z)))
	tmp = 0.0
	if (y <= -7e+18)
		tmp = t_0;
	elseif (y <= 0.032)
		tmp = Float64(Float64(x_m / z) - x_m);
	elseif (y <= 5.1e+222)
		tmp = t_0;
	else
		tmp = Float64(y * Float64(x_m / 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 * (-1.0 + (y / z));
	tmp = 0.0;
	if (y <= -7e+18)
		tmp = t_0;
	elseif (y <= 0.032)
		tmp = (x_m / z) - x_m;
	elseif (y <= 5.1e+222)
		tmp = t_0;
	else
		tmp = y * (x_m / 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[(x$95$m * N[(-1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[y, -7e+18], t$95$0, If[LessEqual[y, 0.032], N[(N[(x$95$m / z), $MachinePrecision] - x$95$m), $MachinePrecision], If[LessEqual[y, 5.1e+222], t$95$0, N[(y * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)

\\
\begin{array}{l}
t_0 := x_m \cdot \left(-1 + \frac{y}{z}\right)\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+18}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 0.032:\\
\;\;\;\;\frac{x_m}{z} - x_m\\

\mathbf{elif}\;y \leq 5.1 \cdot 10^{+222}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x_m}{z}\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -7e18 or 0.032000000000000001 < y < 5.0999999999999999e222

    1. Initial program 89.6%

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

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

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

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

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

        \[\leadsto x \cdot \frac{\color{blue}{1 + \left(y - z\right)}}{z} \]
      5. associate--l+96.9%

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

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

        \[\leadsto x \cdot \color{blue}{\left(\frac{1 + y}{z} + \left(-\frac{z}{z}\right)\right)} \]
      8. *-inverses96.9%

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

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

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

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

    if -7e18 < y < 0.032000000000000001

    1. Initial program 91.7%

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

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

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

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

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

        \[\leadsto x \cdot \frac{\color{blue}{1 + \left(y - z\right)}}{z} \]
      5. associate--l+99.8%

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

        \[\leadsto x \cdot \color{blue}{\left(\frac{1 + y}{z} - \frac{z}{z}\right)} \]
      7. sub-neg99.8%

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

        \[\leadsto x \cdot \left(\frac{1 + y}{z} + \left(-\color{blue}{1}\right)\right) \]
      9. metadata-eval99.8%

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{z} - 1\right)} \]
    6. Step-by-step derivation
      1. sub-neg99.1%

        \[\leadsto x \cdot \color{blue}{\left(\frac{1}{z} + \left(-1\right)\right)} \]
      2. metadata-eval99.1%

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

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

        \[\leadsto \color{blue}{\frac{1 \cdot x}{z}} + -1 \cdot x \]
      5. *-lft-identity99.2%

        \[\leadsto \frac{\color{blue}{x}}{z} + -1 \cdot x \]
      6. neg-mul-199.2%

        \[\leadsto \frac{x}{z} + \color{blue}{\left(-x\right)} \]
      7. unsub-neg99.2%

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    7. Simplified99.2%

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

    if 5.0999999999999999e222 < y

    1. Initial program 93.2%

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

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

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

        \[\leadsto \color{blue}{\frac{x}{z} \cdot y} \]
    4. Simplified93.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{+18}:\\ \;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\ \mathbf{elif}\;y \leq 0.032:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{elif}\;y \leq 5.1 \cdot 10^{+222}:\\ \;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array} \]

Alternative 4: 66.4% accurate, 0.8× 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}\;z \leq -1:\\ \;\;\;\;-x_m\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{-137}:\\ \;\;\;\;\frac{x_m}{z}\\ \mathbf{elif}\;z \leq 5300000000000:\\ \;\;\;\;y \cdot \frac{x_m}{z}\\ \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 (<= z -1.0)
    (- x_m)
    (if (<= z 2.2e-137)
      (/ x_m z)
      (if (<= z 5300000000000.0) (* y (/ x_m z)) (- 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 (z <= -1.0) {
		tmp = -x_m;
	} else if (z <= 2.2e-137) {
		tmp = x_m / z;
	} else if (z <= 5300000000000.0) {
		tmp = y * (x_m / z);
	} 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 (z <= (-1.0d0)) then
        tmp = -x_m
    else if (z <= 2.2d-137) then
        tmp = x_m / z
    else if (z <= 5300000000000.0d0) then
        tmp = y * (x_m / z)
    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 (z <= -1.0) {
		tmp = -x_m;
	} else if (z <= 2.2e-137) {
		tmp = x_m / z;
	} else if (z <= 5300000000000.0) {
		tmp = y * (x_m / z);
	} 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 z <= -1.0:
		tmp = -x_m
	elif z <= 2.2e-137:
		tmp = x_m / z
	elif z <= 5300000000000.0:
		tmp = y * (x_m / z)
	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 (z <= -1.0)
		tmp = Float64(-x_m);
	elseif (z <= 2.2e-137)
		tmp = Float64(x_m / z);
	elseif (z <= 5300000000000.0)
		tmp = Float64(y * Float64(x_m / z));
	else
		tmp = Float64(-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 (z <= -1.0)
		tmp = -x_m;
	elseif (z <= 2.2e-137)
		tmp = x_m / z;
	elseif (z <= 5300000000000.0)
		tmp = y * (x_m / z);
	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[z, -1.0], (-x$95$m), If[LessEqual[z, 2.2e-137], N[(x$95$m / z), $MachinePrecision], If[LessEqual[z, 5300000000000.0], N[(y * N[(x$95$m / z), $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}\;z \leq -1:\\
\;\;\;\;-x_m\\

\mathbf{elif}\;z \leq 2.2 \cdot 10^{-137}:\\
\;\;\;\;\frac{x_m}{z}\\

\mathbf{elif}\;z \leq 5300000000000:\\
\;\;\;\;y \cdot \frac{x_m}{z}\\

\mathbf{else}:\\
\;\;\;\;-x_m\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1 or 5.3e12 < z

    1. Initial program 80.8%

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

      \[\leadsto \color{blue}{-1 \cdot x} \]
    3. Step-by-step derivation
      1. mul-1-neg80.9%

        \[\leadsto \color{blue}{-x} \]
    4. Simplified80.9%

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

    if -1 < z < 2.2000000000000001e-137

    1. Initial program 99.9%

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

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

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

    if 2.2000000000000001e-137 < z < 5.3e12

    1. Initial program 99.7%

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

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

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

        \[\leadsto \color{blue}{\frac{x}{z} \cdot y} \]
    4. Simplified62.2%

      \[\leadsto \color{blue}{\frac{x}{z} \cdot y} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification72.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{-137}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 5300000000000:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]

Alternative 5: 98.9% accurate, 0.8× 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}\;z \leq -0.97 \lor \neg \left(z \leq 1\right):\\ \;\;\;\;x_m \cdot \left(-1 + \frac{y}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x_m + x_m \cdot y}{z}\\ \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 (or (<= z -0.97) (not (<= z 1.0)))
    (* x_m (+ -1.0 (/ y z)))
    (/ (+ 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 tmp;
	if ((z <= -0.97) || !(z <= 1.0)) {
		tmp = x_m * (-1.0 + (y / z));
	} 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) :: tmp
    if ((z <= (-0.97d0)) .or. (.not. (z <= 1.0d0))) then
        tmp = x_m * ((-1.0d0) + (y / z))
    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 tmp;
	if ((z <= -0.97) || !(z <= 1.0)) {
		tmp = x_m * (-1.0 + (y / z));
	} 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):
	tmp = 0
	if (z <= -0.97) or not (z <= 1.0):
		tmp = x_m * (-1.0 + (y / z))
	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)
	tmp = 0.0
	if ((z <= -0.97) || !(z <= 1.0))
		tmp = Float64(x_m * Float64(-1.0 + Float64(y / z)));
	else
		tmp = Float64(Float64(x_m + Float64(x_m * 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)
	tmp = 0.0;
	if ((z <= -0.97) || ~((z <= 1.0)))
		tmp = x_m * (-1.0 + (y / z));
	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_] := N[(x$95$s * If[Or[LessEqual[z, -0.97], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(x$95$m * N[(-1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$95$m + N[(x$95$m * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]), $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}\;z \leq -0.97 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x_m \cdot \left(-1 + \frac{y}{z}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x_m + x_m \cdot y}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -0.96999999999999997 or 1 < z

    1. Initial program 81.4%

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(\frac{1 + y}{z} + \left(-\frac{z}{z}\right)\right)} \]
      8. *-inverses100.0%

        \[\leadsto x \cdot \left(\frac{1 + y}{z} + \left(-\color{blue}{1}\right)\right) \]
      9. metadata-eval100.0%

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

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

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

    if -0.96999999999999997 < z < 1

    1. Initial program 99.9%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. distribute-lft-in99.9%

        \[\leadsto \frac{\color{blue}{x \cdot \left(y - z\right) + x \cdot 1}}{z} \]
      2. fma-def99.9%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, y - z, x \cdot 1\right)}}{z} \]
      3. *-rgt-identity99.9%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -0.97 \lor \neg \left(z \leq 1\right):\\ \;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x + x \cdot y}{z}\\ \end{array} \]

Alternative 6: 95.8% accurate, 0.8× 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 2.2 \cdot 10^{+223}:\\ \;\;\;\;x_m \cdot \left(\frac{y + 1}{z} + -1\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x_m}{z}\\ \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 2.2e+223) (* x_m (+ (/ (+ y 1.0) z) -1.0)) (* y (/ x_m z)))))
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 <= 2.2e+223) {
		tmp = x_m * (((y + 1.0) / z) + -1.0);
	} else {
		tmp = y * (x_m / 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) :: tmp
    if (y <= 2.2d+223) then
        tmp = x_m * (((y + 1.0d0) / z) + (-1.0d0))
    else
        tmp = y * (x_m / 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 tmp;
	if (y <= 2.2e+223) {
		tmp = x_m * (((y + 1.0) / z) + -1.0);
	} else {
		tmp = y * (x_m / 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):
	tmp = 0
	if y <= 2.2e+223:
		tmp = x_m * (((y + 1.0) / z) + -1.0)
	else:
		tmp = y * (x_m / z)
	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 <= 2.2e+223)
		tmp = Float64(x_m * Float64(Float64(Float64(y + 1.0) / z) + -1.0));
	else
		tmp = Float64(y * Float64(x_m / 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)
	tmp = 0.0;
	if (y <= 2.2e+223)
		tmp = x_m * (((y + 1.0) / z) + -1.0);
	else
		tmp = y * (x_m / 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_] := N[(x$95$s * If[LessEqual[y, 2.2e+223], N[(x$95$m * N[(N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(y * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision]]), $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 2.2 \cdot 10^{+223}:\\
\;\;\;\;x_m \cdot \left(\frac{y + 1}{z} + -1\right)\\

\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x_m}{z}\\


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

    1. Initial program 90.9%

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

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

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

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

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

        \[\leadsto x \cdot \frac{\color{blue}{1 + \left(y - z\right)}}{z} \]
      5. associate--l+98.7%

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

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

        \[\leadsto x \cdot \color{blue}{\left(\frac{1 + y}{z} + \left(-\frac{z}{z}\right)\right)} \]
      8. *-inverses98.7%

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

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

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

    if 2.2e223 < y

    1. Initial program 93.2%

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

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

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

        \[\leadsto \color{blue}{\frac{x}{z} \cdot y} \]
    4. Simplified93.2%

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

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

Alternative 7: 84.9% accurate, 1.0× 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.9 \cdot 10^{+62} \lor \neg \left(y \leq 1.26 \cdot 10^{+32}\right):\\ \;\;\;\;\frac{x_m \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x_m}{z} - 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 (or (<= y -3.9e+62) (not (<= y 1.26e+32)))
    (/ (* x_m y) z)
    (- (/ x_m z) 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.9e+62) || !(y <= 1.26e+32)) {
		tmp = (x_m * y) / z;
	} else {
		tmp = (x_m / z) - 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.9d+62)) .or. (.not. (y <= 1.26d+32))) then
        tmp = (x_m * y) / z
    else
        tmp = (x_m / z) - 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.9e+62) || !(y <= 1.26e+32)) {
		tmp = (x_m * y) / z;
	} else {
		tmp = (x_m / z) - 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.9e+62) or not (y <= 1.26e+32):
		tmp = (x_m * y) / z
	else:
		tmp = (x_m / z) - 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.9e+62) || !(y <= 1.26e+32))
		tmp = Float64(Float64(x_m * y) / z);
	else
		tmp = Float64(Float64(x_m / z) - 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.9e+62) || ~((y <= 1.26e+32)))
		tmp = (x_m * y) / z;
	else
		tmp = (x_m / z) - 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[Or[LessEqual[y, -3.9e+62], N[Not[LessEqual[y, 1.26e+32]], $MachinePrecision]], N[(N[(x$95$m * y), $MachinePrecision] / z), $MachinePrecision], N[(N[(x$95$m / z), $MachinePrecision] - x$95$m), $MachinePrecision]]), $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.9 \cdot 10^{+62} \lor \neg \left(y \leq 1.26 \cdot 10^{+32}\right):\\
\;\;\;\;\frac{x_m \cdot y}{z}\\

\mathbf{else}:\\
\;\;\;\;\frac{x_m}{z} - x_m\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.9e62 or 1.26e32 < y

    1. Initial program 89.9%

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

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

    if -3.9e62 < y < 1.26e32

    1. Initial program 91.8%

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

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

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

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

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

        \[\leadsto x \cdot \frac{\color{blue}{1 + \left(y - z\right)}}{z} \]
      5. associate--l+99.8%

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

        \[\leadsto x \cdot \color{blue}{\left(\frac{1 + y}{z} - \frac{z}{z}\right)} \]
      7. sub-neg99.8%

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

        \[\leadsto x \cdot \left(\frac{1 + y}{z} + \left(-\color{blue}{1}\right)\right) \]
      9. metadata-eval99.8%

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(\frac{1}{z} + \left(-1\right)\right)} \]
      2. metadata-eval96.3%

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

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

        \[\leadsto \color{blue}{\frac{1 \cdot x}{z}} + -1 \cdot x \]
      5. *-lft-identity96.4%

        \[\leadsto \frac{\color{blue}{x}}{z} + -1 \cdot x \]
      6. neg-mul-196.4%

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

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    7. Simplified96.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.9 \cdot 10^{+62} \lor \neg \left(y \leq 1.26 \cdot 10^{+32}\right):\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} - x\\ \end{array} \]

Alternative 8: 84.0% accurate, 1.0× 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.95 \cdot 10^{+62}:\\ \;\;\;\;x_m \cdot \frac{y}{z}\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{+31}:\\ \;\;\;\;\frac{x_m}{z} - x_m\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x_m}{z}\\ \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.95e+62)
    (* x_m (/ y z))
    (if (<= y 4.8e+31) (- (/ x_m z) x_m) (* y (/ x_m z))))))
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.95e+62) {
		tmp = x_m * (y / z);
	} else if (y <= 4.8e+31) {
		tmp = (x_m / z) - x_m;
	} else {
		tmp = y * (x_m / 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) :: tmp
    if (y <= (-1.95d+62)) then
        tmp = x_m * (y / z)
    else if (y <= 4.8d+31) then
        tmp = (x_m / z) - x_m
    else
        tmp = y * (x_m / 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 tmp;
	if (y <= -1.95e+62) {
		tmp = x_m * (y / z);
	} else if (y <= 4.8e+31) {
		tmp = (x_m / z) - x_m;
	} else {
		tmp = y * (x_m / 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):
	tmp = 0
	if y <= -1.95e+62:
		tmp = x_m * (y / z)
	elif y <= 4.8e+31:
		tmp = (x_m / z) - x_m
	else:
		tmp = y * (x_m / z)
	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.95e+62)
		tmp = Float64(x_m * Float64(y / z));
	elseif (y <= 4.8e+31)
		tmp = Float64(Float64(x_m / z) - x_m);
	else
		tmp = Float64(y * Float64(x_m / 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)
	tmp = 0.0;
	if (y <= -1.95e+62)
		tmp = x_m * (y / z);
	elseif (y <= 4.8e+31)
		tmp = (x_m / z) - x_m;
	else
		tmp = y * (x_m / 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_] := N[(x$95$s * If[LessEqual[y, -1.95e+62], N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.8e+31], N[(N[(x$95$m / z), $MachinePrecision] - x$95$m), $MachinePrecision], N[(y * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision]]]), $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.95 \cdot 10^{+62}:\\
\;\;\;\;x_m \cdot \frac{y}{z}\\

\mathbf{elif}\;y \leq 4.8 \cdot 10^{+31}:\\
\;\;\;\;\frac{x_m}{z} - x_m\\

\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x_m}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.95e62

    1. Initial program 92.8%

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} \]
    4. Simplified82.8%

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} \]
    5. Step-by-step derivation
      1. clear-num82.9%

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

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

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

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

    if -1.95e62 < y < 4.79999999999999965e31

    1. Initial program 91.8%

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

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

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

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

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

        \[\leadsto x \cdot \frac{\color{blue}{1 + \left(y - z\right)}}{z} \]
      5. associate--l+99.8%

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

        \[\leadsto x \cdot \color{blue}{\left(\frac{1 + y}{z} - \frac{z}{z}\right)} \]
      7. sub-neg99.8%

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

        \[\leadsto x \cdot \left(\frac{1 + y}{z} + \left(-\color{blue}{1}\right)\right) \]
      9. metadata-eval99.8%

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(\frac{1}{z} + \left(-1\right)\right)} \]
      2. metadata-eval96.3%

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

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

        \[\leadsto \color{blue}{\frac{1 \cdot x}{z}} + -1 \cdot x \]
      5. *-lft-identity96.4%

        \[\leadsto \frac{\color{blue}{x}}{z} + -1 \cdot x \]
      6. neg-mul-196.4%

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

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    7. Simplified96.4%

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

    if 4.79999999999999965e31 < y

    1. Initial program 87.7%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.95 \cdot 10^{+62}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{+31}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array} \]

Alternative 9: 65.7% accurate, 1.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}\;z \leq -1 \lor \neg \left(z \leq 345000\right):\\ \;\;\;\;-x_m\\ \mathbf{else}:\\ \;\;\;\;\frac{x_m}{z}\\ \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 (or (<= z -1.0) (not (<= z 345000.0))) (- x_m) (/ x_m z))))
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 ((z <= -1.0) || !(z <= 345000.0)) {
		tmp = -x_m;
	} else {
		tmp = x_m / 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) :: tmp
    if ((z <= (-1.0d0)) .or. (.not. (z <= 345000.0d0))) then
        tmp = -x_m
    else
        tmp = x_m / 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 tmp;
	if ((z <= -1.0) || !(z <= 345000.0)) {
		tmp = -x_m;
	} else {
		tmp = x_m / 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):
	tmp = 0
	if (z <= -1.0) or not (z <= 345000.0):
		tmp = -x_m
	else:
		tmp = x_m / z
	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 ((z <= -1.0) || !(z <= 345000.0))
		tmp = Float64(-x_m);
	else
		tmp = Float64(x_m / 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)
	tmp = 0.0;
	if ((z <= -1.0) || ~((z <= 345000.0)))
		tmp = -x_m;
	else
		tmp = x_m / 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_] := N[(x$95$s * If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 345000.0]], $MachinePrecision]], (-x$95$m), N[(x$95$m / z), $MachinePrecision]]), $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}\;z \leq -1 \lor \neg \left(z \leq 345000\right):\\
\;\;\;\;-x_m\\

\mathbf{else}:\\
\;\;\;\;\frac{x_m}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1 or 345000 < z

    1. Initial program 81.1%

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

      \[\leadsto \color{blue}{-1 \cdot x} \]
    3. Step-by-step derivation
      1. mul-1-neg79.7%

        \[\leadsto \color{blue}{-x} \]
    4. Simplified79.7%

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

    if -1 < z < 345000

    1. Initial program 99.9%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 345000\right):\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \]

Alternative 10: 38.7% accurate, 4.5× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ x_s = \mathsf{copysign}\left(1, x\right) \\ x_s \cdot \left(-x_m\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 = 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 * Float64(-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 \left(-x_m\right)
\end{array}
Derivation
  1. Initial program 91.1%

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

    \[\leadsto \color{blue}{-1 \cdot x} \]
  3. Step-by-step derivation
    1. mul-1-neg39.2%

      \[\leadsto \color{blue}{-x} \]
  4. Simplified39.2%

    \[\leadsto \color{blue}{-x} \]
  5. Final simplification39.2%

    \[\leadsto -x \]

Developer target: 99.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(1 + y\right) \cdot \frac{x}{z} - x\\ \mathbf{if}\;x < -2.71483106713436 \cdot 10^{-162}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x < 3.874108816439546 \cdot 10^{-197}:\\ \;\;\;\;\left(x \cdot \left(\left(y - z\right) + 1\right)\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- (* (+ 1.0 y) (/ x z)) x)))
   (if (< x -2.71483106713436e-162)
     t_0
     (if (< x 3.874108816439546e-197)
       (* (* x (+ (- y z) 1.0)) (/ 1.0 z))
       t_0))))
double code(double x, double y, double z) {
	double t_0 = ((1.0 + y) * (x / z)) - x;
	double tmp;
	if (x < -2.71483106713436e-162) {
		tmp = t_0;
	} else if (x < 3.874108816439546e-197) {
		tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
	} else {
		tmp = t_0;
	}
	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 = ((1.0d0 + y) * (x / z)) - x
    if (x < (-2.71483106713436d-162)) then
        tmp = t_0
    else if (x < 3.874108816439546d-197) then
        tmp = (x * ((y - z) + 1.0d0)) * (1.0d0 / z)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = ((1.0 + y) * (x / z)) - x;
	double tmp;
	if (x < -2.71483106713436e-162) {
		tmp = t_0;
	} else if (x < 3.874108816439546e-197) {
		tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = ((1.0 + y) * (x / z)) - x
	tmp = 0
	if x < -2.71483106713436e-162:
		tmp = t_0
	elif x < 3.874108816439546e-197:
		tmp = (x * ((y - z) + 1.0)) * (1.0 / z)
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(Float64(1.0 + y) * Float64(x / z)) - x)
	tmp = 0.0
	if (x < -2.71483106713436e-162)
		tmp = t_0;
	elseif (x < 3.874108816439546e-197)
		tmp = Float64(Float64(x * Float64(Float64(y - z) + 1.0)) * Float64(1.0 / z));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = ((1.0 + y) * (x / z)) - x;
	tmp = 0.0;
	if (x < -2.71483106713436e-162)
		tmp = t_0;
	elseif (x < 3.874108816439546e-197)
		tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(1.0 + y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]}, If[Less[x, -2.71483106713436e-162], t$95$0, If[Less[x, 3.874108816439546e-197], N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(1 + y\right) \cdot \frac{x}{z} - x\\
\mathbf{if}\;x < -2.71483106713436 \cdot 10^{-162}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x < 3.874108816439546 \cdot 10^{-197}:\\
\;\;\;\;\left(x \cdot \left(\left(y - z\right) + 1\right)\right) \cdot \frac{1}{z}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023331 
(FPCore (x y z)
  :name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
  :precision binary64

  :herbie-target
  (if (< x -2.71483106713436e-162) (- (* (+ 1.0 y) (/ x z)) x) (if (< x 3.874108816439546e-197) (* (* x (+ (- y z) 1.0)) (/ 1.0 z)) (- (* (+ 1.0 y) (/ x z)) x)))

  (/ (* x (+ (- y z) 1.0)) z))