?

Average Error: 0.01% → 0.02%
Time: 3.4s
Precision: binary64
Cost: 448

?

\[\left(\frac{x}{2} + y \cdot x\right) + z \]
\[z + x \cdot \left(y + 0.5\right) \]
(FPCore (x y z) :precision binary64 (+ (+ (/ x 2.0) (* y x)) z))
(FPCore (x y z) :precision binary64 (+ z (* x (+ y 0.5))))
double code(double x, double y, double z) {
	return ((x / 2.0) + (y * x)) + z;
}
double code(double x, double y, double z) {
	return z + (x * (y + 0.5));
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = ((x / 2.0d0) + (y * x)) + 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 = z + (x * (y + 0.5d0))
end function
public static double code(double x, double y, double z) {
	return ((x / 2.0) + (y * x)) + z;
}
public static double code(double x, double y, double z) {
	return z + (x * (y + 0.5));
}
def code(x, y, z):
	return ((x / 2.0) + (y * x)) + z
def code(x, y, z):
	return z + (x * (y + 0.5))
function code(x, y, z)
	return Float64(Float64(Float64(x / 2.0) + Float64(y * x)) + z)
end
function code(x, y, z)
	return Float64(z + Float64(x * Float64(y + 0.5)))
end
function tmp = code(x, y, z)
	tmp = ((x / 2.0) + (y * x)) + z;
end
function tmp = code(x, y, z)
	tmp = z + (x * (y + 0.5));
end
code[x_, y_, z_] := N[(N[(N[(x / 2.0), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]
code[x_, y_, z_] := N[(z + N[(x * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\frac{x}{2} + y \cdot x\right) + z
z + x \cdot \left(y + 0.5\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 0.01

    \[\left(\frac{x}{2} + y \cdot x\right) + z \]
  2. Simplified0.01

    \[\leadsto \color{blue}{\frac{x}{2} + \left(x \cdot y + z\right)} \]
    Proof

    [Start]0.01

    \[ \left(\frac{x}{2} + y \cdot x\right) + z \]

    associate-+l+ [=>]0.01

    \[ \color{blue}{\frac{x}{2} + \left(y \cdot x + z\right)} \]

    *-commutative [=>]0.01

    \[ \frac{x}{2} + \left(\color{blue}{x \cdot y} + z\right) \]
  3. Taylor expanded in x around -inf 0.02

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

    \[\leadsto \color{blue}{z - x \cdot \left(-0.5 - y\right)} \]
    Proof

    [Start]0.02

    \[ -1 \cdot \left(x \cdot \left(-1 \cdot y - 0.5\right)\right) + z \]

    +-commutative [=>]0.02

    \[ \color{blue}{z + -1 \cdot \left(x \cdot \left(-1 \cdot y - 0.5\right)\right)} \]

    mul-1-neg [=>]0.02

    \[ z + \color{blue}{\left(-x \cdot \left(-1 \cdot y - 0.5\right)\right)} \]

    unsub-neg [=>]0.02

    \[ \color{blue}{z - x \cdot \left(-1 \cdot y - 0.5\right)} \]

    sub-neg [=>]0.02

    \[ z - x \cdot \color{blue}{\left(-1 \cdot y + \left(-0.5\right)\right)} \]

    metadata-eval [=>]0.02

    \[ z - x \cdot \left(-1 \cdot y + \color{blue}{-0.5}\right) \]

    +-commutative [=>]0.02

    \[ z - x \cdot \color{blue}{\left(-0.5 + -1 \cdot y\right)} \]

    mul-1-neg [=>]0.02

    \[ z - x \cdot \left(-0.5 + \color{blue}{\left(-y\right)}\right) \]

    neg-sub0 [=>]0.02

    \[ z - x \cdot \left(-0.5 + \color{blue}{\left(0 - y\right)}\right) \]

    associate-+r- [=>]0.02

    \[ z - x \cdot \color{blue}{\left(\left(-0.5 + 0\right) - y\right)} \]

    metadata-eval [=>]0.02

    \[ z - x \cdot \left(\color{blue}{-0.5} - y\right) \]
  5. Final simplification0.02

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

Alternatives

Alternative 1
Error45.36%
Cost1380
\[\begin{array}{l} \mathbf{if}\;z \leq -5500000000000:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq -6.2 \cdot 10^{-45}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;z \leq -4.1 \cdot 10^{-78}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq -1.05 \cdot 10^{-211}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;z \leq -2.2 \cdot 10^{-264}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;z \leq 1.42 \cdot 10^{-257}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-36}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;z \leq 2.12 \cdot 10^{+43}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{+73}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 2
Error18.86%
Cost850
\[\begin{array}{l} \mathbf{if}\;z \leq -14500000000000 \lor \neg \left(z \leq -8 \cdot 10^{-43} \lor \neg \left(z \leq -2.4 \cdot 10^{-78}\right) \land z \leq 6.4 \cdot 10^{+88}\right):\\ \;\;\;\;z + x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y + 0.5\right)\\ \end{array} \]
Alternative 3
Error42.88%
Cost720
\[\begin{array}{l} \mathbf{if}\;z \leq -13500000000000:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq -2.15 \cdot 10^{-44}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;z \leq -1.65 \cdot 10^{-112}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{-55}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 4
Error1.29%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -0.5 \lor \neg \left(y \leq 1.4 \cdot 10^{-6}\right):\\ \;\;\;\;z + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;z + x \cdot 0.5\\ \end{array} \]
Alternative 5
Error25.51%
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -1.9 \cdot 10^{+103}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{+120}:\\ \;\;\;\;x \cdot \left(y + 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 6
Error53.63%
Cost64
\[z \]

Error

Reproduce?

herbie shell --seed 2023115 
(FPCore (x y z)
  :name "Data.Histogram.Bin.BinF:$cfromIndex from histogram-fill-0.8.4.1"
  :precision binary64
  (+ (+ (/ x 2.0) (* y x)) z))