Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J

Percentage Accurate: 96.2% → 99.9%
Time: 7.1s
Alternatives: 13
Speedup: 0.8×

Specification

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

\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\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 13 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: 96.2% accurate, 1.0× speedup?

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

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

Alternative 1: 99.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}\;x_m \leq 7 \cdot 10^{-60}:\\ \;\;\;\;x_m - z \cdot \left(x_m \cdot \left(1 - y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x_m + \left(-1 + y\right) \cdot \left(x_m \cdot z\right)\\ \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 7e-60)
    (- x_m (* z (* x_m (- 1.0 y))))
    (+ x_m (* (+ -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 (x_m <= 7e-60) {
		tmp = x_m - (z * (x_m * (1.0 - y)));
	} else {
		tmp = x_m + ((-1.0 + 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 (x_m <= 7d-60) then
        tmp = x_m - (z * (x_m * (1.0d0 - y)))
    else
        tmp = x_m + (((-1.0d0) + 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 (x_m <= 7e-60) {
		tmp = x_m - (z * (x_m * (1.0 - y)));
	} else {
		tmp = x_m + ((-1.0 + 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 x_m <= 7e-60:
		tmp = x_m - (z * (x_m * (1.0 - y)))
	else:
		tmp = x_m + ((-1.0 + 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 (x_m <= 7e-60)
		tmp = Float64(x_m - Float64(z * Float64(x_m * Float64(1.0 - y))));
	else
		tmp = Float64(x_m + Float64(Float64(-1.0 + 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 (x_m <= 7e-60)
		tmp = x_m - (z * (x_m * (1.0 - y)));
	else
		tmp = x_m + ((-1.0 + 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[x$95$m, 7e-60], N[(x$95$m - N[(z * N[(x$95$m * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m + N[(N[(-1.0 + y), $MachinePrecision] * N[(x$95$m * z), $MachinePrecision]), $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}\;x_m \leq 7 \cdot 10^{-60}:\\
\;\;\;\;x_m - z \cdot \left(x_m \cdot \left(1 - y\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x_m + \left(-1 + y\right) \cdot \left(x_m \cdot z\right)\\


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

    1. Initial program 95.9%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 95.9%

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

      \[\leadsto x + \color{blue}{\left(-1 \cdot \left(x \cdot z\right) + x \cdot \left(y \cdot z\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative90.5%

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

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

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

        \[\leadsto x + \left(\left(x \cdot z\right) \cdot y + \color{blue}{\left(x \cdot z\right) \cdot -1}\right) \]
      5. distribute-lft-in95.8%

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

        \[\leadsto x + \color{blue}{\left(z \cdot x\right)} \cdot \left(y + -1\right) \]
      7. associate-*l*99.4%

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

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

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

    if 6.99999999999999952e-60 < x

    1. Initial program 99.9%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 99.9%

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

      \[\leadsto x + \color{blue}{\left(-1 \cdot \left(x \cdot z\right) + x \cdot \left(y \cdot z\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative92.7%

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

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

        \[\leadsto x + \left(\color{blue}{\left(x \cdot z\right) \cdot y} + -1 \cdot \left(x \cdot z\right)\right) \]
      4. *-commutative88.3%

        \[\leadsto x + \left(\left(x \cdot z\right) \cdot y + \color{blue}{\left(x \cdot z\right) \cdot -1}\right) \]
      5. distribute-lft-in99.9%

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

        \[\leadsto x + \color{blue}{\left(z \cdot x\right)} \cdot \left(y + -1\right) \]
      7. associate-*l*90.4%

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

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

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

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

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

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

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

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

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

Alternative 2: 97.3% accurate, 0.6× 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 \cdot \left(1 - y\right) \leq 5 \cdot 10^{+286}:\\ \;\;\;\;x_m \cdot \left(1 + z \cdot \left(-1 + y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x_m + y \cdot \left(x_m \cdot z\right)\\ \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 y)) 5e+286)
    (* x_m (+ 1.0 (* z (+ -1.0 y))))
    (+ 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 ((z * (1.0 - y)) <= 5e+286) {
		tmp = x_m * (1.0 + (z * (-1.0 + y)));
	} else {
		tmp = x_m + (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 ((z * (1.0d0 - y)) <= 5d+286) then
        tmp = x_m * (1.0d0 + (z * ((-1.0d0) + y)))
    else
        tmp = x_m + (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 ((z * (1.0 - y)) <= 5e+286) {
		tmp = x_m * (1.0 + (z * (-1.0 + y)));
	} else {
		tmp = x_m + (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 (z * (1.0 - y)) <= 5e+286:
		tmp = x_m * (1.0 + (z * (-1.0 + y)))
	else:
		tmp = x_m + (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 (Float64(z * Float64(1.0 - y)) <= 5e+286)
		tmp = Float64(x_m * Float64(1.0 + Float64(z * Float64(-1.0 + y))));
	else
		tmp = Float64(x_m + 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 ((z * (1.0 - y)) <= 5e+286)
		tmp = x_m * (1.0 + (z * (-1.0 + y)));
	else
		tmp = x_m + (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[N[(z * N[(1.0 - y), $MachinePrecision]), $MachinePrecision], 5e+286], N[(x$95$m * N[(1.0 + N[(z * N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m + N[(y * N[(x$95$m * z), $MachinePrecision]), $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}\;z \cdot \left(1 - y\right) \leq 5 \cdot 10^{+286}:\\
\;\;\;\;x_m \cdot \left(1 + z \cdot \left(-1 + y\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x_m + y \cdot \left(x_m \cdot z\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (-.f64 1 y) z) < 5.0000000000000004e286

    1. Initial program 98.7%

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

    if 5.0000000000000004e286 < (*.f64 (-.f64 1 y) z)

    1. Initial program 76.6%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 76.6%

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

      \[\leadsto x + \color{blue}{\left(-1 \cdot \left(x \cdot z\right) + x \cdot \left(y \cdot z\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative51.6%

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

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

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

        \[\leadsto x + \left(\left(x \cdot z\right) \cdot y + \color{blue}{\left(x \cdot z\right) \cdot -1}\right) \]
      5. distribute-lft-in99.8%

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

        \[\leadsto x + \color{blue}{\left(z \cdot x\right)} \cdot \left(y + -1\right) \]
      7. associate-*l*99.7%

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

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

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

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

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

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

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

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

      \[\leadsto x + \color{blue}{x \cdot \left(y \cdot z\right)} \]
    11. Step-by-step derivation
      1. associate-*r*99.7%

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

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

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

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

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

Alternative 3: 97.3% accurate, 0.6× 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 \cdot \left(1 - y\right) \leq 5 \cdot 10^{+286}:\\ \;\;\;\;x_m + x_m \cdot \left(z \cdot \left(-1 + y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x_m + y \cdot \left(x_m \cdot z\right)\\ \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 y)) 5e+286)
    (+ x_m (* x_m (* z (+ -1.0 y))))
    (+ 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 ((z * (1.0 - y)) <= 5e+286) {
		tmp = x_m + (x_m * (z * (-1.0 + y)));
	} else {
		tmp = x_m + (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 ((z * (1.0d0 - y)) <= 5d+286) then
        tmp = x_m + (x_m * (z * ((-1.0d0) + y)))
    else
        tmp = x_m + (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 ((z * (1.0 - y)) <= 5e+286) {
		tmp = x_m + (x_m * (z * (-1.0 + y)));
	} else {
		tmp = x_m + (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 (z * (1.0 - y)) <= 5e+286:
		tmp = x_m + (x_m * (z * (-1.0 + y)))
	else:
		tmp = x_m + (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 (Float64(z * Float64(1.0 - y)) <= 5e+286)
		tmp = Float64(x_m + Float64(x_m * Float64(z * Float64(-1.0 + y))));
	else
		tmp = Float64(x_m + 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 ((z * (1.0 - y)) <= 5e+286)
		tmp = x_m + (x_m * (z * (-1.0 + y)));
	else
		tmp = x_m + (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[N[(z * N[(1.0 - y), $MachinePrecision]), $MachinePrecision], 5e+286], N[(x$95$m + N[(x$95$m * N[(z * N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m + N[(y * N[(x$95$m * z), $MachinePrecision]), $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}\;z \cdot \left(1 - y\right) \leq 5 \cdot 10^{+286}:\\
\;\;\;\;x_m + x_m \cdot \left(z \cdot \left(-1 + y\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x_m + y \cdot \left(x_m \cdot z\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (-.f64 1 y) z) < 5.0000000000000004e286

    1. Initial program 98.7%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 98.7%

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

    if 5.0000000000000004e286 < (*.f64 (-.f64 1 y) z)

    1. Initial program 76.6%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 76.6%

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

      \[\leadsto x + \color{blue}{\left(-1 \cdot \left(x \cdot z\right) + x \cdot \left(y \cdot z\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative51.6%

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

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

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

        \[\leadsto x + \left(\left(x \cdot z\right) \cdot y + \color{blue}{\left(x \cdot z\right) \cdot -1}\right) \]
      5. distribute-lft-in99.8%

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

        \[\leadsto x + \color{blue}{\left(z \cdot x\right)} \cdot \left(y + -1\right) \]
      7. associate-*l*99.7%

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

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

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

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

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

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

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

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

      \[\leadsto x + \color{blue}{x \cdot \left(y \cdot z\right)} \]
    11. Step-by-step derivation
      1. associate-*r*99.7%

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

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

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

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

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

Alternative 4: 59.6% accurate, 0.8× 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(z \cdot y\right)\\ x_s \cdot \begin{array}{l} \mathbf{if}\;y \leq -13500000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.05 \cdot 10^{-245}:\\ \;\;\;\;x_m\\ \mathbf{elif}\;y \leq 7:\\ \;\;\;\;x_m \cdot \left(-z\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 (* z y))))
   (*
    x_s
    (if (<= y -13500000.0)
      t_0
      (if (<= y -1.05e-245) x_m (if (<= y 7.0) (* x_m (- z)) 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 * (z * y);
	double tmp;
	if (y <= -13500000.0) {
		tmp = t_0;
	} else if (y <= -1.05e-245) {
		tmp = x_m;
	} else if (y <= 7.0) {
		tmp = x_m * -z;
	} 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 * (z * y)
    if (y <= (-13500000.0d0)) then
        tmp = t_0
    else if (y <= (-1.05d-245)) then
        tmp = x_m
    else if (y <= 7.0d0) then
        tmp = x_m * -z
    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 * (z * y);
	double tmp;
	if (y <= -13500000.0) {
		tmp = t_0;
	} else if (y <= -1.05e-245) {
		tmp = x_m;
	} else if (y <= 7.0) {
		tmp = x_m * -z;
	} 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 * (z * y)
	tmp = 0
	if y <= -13500000.0:
		tmp = t_0
	elif y <= -1.05e-245:
		tmp = x_m
	elif y <= 7.0:
		tmp = x_m * -z
	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(x_m * Float64(z * y))
	tmp = 0.0
	if (y <= -13500000.0)
		tmp = t_0;
	elseif (y <= -1.05e-245)
		tmp = x_m;
	elseif (y <= 7.0)
		tmp = Float64(x_m * Float64(-z));
	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 * (z * y);
	tmp = 0.0;
	if (y <= -13500000.0)
		tmp = t_0;
	elseif (y <= -1.05e-245)
		tmp = x_m;
	elseif (y <= 7.0)
		tmp = x_m * -z;
	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[(x$95$m * N[(z * y), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[y, -13500000.0], t$95$0, If[LessEqual[y, -1.05e-245], x$95$m, If[LessEqual[y, 7.0], N[(x$95$m * (-z)), $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 := x_m \cdot \left(z \cdot y\right)\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -13500000:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -1.05 \cdot 10^{-245}:\\
\;\;\;\;x_m\\

\mathbf{elif}\;y \leq 7:\\
\;\;\;\;x_m \cdot \left(-z\right)\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.35e7 or 7 < y

    1. Initial program 94.3%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 71.6%

      \[\leadsto \color{blue}{x \cdot \left(y \cdot z\right)} \]
    4. Step-by-step derivation
      1. *-commutative71.6%

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

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

    if -1.35e7 < y < -1.05000000000000005e-245

    1. Initial program 100.0%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 68.0%

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

    if -1.05000000000000005e-245 < y < 7

    1. Initial program 100.0%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 59.5%

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \left(-x\right)} \]
    6. Simplified59.6%

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

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

Alternative 5: 95.1% 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 -1 \lor \neg \left(y \leq 2.8 \cdot 10^{-8}\right):\\ \;\;\;\;x_m + x_m \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x_m - x_m \cdot 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 (<= y -1.0) (not (<= y 2.8e-8)))
    (+ x_m (* x_m (* z y)))
    (- 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 ((y <= -1.0) || !(y <= 2.8e-8)) {
		tmp = x_m + (x_m * (z * y));
	} else {
		tmp = x_m - (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.0d0)) .or. (.not. (y <= 2.8d-8))) then
        tmp = x_m + (x_m * (z * y))
    else
        tmp = x_m - (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.0) || !(y <= 2.8e-8)) {
		tmp = x_m + (x_m * (z * y));
	} else {
		tmp = x_m - (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.0) or not (y <= 2.8e-8):
		tmp = x_m + (x_m * (z * y))
	else:
		tmp = x_m - (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.0) || !(y <= 2.8e-8))
		tmp = Float64(x_m + Float64(x_m * Float64(z * y)));
	else
		tmp = Float64(x_m - 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.0) || ~((y <= 2.8e-8)))
		tmp = x_m + (x_m * (z * y));
	else
		tmp = x_m - (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[y, -1.0], N[Not[LessEqual[y, 2.8e-8]], $MachinePrecision]], N[(x$95$m + N[(x$95$m * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m - 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 \lor \neg \left(y \leq 2.8 \cdot 10^{-8}\right):\\
\;\;\;\;x_m + x_m \cdot \left(z \cdot y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1 or 2.7999999999999999e-8 < y

    1. Initial program 94.4%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 94.5%

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

      \[\leadsto x + \color{blue}{x \cdot \left(y \cdot z\right)} \]
    5. Step-by-step derivation
      1. *-commutative93.4%

        \[\leadsto x + x \cdot \color{blue}{\left(z \cdot y\right)} \]
    6. Simplified93.4%

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

    if -1 < y < 2.7999999999999999e-8

    1. Initial program 100.0%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 100.0%

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

      \[\leadsto x + \color{blue}{\left(-1 \cdot \left(x \cdot z\right) + x \cdot \left(y \cdot z\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative95.7%

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

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

        \[\leadsto x + \left(\color{blue}{\left(x \cdot z\right) \cdot y} + -1 \cdot \left(x \cdot z\right)\right) \]
      4. *-commutative90.5%

        \[\leadsto x + \left(\left(x \cdot z\right) \cdot y + \color{blue}{\left(x \cdot z\right) \cdot -1}\right) \]
      5. distribute-lft-in100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x + -1 \cdot \left(x \cdot z\right)} \]
    11. Step-by-step derivation
      1. neg-mul-1100.0%

        \[\leadsto x + \color{blue}{\left(-x \cdot z\right)} \]
      2. unsub-neg100.0%

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

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

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

Alternative 6: 84.3% 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 -5.9 \cdot 10^{+46}:\\ \;\;\;\;z \cdot \left(x_m \cdot y\right)\\ \mathbf{elif}\;y \leq 2200:\\ \;\;\;\;x_m - x_m \cdot z\\ \mathbf{else}:\\ \;\;\;\;x_m \cdot \left(z \cdot \left(-1 + y\right)\right)\\ \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 -5.9e+46)
    (* z (* x_m y))
    (if (<= y 2200.0) (- x_m (* x_m z)) (* x_m (* z (+ -1.0 y)))))))
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 <= -5.9e+46) {
		tmp = z * (x_m * y);
	} else if (y <= 2200.0) {
		tmp = x_m - (x_m * z);
	} else {
		tmp = x_m * (z * (-1.0 + y));
	}
	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 <= (-5.9d+46)) then
        tmp = z * (x_m * y)
    else if (y <= 2200.0d0) then
        tmp = x_m - (x_m * z)
    else
        tmp = x_m * (z * ((-1.0d0) + y))
    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 <= -5.9e+46) {
		tmp = z * (x_m * y);
	} else if (y <= 2200.0) {
		tmp = x_m - (x_m * z);
	} else {
		tmp = x_m * (z * (-1.0 + y));
	}
	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 <= -5.9e+46:
		tmp = z * (x_m * y)
	elif y <= 2200.0:
		tmp = x_m - (x_m * z)
	else:
		tmp = x_m * (z * (-1.0 + y))
	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 <= -5.9e+46)
		tmp = Float64(z * Float64(x_m * y));
	elseif (y <= 2200.0)
		tmp = Float64(x_m - Float64(x_m * z));
	else
		tmp = Float64(x_m * Float64(z * Float64(-1.0 + y)));
	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 <= -5.9e+46)
		tmp = z * (x_m * y);
	elseif (y <= 2200.0)
		tmp = x_m - (x_m * z);
	else
		tmp = x_m * (z * (-1.0 + y));
	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, -5.9e+46], N[(z * N[(x$95$m * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2200.0], N[(x$95$m - N[(x$95$m * z), $MachinePrecision]), $MachinePrecision], N[(x$95$m * N[(z * N[(-1.0 + y), $MachinePrecision]), $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 -5.9 \cdot 10^{+46}:\\
\;\;\;\;z \cdot \left(x_m \cdot y\right)\\

\mathbf{elif}\;y \leq 2200:\\
\;\;\;\;x_m - x_m \cdot z\\

\mathbf{else}:\\
\;\;\;\;x_m \cdot \left(z \cdot \left(-1 + y\right)\right)\\


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

    1. Initial program 89.6%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 71.0%

      \[\leadsto \color{blue}{x \cdot \left(y \cdot z\right)} \]
    4. Step-by-step derivation
      1. associate-*r*77.8%

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

        \[\leadsto \color{blue}{z \cdot \left(x \cdot y\right)} \]
    5. Simplified77.8%

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

    if -5.8999999999999999e46 < y < 2200

    1. Initial program 100.0%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 100.0%

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

      \[\leadsto x + \color{blue}{\left(-1 \cdot \left(x \cdot z\right) + x \cdot \left(y \cdot z\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative96.2%

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

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

        \[\leadsto x + \left(\color{blue}{\left(x \cdot z\right) \cdot y} + -1 \cdot \left(x \cdot z\right)\right) \]
      4. *-commutative91.6%

        \[\leadsto x + \left(\left(x \cdot z\right) \cdot y + \color{blue}{\left(x \cdot z\right) \cdot -1}\right) \]
      5. distribute-lft-in100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x + -1 \cdot \left(x \cdot z\right)} \]
    11. Step-by-step derivation
      1. neg-mul-195.8%

        \[\leadsto x + \color{blue}{\left(-x \cdot z\right)} \]
      2. unsub-neg95.8%

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

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

    if 2200 < y

    1. Initial program 96.9%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 76.9%

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

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

Alternative 7: 95.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}\;y \leq -1:\\ \;\;\;\;x_m + y \cdot \left(x_m \cdot z\right)\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-8}:\\ \;\;\;\;x_m - x_m \cdot z\\ \mathbf{else}:\\ \;\;\;\;x_m + x_m \cdot \left(z \cdot y\right)\\ \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.0)
    (+ x_m (* y (* x_m z)))
    (if (<= y 2.8e-8) (- x_m (* x_m z)) (+ x_m (* x_m (* z y)))))))
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.0) {
		tmp = x_m + (y * (x_m * z));
	} else if (y <= 2.8e-8) {
		tmp = x_m - (x_m * z);
	} else {
		tmp = x_m + (x_m * (z * y));
	}
	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.0d0)) then
        tmp = x_m + (y * (x_m * z))
    else if (y <= 2.8d-8) then
        tmp = x_m - (x_m * z)
    else
        tmp = x_m + (x_m * (z * y))
    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.0) {
		tmp = x_m + (y * (x_m * z));
	} else if (y <= 2.8e-8) {
		tmp = x_m - (x_m * z);
	} else {
		tmp = x_m + (x_m * (z * y));
	}
	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.0:
		tmp = x_m + (y * (x_m * z))
	elif y <= 2.8e-8:
		tmp = x_m - (x_m * z)
	else:
		tmp = x_m + (x_m * (z * y))
	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.0)
		tmp = Float64(x_m + Float64(y * Float64(x_m * z)));
	elseif (y <= 2.8e-8)
		tmp = Float64(x_m - Float64(x_m * z));
	else
		tmp = Float64(x_m + Float64(x_m * Float64(z * y)));
	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.0)
		tmp = x_m + (y * (x_m * z));
	elseif (y <= 2.8e-8)
		tmp = x_m - (x_m * z);
	else
		tmp = x_m + (x_m * (z * y));
	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.0], N[(x$95$m + N[(y * N[(x$95$m * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.8e-8], N[(x$95$m - N[(x$95$m * z), $MachinePrecision]), $MachinePrecision], N[(x$95$m + N[(x$95$m * 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 \begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x_m + y \cdot \left(x_m \cdot z\right)\\

\mathbf{elif}\;y \leq 2.8 \cdot 10^{-8}:\\
\;\;\;\;x_m - x_m \cdot z\\

\mathbf{else}:\\
\;\;\;\;x_m + x_m \cdot \left(z \cdot y\right)\\


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

    1. Initial program 91.7%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 91.8%

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

      \[\leadsto x + \color{blue}{\left(-1 \cdot \left(x \cdot z\right) + x \cdot \left(y \cdot z\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative91.7%

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

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

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

        \[\leadsto x + \left(\left(x \cdot z\right) \cdot y + \color{blue}{\left(x \cdot z\right) \cdot -1}\right) \]
      5. distribute-lft-in96.2%

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

        \[\leadsto x + \color{blue}{\left(z \cdot x\right)} \cdot \left(y + -1\right) \]
      7. associate-*l*94.3%

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

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

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

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

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

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

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

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

      \[\leadsto x + \color{blue}{x \cdot \left(y \cdot z\right)} \]
    11. Step-by-step derivation
      1. associate-*r*93.1%

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

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

        \[\leadsto x + \color{blue}{y \cdot \left(x \cdot z\right)} \]
    12. Simplified95.0%

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

    if -1 < y < 2.7999999999999999e-8

    1. Initial program 100.0%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 100.0%

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

      \[\leadsto x + \color{blue}{\left(-1 \cdot \left(x \cdot z\right) + x \cdot \left(y \cdot z\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative95.7%

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

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

        \[\leadsto x + \left(\color{blue}{\left(x \cdot z\right) \cdot y} + -1 \cdot \left(x \cdot z\right)\right) \]
      4. *-commutative90.5%

        \[\leadsto x + \left(\left(x \cdot z\right) \cdot y + \color{blue}{\left(x \cdot z\right) \cdot -1}\right) \]
      5. distribute-lft-in100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x + -1 \cdot \left(x \cdot z\right)} \]
    11. Step-by-step derivation
      1. neg-mul-1100.0%

        \[\leadsto x + \color{blue}{\left(-x \cdot z\right)} \]
      2. unsub-neg100.0%

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

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

    if 2.7999999999999999e-8 < y

    1. Initial program 97.0%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 97.1%

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

      \[\leadsto x + \color{blue}{x \cdot \left(y \cdot z\right)} \]
    5. Step-by-step derivation
      1. *-commutative96.1%

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

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

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

Alternative 8: 99.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}\;x_m \leq 10^{-25}:\\ \;\;\;\;x_m - z \cdot \left(x_m \cdot \left(1 - y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x_m + x_m \cdot \left(z \cdot \left(-1 + y\right)\right)\\ \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 1e-25)
    (- x_m (* z (* x_m (- 1.0 y))))
    (+ x_m (* x_m (* z (+ -1.0 y)))))))
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 <= 1e-25) {
		tmp = x_m - (z * (x_m * (1.0 - y)));
	} else {
		tmp = x_m + (x_m * (z * (-1.0 + y)));
	}
	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 (x_m <= 1d-25) then
        tmp = x_m - (z * (x_m * (1.0d0 - y)))
    else
        tmp = x_m + (x_m * (z * ((-1.0d0) + y)))
    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 (x_m <= 1e-25) {
		tmp = x_m - (z * (x_m * (1.0 - y)));
	} else {
		tmp = x_m + (x_m * (z * (-1.0 + y)));
	}
	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 x_m <= 1e-25:
		tmp = x_m - (z * (x_m * (1.0 - y)))
	else:
		tmp = x_m + (x_m * (z * (-1.0 + y)))
	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 (x_m <= 1e-25)
		tmp = Float64(x_m - Float64(z * Float64(x_m * Float64(1.0 - y))));
	else
		tmp = Float64(x_m + Float64(x_m * Float64(z * Float64(-1.0 + y))));
	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 (x_m <= 1e-25)
		tmp = x_m - (z * (x_m * (1.0 - y)));
	else
		tmp = x_m + (x_m * (z * (-1.0 + y)));
	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[x$95$m, 1e-25], N[(x$95$m - N[(z * N[(x$95$m * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m + N[(x$95$m * N[(z * N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]), $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}\;x_m \leq 10^{-25}:\\
\;\;\;\;x_m - z \cdot \left(x_m \cdot \left(1 - y\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x_m + x_m \cdot \left(z \cdot \left(-1 + y\right)\right)\\


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

    1. Initial program 96.0%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 96.0%

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

      \[\leadsto x + \color{blue}{\left(-1 \cdot \left(x \cdot z\right) + x \cdot \left(y \cdot z\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative90.8%

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

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

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

        \[\leadsto x + \left(\left(x \cdot z\right) \cdot y + \color{blue}{\left(x \cdot z\right) \cdot -1}\right) \]
      5. distribute-lft-in95.9%

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

        \[\leadsto x + \color{blue}{\left(z \cdot x\right)} \cdot \left(y + -1\right) \]
      7. associate-*l*99.4%

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

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

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

    if 1.00000000000000004e-25 < x

    1. Initial program 99.9%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 99.9%

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

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

Alternative 9: 83.3% 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 -2.5 \cdot 10^{+47} \lor \neg \left(y \leq 6.2 \cdot 10^{+16}\right):\\ \;\;\;\;x_m \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x_m \cdot \left(1 - z\right)\\ \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 -2.5e+47) (not (<= y 6.2e+16)))
    (* x_m (* z y))
    (* x_m (- 1.0 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.5e+47) || !(y <= 6.2e+16)) {
		tmp = x_m * (z * y);
	} else {
		tmp = x_m * (1.0 - 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.5d+47)) .or. (.not. (y <= 6.2d+16))) then
        tmp = x_m * (z * y)
    else
        tmp = x_m * (1.0d0 - 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.5e+47) || !(y <= 6.2e+16)) {
		tmp = x_m * (z * y);
	} else {
		tmp = x_m * (1.0 - 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.5e+47) or not (y <= 6.2e+16):
		tmp = x_m * (z * y)
	else:
		tmp = x_m * (1.0 - 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.5e+47) || !(y <= 6.2e+16))
		tmp = Float64(x_m * Float64(z * y));
	else
		tmp = Float64(x_m * Float64(1.0 - 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.5e+47) || ~((y <= 6.2e+16)))
		tmp = x_m * (z * y);
	else
		tmp = x_m * (1.0 - 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[y, -2.5e+47], N[Not[LessEqual[y, 6.2e+16]], $MachinePrecision]], N[(x$95$m * N[(z * y), $MachinePrecision]), $MachinePrecision], N[(x$95$m * N[(1.0 - 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.5 \cdot 10^{+47} \lor \neg \left(y \leq 6.2 \cdot 10^{+16}\right):\\
\;\;\;\;x_m \cdot \left(z \cdot y\right)\\

\mathbf{else}:\\
\;\;\;\;x_m \cdot \left(1 - z\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.50000000000000011e47 or 6.2e16 < y

    1. Initial program 93.5%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 75.0%

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

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

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

    if -2.50000000000000011e47 < y < 6.2e16

    1. Initial program 100.0%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 94.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.5 \cdot 10^{+47} \lor \neg \left(y \leq 6.2 \cdot 10^{+16}\right):\\ \;\;\;\;x \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 84.1% 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.8 \cdot 10^{+44}:\\ \;\;\;\;z \cdot \left(x_m \cdot y\right)\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{+17}:\\ \;\;\;\;x_m \cdot \left(1 - z\right)\\ \mathbf{else}:\\ \;\;\;\;x_m \cdot \left(z \cdot y\right)\\ \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.8e+44)
    (* z (* x_m y))
    (if (<= y 1.8e+17) (* x_m (- 1.0 z)) (* x_m (* z y))))))
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.8e+44) {
		tmp = z * (x_m * y);
	} else if (y <= 1.8e+17) {
		tmp = x_m * (1.0 - z);
	} else {
		tmp = x_m * (z * y);
	}
	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.8d+44)) then
        tmp = z * (x_m * y)
    else if (y <= 1.8d+17) then
        tmp = x_m * (1.0d0 - z)
    else
        tmp = x_m * (z * y)
    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.8e+44) {
		tmp = z * (x_m * y);
	} else if (y <= 1.8e+17) {
		tmp = x_m * (1.0 - z);
	} else {
		tmp = x_m * (z * y);
	}
	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.8e+44:
		tmp = z * (x_m * y)
	elif y <= 1.8e+17:
		tmp = x_m * (1.0 - z)
	else:
		tmp = x_m * (z * y)
	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.8e+44)
		tmp = Float64(z * Float64(x_m * y));
	elseif (y <= 1.8e+17)
		tmp = Float64(x_m * Float64(1.0 - z));
	else
		tmp = Float64(x_m * Float64(z * y));
	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.8e+44)
		tmp = z * (x_m * y);
	elseif (y <= 1.8e+17)
		tmp = x_m * (1.0 - z);
	else
		tmp = x_m * (z * y);
	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.8e+44], N[(z * N[(x$95$m * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.8e+17], N[(x$95$m * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(x$95$m * N[(z * y), $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.8 \cdot 10^{+44}:\\
\;\;\;\;z \cdot \left(x_m \cdot y\right)\\

\mathbf{elif}\;y \leq 1.8 \cdot 10^{+17}:\\
\;\;\;\;x_m \cdot \left(1 - z\right)\\

\mathbf{else}:\\
\;\;\;\;x_m \cdot \left(z \cdot y\right)\\


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

    1. Initial program 89.6%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 71.0%

      \[\leadsto \color{blue}{x \cdot \left(y \cdot z\right)} \]
    4. Step-by-step derivation
      1. associate-*r*77.8%

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

        \[\leadsto \color{blue}{z \cdot \left(x \cdot y\right)} \]
    5. Simplified77.8%

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

    if -1.8e44 < y < 1.8e17

    1. Initial program 100.0%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 94.5%

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

    if 1.8e17 < y

    1. Initial program 96.8%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 78.4%

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

        \[\leadsto x \cdot \color{blue}{\left(z \cdot y\right)} \]
    5. Simplified78.4%

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

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

Alternative 11: 84.2% 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 -5.2 \cdot 10^{+47}:\\ \;\;\;\;z \cdot \left(x_m \cdot y\right)\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{+16}:\\ \;\;\;\;x_m - x_m \cdot z\\ \mathbf{else}:\\ \;\;\;\;x_m \cdot \left(z \cdot y\right)\\ \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 -5.2e+47)
    (* z (* x_m y))
    (if (<= y 5.4e+16) (- x_m (* x_m z)) (* x_m (* z y))))))
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 <= -5.2e+47) {
		tmp = z * (x_m * y);
	} else if (y <= 5.4e+16) {
		tmp = x_m - (x_m * z);
	} else {
		tmp = x_m * (z * y);
	}
	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 <= (-5.2d+47)) then
        tmp = z * (x_m * y)
    else if (y <= 5.4d+16) then
        tmp = x_m - (x_m * z)
    else
        tmp = x_m * (z * y)
    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 <= -5.2e+47) {
		tmp = z * (x_m * y);
	} else if (y <= 5.4e+16) {
		tmp = x_m - (x_m * z);
	} else {
		tmp = x_m * (z * y);
	}
	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 <= -5.2e+47:
		tmp = z * (x_m * y)
	elif y <= 5.4e+16:
		tmp = x_m - (x_m * z)
	else:
		tmp = x_m * (z * y)
	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 <= -5.2e+47)
		tmp = Float64(z * Float64(x_m * y));
	elseif (y <= 5.4e+16)
		tmp = Float64(x_m - Float64(x_m * z));
	else
		tmp = Float64(x_m * Float64(z * y));
	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 <= -5.2e+47)
		tmp = z * (x_m * y);
	elseif (y <= 5.4e+16)
		tmp = x_m - (x_m * z);
	else
		tmp = x_m * (z * y);
	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, -5.2e+47], N[(z * N[(x$95$m * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.4e+16], N[(x$95$m - N[(x$95$m * z), $MachinePrecision]), $MachinePrecision], N[(x$95$m * N[(z * y), $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 -5.2 \cdot 10^{+47}:\\
\;\;\;\;z \cdot \left(x_m \cdot y\right)\\

\mathbf{elif}\;y \leq 5.4 \cdot 10^{+16}:\\
\;\;\;\;x_m - x_m \cdot z\\

\mathbf{else}:\\
\;\;\;\;x_m \cdot \left(z \cdot y\right)\\


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

    1. Initial program 89.6%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 71.0%

      \[\leadsto \color{blue}{x \cdot \left(y \cdot z\right)} \]
    4. Step-by-step derivation
      1. associate-*r*77.8%

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

        \[\leadsto \color{blue}{z \cdot \left(x \cdot y\right)} \]
    5. Simplified77.8%

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

    if -5.20000000000000007e47 < y < 5.4e16

    1. Initial program 100.0%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 100.0%

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

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

        \[\leadsto x + \color{blue}{\left(x \cdot \left(y \cdot z\right) + -1 \cdot \left(x \cdot z\right)\right)} \]
      2. *-commutative96.3%

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

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

        \[\leadsto x + \left(\left(x \cdot z\right) \cdot y + \color{blue}{\left(x \cdot z\right) \cdot -1}\right) \]
      5. distribute-lft-in100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x + -1 \cdot \left(x \cdot z\right)} \]
    11. Step-by-step derivation
      1. neg-mul-194.5%

        \[\leadsto x + \color{blue}{\left(-x \cdot z\right)} \]
      2. unsub-neg94.5%

        \[\leadsto \color{blue}{x - x \cdot z} \]
    12. Simplified94.5%

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

    if 5.4e16 < y

    1. Initial program 96.8%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 78.4%

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

        \[\leadsto x \cdot \color{blue}{\left(z \cdot y\right)} \]
    5. Simplified78.4%

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

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

Alternative 12: 63.9% accurate, 1.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}\;z \leq -210000000 \lor \neg \left(z \leq 1.45 \cdot 10^{-5}\right):\\ \;\;\;\;x_m \cdot \left(-z\right)\\ \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 (or (<= z -210000000.0) (not (<= z 1.45e-5))) (* 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 <= -210000000.0) || !(z <= 1.45e-5)) {
		tmp = 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 <= (-210000000.0d0)) .or. (.not. (z <= 1.45d-5))) then
        tmp = 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 <= -210000000.0) || !(z <= 1.45e-5)) {
		tmp = 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 <= -210000000.0) or not (z <= 1.45e-5):
		tmp = 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 <= -210000000.0) || !(z <= 1.45e-5))
		tmp = Float64(x_m * Float64(-z));
	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 ((z <= -210000000.0) || ~((z <= 1.45e-5)))
		tmp = 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[Or[LessEqual[z, -210000000.0], N[Not[LessEqual[z, 1.45e-5]], $MachinePrecision]], N[(x$95$m * (-z)), $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 -210000000 \lor \neg \left(z \leq 1.45 \cdot 10^{-5}\right):\\
\;\;\;\;x_m \cdot \left(-z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.1e8 or 1.45e-5 < z

    1. Initial program 94.0%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 93.3%

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

      \[\leadsto \color{blue}{-1 \cdot \left(x \cdot z\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg51.8%

        \[\leadsto \color{blue}{-x \cdot z} \]
      2. *-commutative51.8%

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

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

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

    if -2.1e8 < z < 1.45e-5

    1. Initial program 99.8%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 66.1%

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

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

Alternative 13: 37.9% accurate, 9.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 96.9%

    \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
  2. Add Preprocessing
  3. Taylor expanded in z around 0 35.2%

    \[\leadsto \color{blue}{x} \]
  4. Final simplification35.2%

    \[\leadsto x \]
  5. Add Preprocessing

Developer target: 99.7% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t_0 < 3.892237649663903 \cdot 10^{+134}:\\
\;\;\;\;\left(x \cdot y\right) \cdot z - \left(x \cdot z - x\right)\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024010 
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
  :precision binary64

  :herbie-target
  (if (< (* x (- 1.0 (* (- 1.0 y) z))) -1.618195973607049e+50) (+ x (* (- 1.0 y) (* (- z) x))) (if (< (* x (- 1.0 (* (- 1.0 y) z))) 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1.0 y) (* (- z) x)))))

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