Average Error: 0.3 → 0.2
Time: 6.5s
Precision: binary64
Cost: 704
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
\[x + \frac{6}{\frac{1}{z \cdot \left(y - x\right)}} \]
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) z)))
(FPCore (x y z) :precision binary64 (+ x (/ 6.0 (/ 1.0 (* z (- y x))))))
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 / (1.0 / (z * (y - x))));
}
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 / (1.0d0 / (z * (y - x))))
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 / (1.0 / (z * (y - x))));
}
def code(x, y, z):
	return x + (((y - x) * 6.0) * z)
def code(x, y, z):
	return x + (6.0 / (1.0 / (z * (y - x))))
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(6.0 / Float64(1.0 / Float64(z * Float64(y - x)))))
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 / (1.0 / (z * (y - x))));
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[(6.0 / N[(1.0 / N[(z * N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
x + \frac{6}{\frac{1}{z \cdot \left(y - x\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.2

    \[\leadsto \color{blue}{\mathsf{fma}\left(6, \left(y - x\right) \cdot z, x\right)} \]
  3. Applied egg-rr27.8

    \[\leadsto \mathsf{fma}\left(6, \color{blue}{\frac{z \cdot \left(y \cdot y - x \cdot x\right)}{y + x}}, x\right) \]
  4. Applied egg-rr0.2

    \[\leadsto \color{blue}{x + \frac{6 \cdot z}{\frac{1}{y - x}}} \]
  5. Applied egg-rr0.2

    \[\leadsto x + \color{blue}{6 \cdot \frac{z}{\frac{1}{y - x}}} \]
  6. Applied egg-rr0.2

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

    \[\leadsto x + \frac{6}{\frac{1}{z \cdot \left(y - x\right)}} \]

Alternatives

Alternative 1
Error23.9
Cost1112
\[\begin{array}{l} t_0 := z \cdot \left(6 \cdot y\right)\\ t_1 := z \cdot \left(x \cdot -6\right)\\ \mathbf{if}\;z \leq -1.15 \cdot 10^{+246}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.06 \cdot 10^{+168}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -0.21646441929426122:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.03069251571248673:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 8.53140184753757 \cdot 10^{+26}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 10^{+75}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error23.9
Cost1112
\[\begin{array}{l} t_0 := z \cdot \left(6 \cdot y\right)\\ t_1 := x \cdot \left(z \cdot -6\right)\\ \mathbf{if}\;z \leq -1.15 \cdot 10^{+246}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.06 \cdot 10^{+168}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -0.21646441929426122:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.03069251571248673:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 8.53140184753757 \cdot 10^{+26}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 10^{+75}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error23.9
Cost1112
\[\begin{array}{l} t_0 := z \cdot \left(6 \cdot y\right)\\ t_1 := x \cdot \left(z \cdot -6\right)\\ \mathbf{if}\;z \leq -1.15 \cdot 10^{+246}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.06 \cdot 10^{+168}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -0.21646441929426122:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.03069251571248673:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 8.53140184753757 \cdot 10^{+26}:\\ \;\;\;\;6 \cdot \left(z \cdot y\right)\\ \mathbf{elif}\;z \leq 10^{+75}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error12.3
Cost848
\[\begin{array}{l} t_0 := z \cdot \left(6 \cdot y\right)\\ t_1 := x \cdot \left(z \cdot -6\right)\\ \mathbf{if}\;z \leq -1.15 \cdot 10^{+246}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.06 \cdot 10^{+168}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 8.53140184753757 \cdot 10^{+26}:\\ \;\;\;\;x + 6 \cdot \left(z \cdot y\right)\\ \mathbf{elif}\;z \leq 10^{+75}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error1.1
Cost712
\[\begin{array}{l} t_0 := 6 \cdot \left(z \cdot \left(y - x\right)\right)\\ \mathbf{if}\;z \leq -1.6983593488052935:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.03069251571248673:\\ \;\;\;\;x + 6 \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error1.1
Cost712
\[\begin{array}{l} t_0 := \left(y - x\right) \cdot \left(6 \cdot z\right)\\ \mathbf{if}\;z \leq -1.6983593488052935:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.03069251571248673:\\ \;\;\;\;x + 6 \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error1.1
Cost712
\[\begin{array}{l} t_0 := \left(y - x\right) \cdot \left(6 \cdot z\right)\\ \mathbf{if}\;z \leq -1.6983593488052935:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.03069251571248673:\\ \;\;\;\;x + z \cdot \left(6 \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error24.9
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -7.912141565496784 \cdot 10^{-28}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.414708121703364 \cdot 10^{-82}:\\ \;\;\;\;z \cdot \left(6 \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error0.3
Cost576
\[x + z \cdot \left(6 \cdot \left(y - x\right)\right) \]
Alternative 10
Error35.2
Cost64
\[x \]

Error

Reproduce

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