?

Average Error: 0.61% → 0.28%
Time: 12.4s
Precision: binary64
Cost: 960

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 0.61

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
  2. Simplified0.29

    \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, 4\right), x\right)} \]
    Proof

    [Start]0.61

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

    +-commutative [=>]0.61

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

    associate-*l* [=>]0.31

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

    fma-def [=>]0.31

    \[ \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]

    sub-neg [=>]0.31

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

    distribute-lft-in [=>]0.29

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

    +-commutative [=>]0.29

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

    neg-mul-1 [=>]0.29

    \[ \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(-1 \cdot z\right)} + 6 \cdot \frac{2}{3}, x\right) \]

    associate-*r* [=>]0.29

    \[ \mathsf{fma}\left(y - x, \color{blue}{\left(6 \cdot -1\right) \cdot z} + 6 \cdot \frac{2}{3}, x\right) \]

    *-commutative [=>]0.29

    \[ \mathsf{fma}\left(y - x, \color{blue}{z \cdot \left(6 \cdot -1\right)} + 6 \cdot \frac{2}{3}, x\right) \]

    fma-def [=>]0.29

    \[ \mathsf{fma}\left(y - x, \color{blue}{\mathsf{fma}\left(z, 6 \cdot -1, 6 \cdot \frac{2}{3}\right)}, x\right) \]

    metadata-eval [=>]0.29

    \[ \mathsf{fma}\left(y - x, \mathsf{fma}\left(z, \color{blue}{-6}, 6 \cdot \frac{2}{3}\right), x\right) \]

    metadata-eval [=>]0.29

    \[ \mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, 6 \cdot \color{blue}{0.6666666666666666}\right), x\right) \]

    metadata-eval [=>]0.29

    \[ \mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, \color{blue}{4}\right), x\right) \]
  3. Taylor expanded in x around -inf 0.28

    \[\leadsto \color{blue}{-1 \cdot \left(\left(3 + -6 \cdot z\right) \cdot x\right) + \left(4 + -6 \cdot z\right) \cdot y} \]
  4. Final simplification0.28

    \[\leadsto \left(-6 \cdot z + 4\right) \cdot y + x \cdot \left(-3 - -6 \cdot z\right) \]

Alternatives

Alternative 1
Error50.97%
Cost1377
\[\begin{array}{l} t_0 := -6 \cdot \left(z \cdot y\right)\\ \mathbf{if}\;z \leq -0.68:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{-83}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -1.1 \cdot 10^{-144}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{-186}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{-135}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.68:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 4 \cdot 10^{+203} \lor \neg \left(z \leq 1.3 \cdot 10^{+260}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(z \cdot x\right)\\ \end{array} \]
Alternative 2
Error51.11%
Cost1377
\[\begin{array}{l} t_0 := -6 \cdot \left(z \cdot y\right)\\ \mathbf{if}\;z \leq -0.68:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -7.2 \cdot 10^{-85}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -8.8 \cdot 10^{-145}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 9 \cdot 10^{-187}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 8.2 \cdot 10^{-136}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.68:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 2.55 \cdot 10^{+194} \lor \neg \left(z \leq 1.55 \cdot 10^{+261}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot 6\right)\\ \end{array} \]
Alternative 3
Error50.94%
Cost1376
\[\begin{array}{l} t_0 := z \cdot \left(-6 \cdot y\right)\\ \mathbf{if}\;z \leq -0.68:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2.4 \cdot 10^{-82}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -1.06 \cdot 10^{-144}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{-187}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 9.4 \cdot 10^{-136}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.68:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 1.05 \cdot 10^{+199}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{+261}:\\ \;\;\;\;z \cdot \left(x \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;-6 \cdot \left(z \cdot y\right)\\ \end{array} \]
Alternative 4
Error33.21%
Cost1240
\[\begin{array}{l} t_0 := -6 \cdot \left(z \cdot \left(y - x\right)\right)\\ \mathbf{if}\;z \leq -0.0235:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.22 \cdot 10^{-86}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -1.1 \cdot 10^{-144}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{-186}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 8.2 \cdot 10^{-136}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.68:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error32.74%
Cost1240
\[\begin{array}{l} t_0 := 6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ t_1 := -6 \cdot \left(z \cdot \left(y - x\right)\right)\\ \mathbf{if}\;z \leq -390000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.5 \cdot 10^{-85}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.1 \cdot 10^{-144}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 6.8 \cdot 10^{-187}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 8.2 \cdot 10^{-136}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 940000000000:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error51%
Cost1112
\[\begin{array}{l} t_0 := -6 \cdot \left(z \cdot y\right)\\ \mathbf{if}\;z \leq -0.68:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.35 \cdot 10^{-83}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -8.8 \cdot 10^{-145}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{-186}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 9.2 \cdot 10^{-136}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.68:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error0.52%
Cost832
\[x + \frac{6 \cdot \left(0.6666666666666666 - z\right)}{\frac{1}{y - x}} \]
Alternative 8
Error27.91%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -3 \cdot 10^{-128} \lor \neg \left(y \leq 3.6 \cdot 10^{-61}\right):\\ \;\;\;\;6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-3 - -6 \cdot z\right)\\ \end{array} \]
Alternative 9
Error27.89%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -2.2 \cdot 10^{-128} \lor \neg \left(y \leq 7.6 \cdot 10^{-73}\right):\\ \;\;\;\;\left(-6 \cdot z + 4\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-3 - -6 \cdot z\right)\\ \end{array} \]
Alternative 10
Error2.91%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -0.61 \lor \neg \left(z \leq 0.6\right):\\ \;\;\;\;z \cdot \left(-6 \cdot \left(y - x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;4 \cdot y + x \cdot -3\\ \end{array} \]
Alternative 11
Error0.61%
Cost704
\[x + \left(0.6666666666666666 - z\right) \cdot \left(6 \cdot \left(y - x\right)\right) \]
Alternative 12
Error53.2%
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{+54}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;y \leq 4.3 \cdot 10^{+71}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;4 \cdot y\\ \end{array} \]
Alternative 13
Error68.13%
Cost192
\[4 \cdot y \]

Error

Reproduce?

herbie shell --seed 2023121 
(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))))