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

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.1
Target0.1
Herbie0.1
\[\left(x + 5\right) \cdot z + x \cdot y \]

Derivation

  1. Initial program 0.1

    \[x \cdot \left(y + z\right) + z \cdot 5 \]
  2. Applied egg-rr0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(5, z, x \cdot \left(y + z\right)\right)} \]
  3. Applied egg-rr0.1

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

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

Alternatives

Alternative 1
Error12.3
Cost976
\[\begin{array}{l} t_0 := x \cdot \left(z + y\right)\\ \mathbf{if}\;x \leq -191575247782.34903:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -2.2501747879970518 \cdot 10^{-15}:\\ \;\;\;\;z \cdot \left(5 + x\right)\\ \mathbf{elif}\;x \leq -2.698789789805946 \cdot 10^{-42}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 0.0017772408805579601:\\ \;\;\;\;5 \cdot z + z \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error23.9
Cost852
\[\begin{array}{l} \mathbf{if}\;x \leq -4.3 \cdot 10^{+95}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq -2.698789789805946 \cdot 10^{-42}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 0.0017772408805579601:\\ \;\;\;\;\frac{z}{0.2}\\ \mathbf{elif}\;x \leq 2.25 \cdot 10^{+188}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{+253}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 3
Error23.8
Cost852
\[\begin{array}{l} \mathbf{if}\;x \leq -4.3 \cdot 10^{+95}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq -2.698789789805946 \cdot 10^{-42}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 0.0017772408805579601:\\ \;\;\;\;5 \cdot z\\ \mathbf{elif}\;x \leq 2.25 \cdot 10^{+188}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{+253}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 4
Error12.3
Cost848
\[\begin{array}{l} t_0 := x \cdot \left(z + y\right)\\ t_1 := z \cdot \left(5 + x\right)\\ \mathbf{if}\;x \leq -191575247782.34903:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -2.2501747879970518 \cdot 10^{-15}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.698789789805946 \cdot 10^{-42}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 0.0017772408805579601:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error27.0
Cost720
\[\begin{array}{l} \mathbf{if}\;z \leq -1.650075797226802 \cdot 10^{-180}:\\ \;\;\;\;\frac{z}{0.2}\\ \mathbf{elif}\;z \leq 5.212143241832743 \cdot 10^{-193}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;z \leq 4.769328334761113 \cdot 10^{-159}:\\ \;\;\;\;\frac{z}{0.2}\\ \mathbf{elif}\;z \leq 1.6643014966405058 \cdot 10^{-72}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{0.2}\\ \end{array} \]
Alternative 6
Error16.4
Cost584
\[\begin{array}{l} t_0 := z \cdot \left(5 + x\right)\\ \mathbf{if}\;z \leq -1.650075797226802 \cdot 10^{-180}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5.212143241832743 \cdot 10^{-193}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error40.2
Cost192
\[x \cdot y \]

Error

Reproduce

herbie shell --seed 2022228 
(FPCore (x y z)
  :name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, C"
  :precision binary64

  :herbie-target
  (+ (* (+ x 5.0) z) (* x y))

  (+ (* x (+ y z)) (* z 5.0)))