Average Error: 0.4 → 0.2
Time: 14.6s
Precision: binary64
Cost: 960
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
\[4 \cdot \left(y - x\right) + \left(x + -6 \cdot \left(\left(y - x\right) \cdot z\right)\right) \]
(FPCore (x y z)
 :precision binary64
 (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))
(FPCore (x y z)
 :precision binary64
 (+ (* 4.0 (- y x)) (+ x (* -6.0 (* (- y x) 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 (4.0 * (y - x)) + (x + (-6.0 * ((y - x) * 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 = (4.0d0 * (y - x)) + (x + ((-6.0d0) * ((y - x) * 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 (4.0 * (y - x)) + (x + (-6.0 * ((y - x) * z)));
}
def code(x, y, z):
	return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z))
def code(x, y, z):
	return (4.0 * (y - x)) + (x + (-6.0 * ((y - x) * 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(4.0 * Float64(y - x)) + Float64(x + Float64(-6.0 * Float64(Float64(y - x) * 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 = (4.0 * (y - x)) + (x + (-6.0 * ((y - x) * 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[(4.0 * N[(y - x), $MachinePrecision]), $MachinePrecision] + N[(x + N[(-6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
4 \cdot \left(y - x\right) + \left(x + -6 \cdot \left(\left(y - x\right) \cdot z\right)\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
    (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): 6 points increase in error, 6 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): 3 points increase in error, 3 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, 0 points decrease in error
    (+.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 (-.f64 y x) 6) (-.f64 (/.f64 2 3) z))) x): 60 points increase in error, 20 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 z around 0 0.2

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

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

Alternatives

Alternative 1
Error32.9
Cost2036
\[\begin{array}{l} t_0 := x \cdot \left(z \cdot 6\right)\\ \mathbf{if}\;z \leq -74365371.24979533:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -4.7769109537890575 \cdot 10^{-151}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -2.3053645700531945 \cdot 10^{-179}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -2.834875409293513 \cdot 10^{-220}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -1.6399313263099076 \cdot 10^{-268}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.495254158807163 \cdot 10^{-299}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 2.1772795084345767 \cdot 10^{-274}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.6078130878189284 \cdot 10^{-205}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 3.590934287959582 \cdot 10^{-149}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 7.266665387251684 \cdot 10^{-17}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 7.620482737871498 \cdot 10^{-9}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{+86}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{+161}:\\ \;\;\;\;y \cdot \left(-6 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \end{array} \]
Alternative 2
Error32.8
Cost1772
\[\begin{array}{l} t_0 := 6 \cdot \left(x \cdot z\right)\\ \mathbf{if}\;z \leq -74365371.24979533:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -4.7769109537890575 \cdot 10^{-151}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -2.3053645700531945 \cdot 10^{-179}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -2.834875409293513 \cdot 10^{-220}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -1.6399313263099076 \cdot 10^{-268}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.495254158807163 \cdot 10^{-299}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 2.1772795084345767 \cdot 10^{-274}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.6078130878189284 \cdot 10^{-205}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 3.590934287959582 \cdot 10^{-149}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 7.266665387251684 \cdot 10^{-17}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 7.620482737871498 \cdot 10^{-9}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error32.8
Cost1772
\[\begin{array}{l} \mathbf{if}\;z \leq -74365371.24979533:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \mathbf{elif}\;z \leq -4.7769109537890575 \cdot 10^{-151}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -2.3053645700531945 \cdot 10^{-179}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -2.834875409293513 \cdot 10^{-220}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -1.6399313263099076 \cdot 10^{-268}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.495254158807163 \cdot 10^{-299}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 2.1772795084345767 \cdot 10^{-274}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.6078130878189284 \cdot 10^{-205}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 3.590934287959582 \cdot 10^{-149}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 7.266665387251684 \cdot 10^{-17}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 7.620482737871498 \cdot 10^{-9}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \end{array} \]
Alternative 4
Error13.5
Cost848
\[\begin{array}{l} t_0 := x \cdot \left(z \cdot 6\right)\\ \mathbf{if}\;z \leq -74365371.24979533:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 7.620482737871498 \cdot 10^{-9}:\\ \;\;\;\;4 \cdot y + x \cdot -3\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{+86}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{+161}:\\ \;\;\;\;y \cdot \left(-6 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \end{array} \]
Alternative 5
Error2.1
Cost712
\[\begin{array}{l} t_0 := z \cdot \left(\left(y - x\right) \cdot -6\right)\\ \mathbf{if}\;z \leq -1.5035160011976247:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 7.620482737871498 \cdot 10^{-9}:\\ \;\;\;\;4 \cdot y + x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error2.1
Cost712
\[\begin{array}{l} t_0 := -6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{if}\;z \leq -1.5035160011976247:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 7.620482737871498 \cdot 10^{-9}:\\ \;\;\;\;4 \cdot y + x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error2.1
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1.5035160011976247:\\ \;\;\;\;-6 \cdot \left(y \cdot z - x \cdot z\right)\\ \mathbf{elif}\;z \leq 7.620482737871498 \cdot 10^{-9}:\\ \;\;\;\;4 \cdot y + x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \end{array} \]
Alternative 8
Error0.4
Cost704
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right) \]
Alternative 9
Error0.2
Cost704
\[x + \left(y - x\right) \cdot \left(4 + -6 \cdot z\right) \]
Alternative 10
Error34.4
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -1.388374644839717 \cdot 10^{+79}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;y \leq 1.0112159903330097 \cdot 10^{-97}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;4 \cdot y\\ \end{array} \]
Alternative 11
Error43.3
Cost192
\[x \cdot -3 \]

Error

Reproduce

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