?

Average Error: 0.4 → 0.2
Time: 16.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.4

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

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

    [Start]0.4

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

    +-commutative [=>]0.4

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

    associate-*l* [=>]0.2

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

    fma-def [=>]0.2

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

    sub-neg [=>]0.2

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

    distribute-lft-in [=>]0.2

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

    +-commutative [=>]0.2

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

    neg-mul-1 [=>]0.2

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

    associate-*r* [=>]0.2

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

    *-commutative [=>]0.2

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

    fma-def [=>]0.2

    \[ \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.2

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

    metadata-eval [=>]0.2

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

    metadata-eval [=>]0.2

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

    \[\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.2

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

Alternatives

Alternative 1
Error32.5
Cost1905
\[\begin{array}{l} t_0 := -6 \cdot \left(z \cdot y\right)\\ t_1 := 6 \cdot \left(z \cdot x\right)\\ \mathbf{if}\;z \leq -6.7 \cdot 10^{+93}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -6.4 \cdot 10^{-19}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.15 \cdot 10^{-231}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -2.85 \cdot 10^{-297}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 9 \cdot 10^{-259}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{-203}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-183}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.46 \cdot 10^{-164}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 9 \cdot 10^{-66}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.4:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{+65} \lor \neg \left(z \leq 8.2 \cdot 10^{+139}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error32.5
Cost1905
\[\begin{array}{l} t_0 := -6 \cdot \left(z \cdot y\right)\\ \mathbf{if}\;z \leq -1.3 \cdot 10^{+93}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -6.4 \cdot 10^{-19}:\\ \;\;\;\;6 \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;z \leq -1.56 \cdot 10^{-229}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -2.55 \cdot 10^{-297}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 10^{-258}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{-204}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{-183}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 4.3 \cdot 10^{-162}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{-66}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.4:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 1.85 \cdot 10^{+65} \lor \neg \left(z \leq 3.9 \cdot 10^{+139}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \end{array} \]
Alternative 3
Error32.5
Cost1905
\[\begin{array}{l} t_0 := -6 \cdot \left(z \cdot y\right)\\ \mathbf{if}\;z \leq -2.2 \cdot 10^{+94}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -6.4 \cdot 10^{-19}:\\ \;\;\;\;6 \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;z \leq -2.5 \cdot 10^{-230}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -2.2 \cdot 10^{-297}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 1.05 \cdot 10^{-258}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-203}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-183}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-166}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{-65}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.4:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{+65} \lor \neg \left(z \leq 2 \cdot 10^{+140}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot 6\right)\\ \end{array} \]
Alternative 4
Error32.4
Cost1905
\[\begin{array}{l} \mathbf{if}\;z \leq -3.55 \cdot 10^{+93}:\\ \;\;\;\;-6 \cdot \left(z \cdot y\right)\\ \mathbf{elif}\;z \leq -6.4 \cdot 10^{-19}:\\ \;\;\;\;6 \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;z \leq -6.8 \cdot 10^{-232}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -2.75 \cdot 10^{-297}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{-258}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{-204}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-183}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 8.8 \cdot 10^{-162}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 2.7 \cdot 10^{-65}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.4:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{+65} \lor \neg \left(z \leq 9.8 \cdot 10^{+138}\right):\\ \;\;\;\;z \cdot \left(-6 \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot 6\right)\\ \end{array} \]
Alternative 5
Error21.6
Cost1636
\[\begin{array}{l} t_0 := -6 \cdot \left(z \cdot \left(y - x\right)\right)\\ \mathbf{if}\;z \leq -6.4 \cdot 10^{-19}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.56 \cdot 10^{-229}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{-297}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 9.2 \cdot 10^{-259}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.05 \cdot 10^{-204}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-183}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 8.6 \cdot 10^{-163}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 9 \cdot 10^{-66}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.64:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error21.4
Cost1636
\[\begin{array}{l} t_0 := -6 \cdot \left(z \cdot \left(y - x\right)\right)\\ \mathbf{if}\;z \leq -6.4 \cdot 10^{-19}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.8 \cdot 10^{-232}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -5.1 \cdot 10^{-297}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{-259}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3 \cdot 10^{-204}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-183}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{-164}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{-65}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 76000000:\\ \;\;\;\;6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error32.8
Cost1508
\[\begin{array}{l} t_0 := -6 \cdot \left(z \cdot y\right)\\ \mathbf{if}\;z \leq -6.4 \cdot 10^{-19}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.75 \cdot 10^{-230}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{-297}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{-259}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-204}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-183}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{-164}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{-66}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.4:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error17.7
Cost1243
\[\begin{array}{l} \mathbf{if}\;y \leq -1.2 \cdot 10^{+21} \lor \neg \left(y \leq 5.6 \cdot 10^{-121}\right) \land \left(y \leq 6.2 \cdot 10^{-80} \lor \neg \left(y \leq 1.25 \cdot 10^{-40}\right) \land \left(y \leq 0.000145 \lor \neg \left(y \leq 2.7 \cdot 10^{+25}\right)\right)\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
Error17.7
Cost1241
\[\begin{array}{l} t_0 := x \cdot \left(-3 - -6 \cdot z\right)\\ t_1 := \left(-6 \cdot z + 4\right) \cdot y\\ \mathbf{if}\;y \leq -3.2 \cdot 10^{+20}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.8 \cdot 10^{-123}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{-81}:\\ \;\;\;\;6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{-40} \lor \neg \left(y \leq 0.00034\right) \land y \leq 3.4 \cdot 10^{+25}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error17.5
Cost1240
\[\begin{array}{l} t_0 := x \cdot \left(-3 - -6 \cdot z\right)\\ t_1 := \left(-6 \cdot z + 4\right) \cdot y\\ \mathbf{if}\;y \leq -2.25 \cdot 10^{+14}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5.6 \cdot 10^{-121}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{-81}:\\ \;\;\;\;6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-40}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 8.6 \cdot 10^{-6}:\\ \;\;\;\;\left(0.6666666666666666 - z\right) \cdot \left(y \cdot 6\right)\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{+25}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error0.3
Cost832
\[x + \frac{\left(y - x\right) \cdot 6}{\frac{1}{0.6666666666666666 - z}} \]
Alternative 12
Error1.8
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -0.6:\\ \;\;\;\;-6 \cdot \left(z \cdot \left(y - x\right)\right)\\ \mathbf{elif}\;z \leq 0.6:\\ \;\;\;\;4 \cdot y + x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-6 \cdot \left(y - x\right)\right)\\ \end{array} \]
Alternative 13
Error0.4
Cost704
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right) \]
Alternative 14
Error33.8
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.4 \cdot 10^{+61}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;x \leq 7 \cdot 10^{+14}:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot -3\\ \end{array} \]
Alternative 15
Error43.3
Cost192
\[4 \cdot y \]

Error

Reproduce?

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