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

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, 12 points decrease in error
    (fma.f64 (-.f64 y x) (fma.f64 z (*.f64 6 -1) (Rewrite<= metadata-eval (*.f64 6 2/3))) x): 0 points increase in error, 0 points decrease in error
    (fma.f64 (-.f64 y x) (fma.f64 z (*.f64 6 -1) (*.f64 6 (Rewrite<= metadata-eval (/.f64 2 3)))) x): 14 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 6 (/.f64 2 3)))) x): 0 points increase in error, 12 points decrease in error
    (fma.f64 (-.f64 y x) (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 (*.f64 6 -1) z)) (*.f64 6 (/.f64 2 3))) x): 0 points increase in error, 2 points decrease in error
    (fma.f64 (-.f64 y x) (+.f64 (Rewrite<= associate-*r*_binary64 (*.f64 6 (*.f64 -1 z))) (*.f64 6 (/.f64 2 3))) x): 14 points increase in error, 0 points decrease in error
    (fma.f64 (-.f64 y x) (+.f64 (*.f64 6 (Rewrite<= neg-mul-1_binary64 (neg.f64 z))) (*.f64 6 (/.f64 2 3))) x): 0 points increase in error, 14 points decrease in error
    (fma.f64 (-.f64 y x) (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 6 (/.f64 2 3)) (*.f64 6 (neg.f64 z)))) x): 12 points increase in error, 0 points decrease in error
    (fma.f64 (-.f64 y x) (Rewrite<= distribute-lft-in_binary64 (*.f64 6 (+.f64 (/.f64 2 3) (neg.f64 z)))) x): 0 points increase in error, 12 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)): 14 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): 0 points increase in error, 6 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, 8 points decrease in error
  3. Applied egg-rr0.2

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

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

Alternatives

Alternative 1
Error25.0
Cost1373
\[\begin{array}{l} t_0 := 6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ \mathbf{if}\;x \leq -2.1 \cdot 10^{+132}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;x \leq -1.05 \cdot 10^{+61}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.7 \cdot 10^{+20}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;x \leq -2.15 \cdot 10^{-45}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;x \leq 280000000 \lor \neg \left(x \leq 6.1 \cdot 10^{+85}\right) \land x \leq 8.2 \cdot 10^{+129}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x \cdot -3\\ \end{array} \]
Alternative 2
Error21.2
Cost1372
\[\begin{array}{l} t_0 := x \cdot \left(-3 + z \cdot 6\right)\\ t_1 := z \cdot \left(\left(y - x\right) \cdot -6\right)\\ \mathbf{if}\;z \leq -0.032:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{-307}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 3.7 \cdot 10^{-214}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.16 \cdot 10^{-150}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{-111}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-46}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 170000:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error21.0
Cost1372
\[\begin{array}{l} t_0 := z \cdot \left(\left(y - x\right) \cdot -6\right)\\ t_1 := x \cdot \left(-3 + z \cdot 6\right)\\ \mathbf{if}\;z \leq -1600:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -7.4 \cdot 10^{-307}:\\ \;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\ \mathbf{elif}\;z \leq 5.3 \cdot 10^{-214}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{-147}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{-111}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{-45}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 205000:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error33.0
Cost1244
\[\begin{array}{l} t_0 := 6 \cdot \left(x \cdot z\right)\\ \mathbf{if}\;z \leq -1.6:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.25 \cdot 10^{-307}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{-214}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{-149}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 2.05 \cdot 10^{-112}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{-46}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 0.96:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error33.1
Cost1244
\[\begin{array}{l} \mathbf{if}\;z \leq -1.4:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \mathbf{elif}\;z \leq -5.1 \cdot 10^{-307}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 8.6 \cdot 10^{-214}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{-148}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{-111}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3 \cdot 10^{-45}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 0.96:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \end{array} \]
Alternative 6
Error33.1
Cost1244
\[\begin{array}{l} \mathbf{if}\;z \leq -3300:\\ \;\;\;\;y \cdot \left(z \cdot -6\right)\\ \mathbf{elif}\;z \leq -8.5 \cdot 10^{-308}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 3.25 \cdot 10^{-214}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-144}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 2 \cdot 10^{-112}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{-46}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 0.96:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \end{array} \]
Alternative 7
Error16.6
Cost978
\[\begin{array}{l} \mathbf{if}\;x \leq -2.8 \cdot 10^{+80} \lor \neg \left(x \leq -1.16 \cdot 10^{+61} \lor \neg \left(x \leq -2.1 \cdot 10^{-45}\right) \land x \leq 1.55 \cdot 10^{-44}\right):\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ \end{array} \]
Alternative 8
Error34.5
Cost721
\[\begin{array}{l} \mathbf{if}\;x \leq -1.85 \cdot 10^{+129}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;x \leq -7 \cdot 10^{+61} \lor \neg \left(x \leq -1.95 \cdot 10^{-120}\right) \land x \leq 1.72 \cdot 10^{-9}:\\ \;\;\;\;y \cdot 4\\ \mathbf{else}:\\ \;\;\;\;x \cdot -3\\ \end{array} \]
Alternative 9
Error1.9
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -0.6 \lor \neg \left(z \leq 0.66\right):\\ \;\;\;\;z \cdot \left(\left(y - x\right) \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot 4 + x \cdot -3\\ \end{array} \]
Alternative 10
Error0.4
Cost704
\[x + \left(0.6666666666666666 - z\right) \cdot \left(\left(y - x\right) \cdot 6\right) \]
Alternative 11
Error0.3
Cost704
\[x + \left(z + -0.6666666666666666\right) \cdot \frac{y - x}{-0.16666666666666666} \]
Alternative 12
Error0.3
Cost704
\[x + \frac{z + -0.6666666666666666}{\frac{-0.16666666666666666}{y - x}} \]
Alternative 13
Error0.2
Cost704
\[x + \left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right) \]
Alternative 14
Error42.7
Cost192
\[x \cdot -3 \]

Error

Reproduce

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