Average Error: 0.4 → 0.2
Time: 11.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): 5 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): 2 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)): 3 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): 68 points increase in error, 17 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
Error33.0
Cost1112
\[\begin{array}{l} t_0 := y \cdot \left(-6 \cdot z\right)\\ \mathbf{if}\;z \leq -2.4774148561027497 \cdot 10^{+21}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.4389908808816314 \cdot 10^{-66}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -1.4764790011037582 \cdot 10^{-216}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -4.267252325917222 \cdot 10^{-230}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -2.4314014463301733 \cdot 10^{-297}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 0.0036699405484121803:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error32.3
Cost1112
\[\begin{array}{l} t_0 := 6 \cdot \left(x \cdot z\right)\\ \mathbf{if}\;z \leq -55867.329838425474:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.4389908808816314 \cdot 10^{-66}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -1.4764790011037582 \cdot 10^{-216}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -4.267252325917222 \cdot 10^{-230}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -2.4314014463301733 \cdot 10^{-297}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 0.0036699405484121803:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error32.3
Cost1112
\[\begin{array}{l} \mathbf{if}\;z \leq -55867.329838425474:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \mathbf{elif}\;z \leq -3.4389908808816314 \cdot 10^{-66}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -1.4764790011037582 \cdot 10^{-216}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -4.267252325917222 \cdot 10^{-230}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -2.4314014463301733 \cdot 10^{-297}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 0.0036699405484121803:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \end{array} \]
Alternative 4
Error1.3
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -55867.329838425474:\\ \;\;\;\;z \cdot \left(\left(y - x\right) \cdot -6\right)\\ \mathbf{elif}\;z \leq 10.180784999286313:\\ \;\;\;\;x \cdot -4 + \left(x + 6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(y \cdot -6 + x \cdot 6\right)\\ \end{array} \]
Alternative 5
Error1.8
Cost968
\[\begin{array}{l} \mathbf{if}\;z \leq -55867.329838425474:\\ \;\;\;\;z \cdot \left(\left(y - x\right) \cdot -6\right)\\ \mathbf{elif}\;z \leq 0.0036699405484121803:\\ \;\;\;\;4 \cdot y + x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(y \cdot -6 + x \cdot 6\right)\\ \end{array} \]
Alternative 6
Error12.9
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -55867.329838425474:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \mathbf{elif}\;z \leq 0.0036699405484121803:\\ \;\;\;\;4 \cdot y + x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \end{array} \]
Alternative 7
Error1.8
Cost712
\[\begin{array}{l} t_0 := z \cdot \left(\left(y - x\right) \cdot -6\right)\\ \mathbf{if}\;z \leq -55867.329838425474:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.0036699405484121803:\\ \;\;\;\;4 \cdot y + x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error0.4
Cost704
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right) \]
Alternative 9
Error33.8
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -1.417898523361797 \cdot 10^{-32}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;y \leq 1.0475370519041326 \cdot 10^{+63}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;4 \cdot y\\ \end{array} \]
Alternative 10
Error43.2
Cost192
\[4 \cdot y \]
Alternative 11
Error62.4
Cost64
\[x \]

Error

Reproduce

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