Average Error: 0.4 → 0.2
Time: 13.2s
Precision: binary64
Cost: 960
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
\[x \cdot \left(z \cdot 6 + -3\right) + \left(-6 \cdot z + 4\right) \cdot y \]
(FPCore (x y z)
 :precision binary64
 (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))
(FPCore (x y z)
 :precision binary64
 (+ (* x (+ (* z 6.0) -3.0)) (* (+ (* -6.0 z) 4.0) y)))
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 * ((z * 6.0) + -3.0)) + (((-6.0 * z) + 4.0) * y);
}
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 * ((z * 6.0d0) + (-3.0d0))) + ((((-6.0d0) * z) + 4.0d0) * y)
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 * ((z * 6.0) + -3.0)) + (((-6.0 * z) + 4.0) * y);
}
def code(x, y, z):
	return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z))
def code(x, y, z):
	return (x * ((z * 6.0) + -3.0)) + (((-6.0 * z) + 4.0) * y)
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(x * Float64(Float64(z * 6.0) + -3.0)) + Float64(Float64(Float64(-6.0 * z) + 4.0) * y))
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 * ((z * 6.0) + -3.0)) + (((-6.0 * z) + 4.0) * y);
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[(x * N[(N[(z * 6.0), $MachinePrecision] + -3.0), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(-6.0 * z), $MachinePrecision] + 4.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
x \cdot \left(z \cdot 6 + -3\right) + \left(-6 \cdot z + 4\right) \cdot y

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
    (fma.f64 (-.f64 y x) (fma.f64 z -6 4) x): 0 points increase in error, 0 points decrease in error
    (fma.f64 (-.f64 y x) (fma.f64 z (Rewrite<= metadata-eval (*.f64 6 -1)) 4) x): 0 points increase in error, 0 points decrease in error
    (fma.f64 (-.f64 y x) (fma.f64 z (*.f64 6 -1) (Rewrite<= metadata-eval (*.f64 2/3 6))) x): 0 points increase in error, 0 points decrease in error
    (fma.f64 (-.f64 y x) (fma.f64 z (*.f64 6 -1) (*.f64 (Rewrite<= metadata-eval (/.f64 2 3)) 6)) x): 0 points increase in error, 0 points decrease in error
    (fma.f64 (-.f64 y x) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 z (*.f64 6 -1)) (*.f64 (/.f64 2 3) 6))) x): 4 points increase in error, 7 points decrease in error
    (fma.f64 (-.f64 y x) (+.f64 (*.f64 z (Rewrite=> metadata-eval -6)) (*.f64 (/.f64 2 3) 6)) x): 0 points increase in error, 0 points decrease in error
    (fma.f64 (-.f64 y x) (+.f64 (*.f64 z (Rewrite<= metadata-eval (neg.f64 6))) (*.f64 (/.f64 2 3) 6)) x): 0 points increase in error, 0 points decrease in error
    (fma.f64 (-.f64 y x) (+.f64 (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 z 6))) (*.f64 (/.f64 2 3) 6)) x): 0 points increase in error, 0 points decrease in error
    (fma.f64 (-.f64 y x) (+.f64 (Rewrite<= distribute-lft-neg-out_binary64 (*.f64 (neg.f64 z) 6)) (*.f64 (/.f64 2 3) 6)) x): 0 points increase in error, 0 points decrease in error
    (fma.f64 (-.f64 y x) (Rewrite<= distribute-rgt-in_binary64 (*.f64 6 (+.f64 (neg.f64 z) (/.f64 2 3)))) x): 4 points increase in error, 1 points decrease in error
    (fma.f64 (-.f64 y x) (*.f64 6 (Rewrite<= +-commutative_binary64 (+.f64 (/.f64 2 3) (neg.f64 z)))) x): 0 points increase in error, 0 points decrease in error
    (fma.f64 (-.f64 y x) (*.f64 6 (Rewrite<= sub-neg_binary64 (-.f64 (/.f64 2 3) z))) x): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (-.f64 y x) (*.f64 6 (-.f64 (/.f64 2 3) z))) x)): 2 points increase in error, 1 points decrease in error
    (+.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 (-.f64 y x) 6) (-.f64 (/.f64 2 3) z))) x): 67 points increase in error, 19 points decrease in error
    (Rewrite<= +-commutative_binary64 (+.f64 x (*.f64 (*.f64 (-.f64 y x) 6) (-.f64 (/.f64 2 3) z)))): 0 points increase in error, 0 points decrease in error
  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 x \cdot \left(z \cdot 6 + -3\right) + \left(-6 \cdot z + 4\right) \cdot y \]

Alternatives

Alternative 1
Error32.4
Cost1508
\[\begin{array}{l} t_0 := x + 4 \cdot y\\ t_1 := \left(-6 \cdot z\right) \cdot y\\ \mathbf{if}\;z \leq -3.2 \cdot 10^{+212}:\\ \;\;\;\;6 \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;z \leq -2.953699789376325:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.551349439988947 \cdot 10^{-86}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.069627291311846 \cdot 10^{-300}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.9987772706692167 \cdot 10^{-286}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 9.726196262510038 \cdot 10^{-217}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 5.032686791275574 \cdot 10^{-178}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.05710417915525057:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 9 \cdot 10^{+95}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot 6\right)\\ \end{array} \]
Alternative 2
Error32.4
Cost1508
\[\begin{array}{l} t_0 := x + 4 \cdot y\\ t_1 := \left(-6 \cdot z\right) \cdot y\\ \mathbf{if}\;z \leq -3.2 \cdot 10^{+212}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \mathbf{elif}\;z \leq -2.953699789376325:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.551349439988947 \cdot 10^{-86}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.069627291311846 \cdot 10^{-300}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.9987772706692167 \cdot 10^{-286}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 9.726196262510038 \cdot 10^{-217}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 5.032686791275574 \cdot 10^{-178}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.05710417915525057:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 9 \cdot 10^{+95}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot 6\right)\\ \end{array} \]
Alternative 3
Error12.5
Cost976
\[\begin{array}{l} t_0 := \left(-6 \cdot z + 4\right) \cdot y\\ \mathbf{if}\;z \leq -3.2 \cdot 10^{+212}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \mathbf{elif}\;z \leq -1.0485666352098684 \cdot 10^{-14}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3.0481372367119667 \cdot 10^{-19}:\\ \;\;\;\;4 \cdot y + x \cdot -3\\ \mathbf{elif}\;z \leq 9 \cdot 10^{+95}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot 6\right)\\ \end{array} \]
Alternative 4
Error32.6
Cost848
\[\begin{array}{l} t_0 := z \cdot \left(x \cdot 6\right)\\ t_1 := \left(-6 \cdot z\right) \cdot y\\ \mathbf{if}\;z \leq -3.2 \cdot 10^{+212}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2.273670104669541 \cdot 10^{-22}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 0.05710417915525057:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 9 \cdot 10^{+95}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error32.6
Cost848
\[\begin{array}{l} t_0 := \left(-6 \cdot z\right) \cdot y\\ \mathbf{if}\;z \leq -3.2 \cdot 10^{+212}:\\ \;\;\;\;6 \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;z \leq -2.273670104669541 \cdot 10^{-22}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.05710417915525057:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 9 \cdot 10^{+95}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot 6\right)\\ \end{array} \]
Alternative 6
Error12.7
Cost848
\[\begin{array}{l} t_0 := \left(-6 \cdot z\right) \cdot y\\ \mathbf{if}\;z \leq -3.2 \cdot 10^{+212}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \mathbf{elif}\;z \leq -2.953699789376325:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.05710417915525057:\\ \;\;\;\;4 \cdot y + x \cdot -3\\ \mathbf{elif}\;z \leq 9 \cdot 10^{+95}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot 6\right)\\ \end{array} \]
Alternative 7
Error1.7
Cost840
\[\begin{array}{l} t_0 := x + \left(-6 \cdot z\right) \cdot \left(y - x\right)\\ \mathbf{if}\;z \leq -2.953699789376325:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.05710417915525057:\\ \;\;\;\;4 \cdot y + x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error1.7
Cost712
\[\begin{array}{l} t_0 := 6 \cdot \left(z \cdot \left(x - y\right)\right)\\ \mathbf{if}\;z \leq -2.953699789376325:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.05710417915525057:\\ \;\;\;\;4 \cdot y + x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 9
Error0.2
Cost704
\[x - \left(y - x\right) \cdot \left(-6 \cdot \left(0.6666666666666666 - z\right)\right) \]
Alternative 10
Error32.8
Cost584
\[\begin{array}{l} t_0 := \left(-6 \cdot z\right) \cdot y\\ \mathbf{if}\;z \leq -2.273670104669541 \cdot 10^{-22}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.05710417915525057:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 11
Error43.2
Cost192
\[x \cdot -3 \]
Alternative 12
Error62.4
Cost64
\[x \]

Error

Reproduce

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