Average Error: 0.3 → 0.2
Time: 8.7s
Precision: binary64
Cost: 576
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
\[x + \left(y - x\right) \cdot \left(6 \cdot z\right) \]
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) z)))
(FPCore (x y z) :precision binary64 (+ x (* (- y x) (* 6.0 z))))
double code(double x, double y, double z) {
	return x + (((y - x) * 6.0) * z);
}
double code(double x, double y, double z) {
	return x + ((y - x) * (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) * 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) * (6.0d0 * z))
end function
public static double code(double x, double y, double z) {
	return x + (((y - x) * 6.0) * z);
}
public static double code(double x, double y, double z) {
	return x + ((y - x) * (6.0 * z));
}
def code(x, y, z):
	return x + (((y - x) * 6.0) * z)
def code(x, y, z):
	return x + ((y - x) * (6.0 * z))
function code(x, y, z)
	return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * z))
end
function code(x, y, z)
	return Float64(x + Float64(Float64(y - x) * Float64(6.0 * z)))
end
function tmp = code(x, y, z)
	tmp = x + (((y - x) * 6.0) * z);
end
function tmp = code(x, y, z)
	tmp = x + ((y - x) * (6.0 * z));
end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(x + N[(N[(y - x), $MachinePrecision] * N[(6.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
x + \left(y - x\right) \cdot \left(6 \cdot z\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.3
Target0.2
Herbie0.2
\[x - \left(6 \cdot z\right) \cdot \left(x - y\right) \]

Derivation

  1. Initial program 0.3

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot 6, z, x\right)} \]
    Proof
    (fma.f64 (*.f64 (-.f64 y x) 6) z x): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (*.f64 (-.f64 y x) 6) z) x)): 5 points increase in error, 1 points decrease in error
    (Rewrite<= +-commutative_binary64 (+.f64 x (*.f64 (*.f64 (-.f64 y x) 6) z))): 0 points increase in error, 0 points decrease in error
  3. Applied egg-rr0.2

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

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

Alternatives

Alternative 1
Error25.3
Cost1244
\[\begin{array}{l} t_0 := x \cdot \left(z \cdot -6\right)\\ t_1 := y \cdot \left(6 \cdot z\right)\\ \mathbf{if}\;z \leq -4 \cdot 10^{+108}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.3911802600254683 \cdot 10^{-114}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.0208099600057898 \cdot 10^{-70}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 717315.7439188524:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.7 \cdot 10^{+79}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{+145}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{+245}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error25.3
Cost1244
\[\begin{array}{l} t_0 := x \cdot \left(z \cdot -6\right)\\ t_1 := y \cdot \left(6 \cdot z\right)\\ \mathbf{if}\;z \leq -4 \cdot 10^{+108}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.3911802600254683 \cdot 10^{-114}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.0208099600057898 \cdot 10^{-70}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 717315.7439188524:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.7 \cdot 10^{+79}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 6 \cdot 10^{+152}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{+245}:\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error14.0
Cost712
\[\begin{array}{l} t_0 := z \cdot \frac{y - x}{0.16666666666666666}\\ \mathbf{if}\;z \leq -1.3911802600254683 \cdot 10^{-114}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.0208099600057898 \cdot 10^{-70}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error13.9
Cost712
\[\begin{array}{l} t_0 := \left(y - x\right) \cdot \left(6 \cdot z\right)\\ \mathbf{if}\;z \leq -1.3911802600254683 \cdot 10^{-114}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.0208099600057898 \cdot 10^{-70}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error13.1
Cost712
\[\begin{array}{l} t_0 := x \cdot \left(1 + z \cdot -6\right)\\ \mathbf{if}\;x \leq -5.872105785230448 \cdot 10^{-74}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.1562139141002143 \cdot 10^{+20}:\\ \;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error1.2
Cost712
\[\begin{array}{l} t_0 := \left(y - x\right) \cdot \left(6 \cdot z\right)\\ \mathbf{if}\;z \leq -22009204.077657487:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.011881861933520465:\\ \;\;\;\;x + z \cdot \left(y \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error1.3
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -4339070671785.9253:\\ \;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\ \mathbf{elif}\;z \leq 717315.7439188524:\\ \;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{y - x}{0.16666666666666666}\\ \end{array} \]
Alternative 8
Error24.5
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -5.872105785230448 \cdot 10^{-74}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.0105680278433627 \cdot 10^{-88}:\\ \;\;\;\;y \cdot \left(6 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error35.2
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022300 
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, E"
  :precision binary64

  :herbie-target
  (- x (* (* 6.0 z) (- x y)))

  (+ x (* (* (- y x) 6.0) z)))