Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, D

Percentage Accurate: 99.5% → 99.8%
Time: 12.5s
Alternatives: 10
Speedup: 1.2×

Specification

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

\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - 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 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: 99.5% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(y - x, 4 + z \cdot -6, x\right) \end{array} \]
(FPCore (x y z) :precision binary64 (fma (- y x) (+ 4.0 (* z -6.0)) x))
double code(double x, double y, double z) {
	return fma((y - x), (4.0 + (z * -6.0)), x);
}
function code(x, y, z)
	return fma(Float64(y - x), Float64(4.0 + Float64(z * -6.0)), x)
end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * N[(4.0 + N[(z * -6.0), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(y - x, 4 + z \cdot -6, x\right)
\end{array}
Derivation
  1. Initial program 99.6%

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

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

      \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x \]
    3. fma-define99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
    4. sub-neg99.8%

      \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
    5. distribute-rgt-in99.8%

      \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
    6. metadata-eval99.8%

      \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
    7. metadata-eval99.8%

      \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
    8. distribute-lft-neg-out99.8%

      \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
    9. distribute-rgt-neg-in99.8%

      \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
    10. metadata-eval99.8%

      \[\leadsto \mathsf{fma}\left(y - x, 4 + z \cdot \color{blue}{-6}, x\right) \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 4 + z \cdot -6, x\right)} \]
  4. Add Preprocessing
  5. Add Preprocessing

Alternative 2: 74.4% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(-3 + z \cdot 6\right)\\ \mathbf{if}\;x \leq -4 \cdot 10^{+143}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -1.9 \cdot 10^{+77}:\\ \;\;\;\;z \cdot \left(\left(y - x\right) \cdot -6\right)\\ \mathbf{elif}\;x \leq -940 \lor \neg \left(x \leq 1.45\right):\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (+ -3.0 (* z 6.0)))))
   (if (<= x -4e+143)
     t_0
     (if (<= x -1.9e+77)
       (* z (* (- y x) -6.0))
       (if (or (<= x -940.0) (not (<= x 1.45)))
         t_0
         (* y (+ 4.0 (* z -6.0))))))))
double code(double x, double y, double z) {
	double t_0 = x * (-3.0 + (z * 6.0));
	double tmp;
	if (x <= -4e+143) {
		tmp = t_0;
	} else if (x <= -1.9e+77) {
		tmp = z * ((y - x) * -6.0);
	} else if ((x <= -940.0) || !(x <= 1.45)) {
		tmp = t_0;
	} else {
		tmp = y * (4.0 + (z * -6.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 = x * ((-3.0d0) + (z * 6.0d0))
    if (x <= (-4d+143)) then
        tmp = t_0
    else if (x <= (-1.9d+77)) then
        tmp = z * ((y - x) * (-6.0d0))
    else if ((x <= (-940.0d0)) .or. (.not. (x <= 1.45d0))) then
        tmp = t_0
    else
        tmp = y * (4.0d0 + (z * (-6.0d0)))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x * (-3.0 + (z * 6.0));
	double tmp;
	if (x <= -4e+143) {
		tmp = t_0;
	} else if (x <= -1.9e+77) {
		tmp = z * ((y - x) * -6.0);
	} else if ((x <= -940.0) || !(x <= 1.45)) {
		tmp = t_0;
	} else {
		tmp = y * (4.0 + (z * -6.0));
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (-3.0 + (z * 6.0))
	tmp = 0
	if x <= -4e+143:
		tmp = t_0
	elif x <= -1.9e+77:
		tmp = z * ((y - x) * -6.0)
	elif (x <= -940.0) or not (x <= 1.45):
		tmp = t_0
	else:
		tmp = y * (4.0 + (z * -6.0))
	return tmp
function code(x, y, z)
	t_0 = Float64(x * Float64(-3.0 + Float64(z * 6.0)))
	tmp = 0.0
	if (x <= -4e+143)
		tmp = t_0;
	elseif (x <= -1.9e+77)
		tmp = Float64(z * Float64(Float64(y - x) * -6.0));
	elseif ((x <= -940.0) || !(x <= 1.45))
		tmp = t_0;
	else
		tmp = Float64(y * Float64(4.0 + Float64(z * -6.0)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * (-3.0 + (z * 6.0));
	tmp = 0.0;
	if (x <= -4e+143)
		tmp = t_0;
	elseif (x <= -1.9e+77)
		tmp = z * ((y - x) * -6.0);
	elseif ((x <= -940.0) || ~((x <= 1.45)))
		tmp = t_0;
	else
		tmp = y * (4.0 + (z * -6.0));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(-3.0 + N[(z * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4e+143], t$95$0, If[LessEqual[x, -1.9e+77], N[(z * N[(N[(y - x), $MachinePrecision] * -6.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, -940.0], N[Not[LessEqual[x, 1.45]], $MachinePrecision]], t$95$0, N[(y * N[(4.0 + N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \left(-3 + z \cdot 6\right)\\
\mathbf{if}\;x \leq -4 \cdot 10^{+143}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq -1.9 \cdot 10^{+77}:\\
\;\;\;\;z \cdot \left(\left(y - x\right) \cdot -6\right)\\

\mathbf{elif}\;x \leq -940 \lor \neg \left(x \leq 1.45\right):\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -4.0000000000000001e143 or -1.9000000000000001e77 < x < -940 or 1.44999999999999996 < x

    1. Initial program 99.5%

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

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x \]
      3. fma-define99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
      4. sub-neg99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. distribute-rgt-in99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
      6. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
      7. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
      8. distribute-lft-neg-out99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
      9. distribute-rgt-neg-in99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
      10. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + z \cdot \color{blue}{-6}, x\right) \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 4 + z \cdot -6, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 81.3%

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

        \[\leadsto x + \color{blue}{\left(-x \cdot \left(4 + -6 \cdot z\right)\right)} \]
      2. *-lft-identity81.3%

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

        \[\leadsto 1 \cdot x + \left(-\color{blue}{\left(4 + -6 \cdot z\right) \cdot x}\right) \]
      4. distribute-lft-neg-in81.3%

        \[\leadsto 1 \cdot x + \color{blue}{\left(-\left(4 + -6 \cdot z\right)\right) \cdot x} \]
      5. mul-1-neg81.3%

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

        \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \left(4 + -6 \cdot z\right)\right)} \]
      7. distribute-rgt-in81.3%

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

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + \left(-6 \cdot z\right) \cdot -1\right)\right) \]
      9. associate-+r+81.3%

        \[\leadsto x \cdot \color{blue}{\left(\left(1 + -4\right) + \left(-6 \cdot z\right) \cdot -1\right)} \]
      10. metadata-eval81.3%

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

        \[\leadsto x \cdot \left(-3 + \color{blue}{\left(z \cdot -6\right)} \cdot -1\right) \]
      12. associate-*l*81.3%

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

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

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

    if -4.0000000000000001e143 < x < -1.9000000000000001e77

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x \]
      3. fma-define100.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
      4. sub-neg100.0%

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. distribute-rgt-in100.0%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
      6. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
      7. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
      8. distribute-lft-neg-out100.0%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
      9. distribute-rgt-neg-in100.0%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
      10. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + z \cdot \color{blue}{-6}, x\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 4 + z \cdot -6, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 85.0%

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

        \[\leadsto z \cdot \color{blue}{\left(\left(-6 \cdot \left(y - x\right) + 4 \cdot \frac{y - x}{z}\right) + \frac{x}{z}\right)} \]
      2. *-commutative85.0%

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

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

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

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

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

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

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

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

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

    if -940 < x < 1.44999999999999996

    1. Initial program 99.6%

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

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x \]
      3. fma-define99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
      4. sub-neg99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. distribute-rgt-in99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
      6. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
      7. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
      8. distribute-lft-neg-out99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
      9. distribute-rgt-neg-in99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
      10. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + z \cdot \color{blue}{-6}, x\right) \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 4 + z \cdot -6, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 79.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{+143}:\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \mathbf{elif}\;x \leq -1.9 \cdot 10^{+77}:\\ \;\;\;\;z \cdot \left(\left(y - x\right) \cdot -6\right)\\ \mathbf{elif}\;x \leq -940 \lor \neg \left(x \leq 1.45\right):\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 75.8% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -7800 \lor \neg \left(x \leq 0.33\right):\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -7800.0) (not (<= x 0.33)))
   (* x (+ -3.0 (* z 6.0)))
   (* y (+ 4.0 (* z -6.0)))))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -7800.0) || !(x <= 0.33)) {
		tmp = x * (-3.0 + (z * 6.0));
	} else {
		tmp = y * (4.0 + (z * -6.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) :: tmp
    if ((x <= (-7800.0d0)) .or. (.not. (x <= 0.33d0))) then
        tmp = x * ((-3.0d0) + (z * 6.0d0))
    else
        tmp = y * (4.0d0 + (z * (-6.0d0)))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -7800.0) || !(x <= 0.33)) {
		tmp = x * (-3.0 + (z * 6.0));
	} else {
		tmp = y * (4.0 + (z * -6.0));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x <= -7800.0) or not (x <= 0.33):
		tmp = x * (-3.0 + (z * 6.0))
	else:
		tmp = y * (4.0 + (z * -6.0))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((x <= -7800.0) || !(x <= 0.33))
		tmp = Float64(x * Float64(-3.0 + Float64(z * 6.0)));
	else
		tmp = Float64(y * Float64(4.0 + Float64(z * -6.0)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -7800.0) || ~((x <= 0.33)))
		tmp = x * (-3.0 + (z * 6.0));
	else
		tmp = y * (4.0 + (z * -6.0));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[x, -7800.0], N[Not[LessEqual[x, 0.33]], $MachinePrecision]], N[(x * N[(-3.0 + N[(z * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(4.0 + N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -7800 \lor \neg \left(x \leq 0.33\right):\\
\;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -7800 or 0.330000000000000016 < x

    1. Initial program 99.6%

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

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x \]
      3. fma-define99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
      4. sub-neg99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. distribute-rgt-in99.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
      6. metadata-eval99.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
      7. metadata-eval99.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
      8. distribute-lft-neg-out99.9%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
      9. distribute-rgt-neg-in99.9%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
      10. metadata-eval99.9%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 4 + z \cdot -6, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 78.2%

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

        \[\leadsto x + \color{blue}{\left(-x \cdot \left(4 + -6 \cdot z\right)\right)} \]
      2. *-lft-identity78.2%

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

        \[\leadsto 1 \cdot x + \left(-\color{blue}{\left(4 + -6 \cdot z\right) \cdot x}\right) \]
      4. distribute-lft-neg-in78.2%

        \[\leadsto 1 \cdot x + \color{blue}{\left(-\left(4 + -6 \cdot z\right)\right) \cdot x} \]
      5. mul-1-neg78.2%

        \[\leadsto 1 \cdot x + \color{blue}{\left(-1 \cdot \left(4 + -6 \cdot z\right)\right)} \cdot x \]
      6. distribute-rgt-in78.2%

        \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \left(4 + -6 \cdot z\right)\right)} \]
      7. distribute-rgt-in78.2%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(4 \cdot -1 + \left(-6 \cdot z\right) \cdot -1\right)}\right) \]
      8. metadata-eval78.2%

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + \left(-6 \cdot z\right) \cdot -1\right)\right) \]
      9. associate-+r+78.2%

        \[\leadsto x \cdot \color{blue}{\left(\left(1 + -4\right) + \left(-6 \cdot z\right) \cdot -1\right)} \]
      10. metadata-eval78.2%

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

        \[\leadsto x \cdot \left(-3 + \color{blue}{\left(z \cdot -6\right)} \cdot -1\right) \]
      12. associate-*l*78.2%

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

        \[\leadsto x \cdot \left(-3 + z \cdot \color{blue}{6}\right) \]
    7. Simplified78.2%

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

    if -7800 < x < 0.330000000000000016

    1. Initial program 99.6%

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

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x \]
      3. fma-define99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
      4. sub-neg99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. distribute-rgt-in99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
      6. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
      7. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
      8. distribute-lft-neg-out99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
      9. distribute-rgt-neg-in99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
      10. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + z \cdot \color{blue}{-6}, x\right) \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 4 + z \cdot -6, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 79.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7800 \lor \neg \left(x \leq 0.33\right):\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 58.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.35 \cdot 10^{-59} \lor \neg \left(x \leq 0.65\right):\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot 4\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -1.35e-59) (not (<= x 0.65)))
   (* x (+ -3.0 (* z 6.0)))
   (* y 4.0)))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -1.35e-59) || !(x <= 0.65)) {
		tmp = x * (-3.0 + (z * 6.0));
	} else {
		tmp = y * 4.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) :: tmp
    if ((x <= (-1.35d-59)) .or. (.not. (x <= 0.65d0))) then
        tmp = x * ((-3.0d0) + (z * 6.0d0))
    else
        tmp = y * 4.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -1.35e-59) || !(x <= 0.65)) {
		tmp = x * (-3.0 + (z * 6.0));
	} else {
		tmp = y * 4.0;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x <= -1.35e-59) or not (x <= 0.65):
		tmp = x * (-3.0 + (z * 6.0))
	else:
		tmp = y * 4.0
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((x <= -1.35e-59) || !(x <= 0.65))
		tmp = Float64(x * Float64(-3.0 + Float64(z * 6.0)));
	else
		tmp = Float64(y * 4.0);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -1.35e-59) || ~((x <= 0.65)))
		tmp = x * (-3.0 + (z * 6.0));
	else
		tmp = y * 4.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.35e-59], N[Not[LessEqual[x, 0.65]], $MachinePrecision]], N[(x * N[(-3.0 + N[(z * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * 4.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{-59} \lor \neg \left(x \leq 0.65\right):\\
\;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\

\mathbf{else}:\\
\;\;\;\;y \cdot 4\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.3499999999999999e-59 or 0.650000000000000022 < x

    1. Initial program 99.6%

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

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x \]
      3. fma-define99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
      4. sub-neg99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. distribute-rgt-in99.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
      6. metadata-eval99.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
      7. metadata-eval99.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
      8. distribute-lft-neg-out99.9%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
      9. distribute-rgt-neg-in99.9%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
      10. metadata-eval99.9%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 4 + z \cdot -6, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 75.6%

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

        \[\leadsto x + \color{blue}{\left(-x \cdot \left(4 + -6 \cdot z\right)\right)} \]
      2. *-lft-identity75.6%

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

        \[\leadsto 1 \cdot x + \left(-\color{blue}{\left(4 + -6 \cdot z\right) \cdot x}\right) \]
      4. distribute-lft-neg-in75.6%

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

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

        \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \left(4 + -6 \cdot z\right)\right)} \]
      7. distribute-rgt-in75.6%

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

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + \left(-6 \cdot z\right) \cdot -1\right)\right) \]
      9. associate-+r+75.6%

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

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

        \[\leadsto x \cdot \left(-3 + \color{blue}{\left(z \cdot -6\right)} \cdot -1\right) \]
      12. associate-*l*75.6%

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

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

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

    if -1.3499999999999999e-59 < x < 0.650000000000000022

    1. Initial program 99.5%

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

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x \]
      3. fma-define99.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
      4. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. distribute-rgt-in99.7%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
      6. metadata-eval99.7%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
      7. metadata-eval99.7%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
      8. distribute-lft-neg-out99.7%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
      9. distribute-rgt-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
      10. metadata-eval99.7%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + z \cdot \color{blue}{-6}, x\right) \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 4 + z \cdot -6, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 99.7%

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

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

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

        \[\leadsto y \cdot \left(\color{blue}{\left(-4 + 1\right) \cdot \frac{x}{y}} + 4\right) \]
      3. fma-define53.4%

        \[\leadsto y \cdot \color{blue}{\mathsf{fma}\left(-4 + 1, \frac{x}{y}, 4\right)} \]
      4. metadata-eval53.4%

        \[\leadsto y \cdot \mathsf{fma}\left(\color{blue}{-3}, \frac{x}{y}, 4\right) \]
    8. Simplified53.4%

      \[\leadsto \color{blue}{y \cdot \mathsf{fma}\left(-3, \frac{x}{y}, 4\right)} \]
    9. Taylor expanded in y around inf 45.6%

      \[\leadsto \color{blue}{4 \cdot y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification63.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.35 \cdot 10^{-59} \lor \neg \left(x \leq 0.65\right):\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot 4\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 97.8% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -0.65:\\ \;\;\;\;x + z \cdot \left(y \cdot -6 + x \cdot 6\right)\\ \mathbf{elif}\;z \leq 0.5:\\ \;\;\;\;x + \left(y - x\right) \cdot 4\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(\left(y - x\right) \cdot -6\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -0.65)
   (+ x (* z (+ (* y -6.0) (* x 6.0))))
   (if (<= z 0.5) (+ x (* (- y x) 4.0)) (* z (* (- y x) -6.0)))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -0.65) {
		tmp = x + (z * ((y * -6.0) + (x * 6.0)));
	} else if (z <= 0.5) {
		tmp = x + ((y - x) * 4.0);
	} else {
		tmp = z * ((y - x) * -6.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) :: tmp
    if (z <= (-0.65d0)) then
        tmp = x + (z * ((y * (-6.0d0)) + (x * 6.0d0)))
    else if (z <= 0.5d0) then
        tmp = x + ((y - x) * 4.0d0)
    else
        tmp = z * ((y - x) * (-6.0d0))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -0.65) {
		tmp = x + (z * ((y * -6.0) + (x * 6.0)));
	} else if (z <= 0.5) {
		tmp = x + ((y - x) * 4.0);
	} else {
		tmp = z * ((y - x) * -6.0);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -0.65:
		tmp = x + (z * ((y * -6.0) + (x * 6.0)))
	elif z <= 0.5:
		tmp = x + ((y - x) * 4.0)
	else:
		tmp = z * ((y - x) * -6.0)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -0.65)
		tmp = Float64(x + Float64(z * Float64(Float64(y * -6.0) + Float64(x * 6.0))));
	elseif (z <= 0.5)
		tmp = Float64(x + Float64(Float64(y - x) * 4.0));
	else
		tmp = Float64(z * Float64(Float64(y - x) * -6.0));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -0.65)
		tmp = x + (z * ((y * -6.0) + (x * 6.0)));
	elseif (z <= 0.5)
		tmp = x + ((y - x) * 4.0);
	else
		tmp = z * ((y - x) * -6.0);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -0.65], N[(x + N[(z * N[(N[(y * -6.0), $MachinePrecision] + N[(x * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.5], N[(x + N[(N[(y - x), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(y - x), $MachinePrecision] * -6.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.65:\\
\;\;\;\;x + z \cdot \left(y \cdot -6 + x \cdot 6\right)\\

\mathbf{elif}\;z \leq 0.5:\\
\;\;\;\;x + \left(y - x\right) \cdot 4\\

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


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

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. metadata-eval99.7%

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

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

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

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

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

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

        \[\leadsto x + -1 \cdot \left(z \cdot \color{blue}{\mathsf{fma}\left(x, -6, y \cdot 6\right)}\right) \]
      4. neg-mul-198.6%

        \[\leadsto x + \color{blue}{\left(-z \cdot \mathsf{fma}\left(x, -6, y \cdot 6\right)\right)} \]
      5. distribute-rgt-neg-in98.6%

        \[\leadsto x + \color{blue}{z \cdot \left(-\mathsf{fma}\left(x, -6, y \cdot 6\right)\right)} \]
      6. fma-undefine98.7%

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

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

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

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

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

        \[\leadsto x + z \cdot \left(-\left(y \cdot 6 + \color{blue}{x \cdot -6}\right)\right) \]
      12. distribute-neg-in98.7%

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

        \[\leadsto x + z \cdot \left(\left(-\color{blue}{6 \cdot y}\right) + \left(-x \cdot -6\right)\right) \]
      14. distribute-lft-neg-in98.7%

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

        \[\leadsto x + z \cdot \left(\color{blue}{-6} \cdot y + \left(-x \cdot -6\right)\right) \]
      16. distribute-rgt-neg-in98.7%

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

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

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

    if -0.650000000000000022 < z < 0.5

    1. Initial program 99.4%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. metadata-eval99.4%

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

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

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

    if 0.5 < z

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x \]
      3. fma-define99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
      4. sub-neg99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. distribute-rgt-in99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
      6. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
      7. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
      8. distribute-lft-neg-out99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
      9. distribute-rgt-neg-in99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
      10. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + z \cdot \color{blue}{-6}, x\right) \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 4 + z \cdot -6, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 99.9%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -0.65:\\ \;\;\;\;x + z \cdot \left(y \cdot -6 + x \cdot 6\right)\\ \mathbf{elif}\;z \leq 0.5:\\ \;\;\;\;x + \left(y - x\right) \cdot 4\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(\left(y - x\right) \cdot -6\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 97.9% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -0.55:\\ \;\;\;\;\left(y - x\right) \cdot \left(z \cdot -6\right)\\ \mathbf{elif}\;z \leq 0.66:\\ \;\;\;\;x + \left(y - x\right) \cdot 4\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(\left(y - x\right) \cdot -6\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -0.55)
   (* (- y x) (* z -6.0))
   (if (<= z 0.66) (+ x (* (- y x) 4.0)) (* z (* (- y x) -6.0)))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -0.55) {
		tmp = (y - x) * (z * -6.0);
	} else if (z <= 0.66) {
		tmp = x + ((y - x) * 4.0);
	} else {
		tmp = z * ((y - x) * -6.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) :: tmp
    if (z <= (-0.55d0)) then
        tmp = (y - x) * (z * (-6.0d0))
    else if (z <= 0.66d0) then
        tmp = x + ((y - x) * 4.0d0)
    else
        tmp = z * ((y - x) * (-6.0d0))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -0.55) {
		tmp = (y - x) * (z * -6.0);
	} else if (z <= 0.66) {
		tmp = x + ((y - x) * 4.0);
	} else {
		tmp = z * ((y - x) * -6.0);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -0.55:
		tmp = (y - x) * (z * -6.0)
	elif z <= 0.66:
		tmp = x + ((y - x) * 4.0)
	else:
		tmp = z * ((y - x) * -6.0)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -0.55)
		tmp = Float64(Float64(y - x) * Float64(z * -6.0));
	elseif (z <= 0.66)
		tmp = Float64(x + Float64(Float64(y - x) * 4.0));
	else
		tmp = Float64(z * Float64(Float64(y - x) * -6.0));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -0.55)
		tmp = (y - x) * (z * -6.0);
	elseif (z <= 0.66)
		tmp = x + ((y - x) * 4.0);
	else
		tmp = z * ((y - x) * -6.0);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -0.55], N[(N[(y - x), $MachinePrecision] * N[(z * -6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.66], N[(x + N[(N[(y - x), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(y - x), $MachinePrecision] * -6.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.55:\\
\;\;\;\;\left(y - x\right) \cdot \left(z \cdot -6\right)\\

\mathbf{elif}\;z \leq 0.66:\\
\;\;\;\;x + \left(y - x\right) \cdot 4\\

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


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

    1. Initial program 99.7%

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

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x \]
      3. fma-define99.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
      4. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. distribute-rgt-in99.7%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
      6. metadata-eval99.7%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
      7. metadata-eval99.7%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
      8. distribute-lft-neg-out99.7%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
      9. distribute-rgt-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
      10. metadata-eval99.7%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + z \cdot \color{blue}{-6}, x\right) \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 4 + z \cdot -6, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.55000000000000004 < z < 0.660000000000000031

    1. Initial program 99.4%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. metadata-eval99.4%

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

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

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

    if 0.660000000000000031 < z

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x \]
      3. fma-define99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
      4. sub-neg99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. distribute-rgt-in99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
      6. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
      7. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
      8. distribute-lft-neg-out99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
      9. distribute-rgt-neg-in99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
      10. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + z \cdot \color{blue}{-6}, x\right) \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 4 + z \cdot -6, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 99.9%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -0.55:\\ \;\;\;\;\left(y - x\right) \cdot \left(z \cdot -6\right)\\ \mathbf{elif}\;z \leq 0.66:\\ \;\;\;\;x + \left(y - x\right) \cdot 4\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(\left(y - x\right) \cdot -6\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 38.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.8 \cdot 10^{-27} \lor \neg \left(x \leq 1.15 \cdot 10^{+36}\right):\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;y \cdot 4\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -2.8e-27) (not (<= x 1.15e+36))) (* x -3.0) (* y 4.0)))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -2.8e-27) || !(x <= 1.15e+36)) {
		tmp = x * -3.0;
	} else {
		tmp = y * 4.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) :: tmp
    if ((x <= (-2.8d-27)) .or. (.not. (x <= 1.15d+36))) then
        tmp = x * (-3.0d0)
    else
        tmp = y * 4.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -2.8e-27) || !(x <= 1.15e+36)) {
		tmp = x * -3.0;
	} else {
		tmp = y * 4.0;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x <= -2.8e-27) or not (x <= 1.15e+36):
		tmp = x * -3.0
	else:
		tmp = y * 4.0
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((x <= -2.8e-27) || !(x <= 1.15e+36))
		tmp = Float64(x * -3.0);
	else
		tmp = Float64(y * 4.0);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -2.8e-27) || ~((x <= 1.15e+36)))
		tmp = x * -3.0;
	else
		tmp = y * 4.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.8e-27], N[Not[LessEqual[x, 1.15e+36]], $MachinePrecision]], N[(x * -3.0), $MachinePrecision], N[(y * 4.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.8 \cdot 10^{-27} \lor \neg \left(x \leq 1.15 \cdot 10^{+36}\right):\\
\;\;\;\;x \cdot -3\\

\mathbf{else}:\\
\;\;\;\;y \cdot 4\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.8e-27 or 1.14999999999999998e36 < x

    1. Initial program 99.6%

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

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x \]
      3. fma-define99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
      4. sub-neg99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. distribute-rgt-in99.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
      6. metadata-eval99.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
      7. metadata-eval99.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
      8. distribute-lft-neg-out99.9%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
      9. distribute-rgt-neg-in99.9%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
      10. metadata-eval99.9%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 4 + z \cdot -6, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 70.0%

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

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

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

        \[\leadsto y \cdot \left(\color{blue}{\left(-4 + 1\right) \cdot \frac{x}{y}} + 4\right) \]
      3. fma-define40.4%

        \[\leadsto y \cdot \color{blue}{\mathsf{fma}\left(-4 + 1, \frac{x}{y}, 4\right)} \]
      4. metadata-eval40.4%

        \[\leadsto y \cdot \mathsf{fma}\left(\color{blue}{-3}, \frac{x}{y}, 4\right) \]
    8. Simplified40.4%

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

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

    if -2.8e-27 < x < 1.14999999999999998e36

    1. Initial program 99.5%

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

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x \]
      3. fma-define99.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
      4. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. distribute-rgt-in99.7%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
      6. metadata-eval99.7%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
      7. metadata-eval99.7%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
      8. distribute-lft-neg-out99.7%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
      9. distribute-rgt-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
      10. metadata-eval99.7%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + z \cdot \color{blue}{-6}, x\right) \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 4 + z \cdot -6, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 99.7%

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

      \[\leadsto \color{blue}{y \cdot \left(4 + \left(-4 \cdot \frac{x}{y} + \frac{x}{y}\right)\right)} \]
    7. Step-by-step derivation
      1. +-commutative53.6%

        \[\leadsto y \cdot \color{blue}{\left(\left(-4 \cdot \frac{x}{y} + \frac{x}{y}\right) + 4\right)} \]
      2. distribute-lft1-in53.6%

        \[\leadsto y \cdot \left(\color{blue}{\left(-4 + 1\right) \cdot \frac{x}{y}} + 4\right) \]
      3. fma-define53.6%

        \[\leadsto y \cdot \color{blue}{\mathsf{fma}\left(-4 + 1, \frac{x}{y}, 4\right)} \]
      4. metadata-eval53.6%

        \[\leadsto y \cdot \mathsf{fma}\left(\color{blue}{-3}, \frac{x}{y}, 4\right) \]
    8. Simplified53.6%

      \[\leadsto \color{blue}{y \cdot \mathsf{fma}\left(-3, \frac{x}{y}, 4\right)} \]
    9. Taylor expanded in y around inf 44.8%

      \[\leadsto \color{blue}{4 \cdot y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification41.7%

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

Alternative 8: 99.5% accurate, 1.0× speedup?

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

\\
x + \left(x \cdot -6 + y \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)
\end{array}
Derivation
  1. Initial program 99.6%

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

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

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

    \[\leadsto x + \color{blue}{\left(-6 \cdot x + 6 \cdot y\right)} \cdot \left(0.6666666666666666 - z\right) \]
  6. Final simplification99.6%

    \[\leadsto x + \left(x \cdot -6 + y \cdot 6\right) \cdot \left(0.6666666666666666 - z\right) \]
  7. Add Preprocessing

Alternative 9: 99.5% accurate, 1.2× speedup?

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

\\
x + \left(0.6666666666666666 - z\right) \cdot \left(\left(y - x\right) \cdot 6\right)
\end{array}
Derivation
  1. Initial program 99.6%

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

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

    \[\leadsto \color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)} \]
  4. Add Preprocessing
  5. Final simplification99.6%

    \[\leadsto x + \left(0.6666666666666666 - z\right) \cdot \left(\left(y - x\right) \cdot 6\right) \]
  6. Add Preprocessing

Alternative 10: 26.7% accurate, 4.3× speedup?

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

\\
x \cdot -3
\end{array}
Derivation
  1. Initial program 99.6%

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

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

      \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x \]
    3. fma-define99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
    4. sub-neg99.8%

      \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
    5. distribute-rgt-in99.8%

      \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
    6. metadata-eval99.8%

      \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
    7. metadata-eval99.8%

      \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
    8. distribute-lft-neg-out99.8%

      \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
    9. distribute-rgt-neg-in99.8%

      \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
    10. metadata-eval99.8%

      \[\leadsto \mathsf{fma}\left(y - x, 4 + z \cdot \color{blue}{-6}, x\right) \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 4 + z \cdot -6, x\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in y around inf 83.9%

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

    \[\leadsto \color{blue}{y \cdot \left(4 + \left(-4 \cdot \frac{x}{y} + \frac{x}{y}\right)\right)} \]
  7. Step-by-step derivation
    1. +-commutative42.9%

      \[\leadsto y \cdot \color{blue}{\left(\left(-4 \cdot \frac{x}{y} + \frac{x}{y}\right) + 4\right)} \]
    2. distribute-lft1-in46.6%

      \[\leadsto y \cdot \left(\color{blue}{\left(-4 + 1\right) \cdot \frac{x}{y}} + 4\right) \]
    3. fma-define46.6%

      \[\leadsto y \cdot \color{blue}{\mathsf{fma}\left(-4 + 1, \frac{x}{y}, 4\right)} \]
    4. metadata-eval46.6%

      \[\leadsto y \cdot \mathsf{fma}\left(\color{blue}{-3}, \frac{x}{y}, 4\right) \]
  8. Simplified46.6%

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

    \[\leadsto \color{blue}{-3 \cdot x} \]
  10. Final simplification25.8%

    \[\leadsto x \cdot -3 \]
  11. Add Preprocessing

Reproduce

?
herbie shell --seed 2024111 
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, D"
  :precision binary64
  (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))