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

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 0.2

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
  2. Taylor expanded in z around 0 0.2

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

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

    \[\leadsto \color{blue}{\left(-6 \cdot z\right) \cdot \left(x - y\right)} + x \]
    Proof
    (*.f64 (*.f64 -6 z) (-.f64 x y)): 0 points increase in error, 0 points decrease in error
    (Rewrite=> associate-*l*_binary64 (*.f64 -6 (*.f64 z (-.f64 x y)))): 48 points increase in error, 50 points decrease in error
    (*.f64 -6 (Rewrite<= distribute-rgt-out--_binary64 (-.f64 (*.f64 x z) (*.f64 y z)))): 3 points increase in error, 2 points decrease in error
    (*.f64 -6 (-.f64 (Rewrite<= *-commutative_binary64 (*.f64 z x)) (*.f64 y z))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= distribute-lft-out--_binary64 (-.f64 (*.f64 -6 (*.f64 z x)) (*.f64 -6 (*.f64 y z)))): 2 points increase in error, 1 points decrease in error
    (-.f64 (*.f64 -6 (*.f64 z x)) (*.f64 (Rewrite<= metadata-eval (neg.f64 6)) (*.f64 y z))): 0 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 -6 (*.f64 z x)) (Rewrite<= distribute-lft-neg-in_binary64 (neg.f64 (*.f64 6 (*.f64 y z))))): 0 points increase in error, 0 points decrease in error
    (Rewrite=> fma-neg_binary64 (fma.f64 -6 (*.f64 z x) (neg.f64 (neg.f64 (*.f64 6 (*.f64 y z)))))): 5 points increase in error, 6 points decrease in error
    (fma.f64 -6 (*.f64 z x) (Rewrite=> remove-double-neg_binary64 (*.f64 6 (*.f64 y z)))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 -6 (*.f64 z x)) (*.f64 6 (*.f64 y z)))): 6 points increase in error, 5 points decrease in error
  5. Final simplification0.2

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

Alternatives

Alternative 1
Error24.6
Cost980
\[\begin{array}{l} t_0 := z \cdot \left(y \cdot 6\right)\\ \mathbf{if}\;z \leq -1.75 \cdot 10^{+109}:\\ \;\;\;\;\left(-6 \cdot z\right) \cdot x\\ \mathbf{elif}\;z \leq -2.4061406499523838 \cdot 10^{-11}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.4389908808816314 \cdot 10^{-66}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -3.1161930175663275 \cdot 10^{-110}:\\ \;\;\;\;6 \cdot \left(z \cdot y\right)\\ \mathbf{elif}\;z \leq 1.576514821231866 \cdot 10^{-34}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error13.4
Cost976
\[\begin{array}{l} t_0 := \left(-6 \cdot z\right) \cdot \left(x - y\right)\\ \mathbf{if}\;z \leq -2.4061406499523838 \cdot 10^{-11}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.4389908808816314 \cdot 10^{-66}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -2.481447128094156 \cdot 10^{-113}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.576514821231866 \cdot 10^{-34}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error13.3
Cost976
\[\begin{array}{l} t_0 := \left(-6 \cdot z\right) \cdot \left(x - y\right)\\ \mathbf{if}\;z \leq -2.4061406499523838 \cdot 10^{-11}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.4389908808816314 \cdot 10^{-66}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -2.481447128094156 \cdot 10^{-113}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.576514821231866 \cdot 10^{-34}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(z \cdot \left(y - x\right)\right)\\ \end{array} \]
Alternative 4
Error25.1
Cost848
\[\begin{array}{l} t_0 := 6 \cdot \left(z \cdot y\right)\\ \mathbf{if}\;z \leq -2.4061406499523838 \cdot 10^{-11}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.4389908808816314 \cdot 10^{-66}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -3.1161930175663275 \cdot 10^{-110}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.576514821231866 \cdot 10^{-34}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error25.1
Cost848
\[\begin{array}{l} t_0 := z \cdot \left(y \cdot 6\right)\\ \mathbf{if}\;z \leq -2.4061406499523838 \cdot 10^{-11}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.4389908808816314 \cdot 10^{-66}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -3.1161930175663275 \cdot 10^{-110}:\\ \;\;\;\;6 \cdot \left(z \cdot y\right)\\ \mathbf{elif}\;z \leq 1.576514821231866 \cdot 10^{-34}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error1.0
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -55867.329838425474:\\ \;\;\;\;\left(-6 \cdot z\right) \cdot \left(x - y\right)\\ \mathbf{elif}\;z \leq 0.3230483277183604:\\ \;\;\;\;x + z \cdot \left(y \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(z \cdot \left(y - x\right)\right)\\ \end{array} \]
Alternative 7
Error35.0
Cost64
\[x \]

Error

Reproduce

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