?

Average Error: 0.4 → 0.2
Time: 32.4s
Precision: binary64
Cost: 704

?

\[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
\[x + \left(y - x\right) \cdot \left(4 + -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 (+ x (* (- y x) (+ 4.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 x + ((y - x) * (4.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 = x + ((y - x) * (4.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 x + ((y - x) * (4.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 x + ((y - x) * (4.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(x + Float64(Float64(y - x) * Float64(4.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 = x + ((y - x) * (4.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[(x + N[(N[(y - x), $MachinePrecision] * N[(4.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)
x + \left(y - x\right) \cdot \left(4 + -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.4

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

    [Start]0.4

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

    metadata-eval [=>]0.4

    \[ x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\color{blue}{0.6666666666666666} - z\right) \]
  3. Taylor expanded in z around 0 0.2

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

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

    [Start]0.2

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

    rational.json-simplify-1 [=>]0.2

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

    rational.json-simplify-2 [=>]0.2

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

    rational.json-simplify-43 [=>]0.2

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

    rational.json-simplify-51 [=>]0.2

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

    rational.json-simplify-2 [=>]0.2

    \[ x + \left(y - x\right) \cdot \left(4 + \color{blue}{-6 \cdot z}\right) \]
  5. Final simplification0.2

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

Alternatives

Alternative 1
Error20.8
Cost1504
\[\begin{array}{l} t_0 := -6 \cdot \left(z \cdot \left(y - x\right)\right)\\ \mathbf{if}\;z \leq -1.02 \cdot 10^{-5}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{-165}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -1.8 \cdot 10^{-306}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{-230}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-196}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{-129}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 1.22 \cdot 10^{-86}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.68:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error20.8
Cost1504
\[\begin{array}{l} t_0 := -6 \cdot \left(z \cdot \left(y - x\right)\right)\\ \mathbf{if}\;z \leq -1.02 \cdot 10^{-5}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2 \cdot 10^{-165}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -4 \cdot 10^{-307}:\\ \;\;\;\;x \cdot \left(z \cdot 6 + -3\right)\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-229}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{-196}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{-130}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{-86}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.5:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error20.8
Cost1504
\[\begin{array}{l} t_0 := z \cdot \left(-6 \cdot \left(y - x\right)\right)\\ \mathbf{if}\;z \leq -1.02 \cdot 10^{-5}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.8 \cdot 10^{-163}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -2.5 \cdot 10^{-307}:\\ \;\;\;\;x \cdot \left(z \cdot 6 + -3\right)\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{-229}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{-196}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 6.8 \cdot 10^{-130}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 4.7 \cdot 10^{-85}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.64:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error32.4
Cost1376
\[\begin{array}{l} t_0 := -6 \cdot \left(z \cdot y\right)\\ \mathbf{if}\;z \leq -0.65:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.5 \cdot 10^{-165}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -1.05 \cdot 10^{-305}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{-230}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{-196}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{-130}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{-86}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{-6}:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error32.4
Cost1376
\[\begin{array}{l} \mathbf{if}\;z \leq -1.02 \cdot 10^{-5}:\\ \;\;\;\;6 \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;z \leq -9.8 \cdot 10^{-166}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -1.05 \cdot 10^{-305}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{-230}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{-196}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 10^{-129}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-87}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{-6}:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;-6 \cdot \left(z \cdot y\right)\\ \end{array} \]
Alternative 6
Error32.5
Cost1376
\[\begin{array}{l} \mathbf{if}\;z \leq -1.02 \cdot 10^{-5}:\\ \;\;\;\;6 \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{-163}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -1.3 \cdot 10^{-306}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 2.55 \cdot 10^{-229}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 3.55 \cdot 10^{-196}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{-130}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{-87}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{-6}:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-6 \cdot y\right)\\ \end{array} \]
Alternative 7
Error1.8
Cost712
\[\begin{array}{l} t_0 := z \cdot \left(-6 \cdot \left(y - x\right)\right)\\ \mathbf{if}\;z \leq -0.58:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.55:\\ \;\;\;\;4 \cdot y + x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error0.4
Cost704
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right) \]
Alternative 9
Error34.7
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -7.8 \cdot 10^{-94}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{-65}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;4 \cdot y\\ \end{array} \]
Alternative 10
Error43.9
Cost192
\[4 \cdot y \]
Alternative 11
Error62.3
Cost64
\[x \]

Error

Reproduce?

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