?

Average Error: 0.0 → 0.0
Time: 3.2s
Precision: binary64
Cost: 448

?

\[\left(\frac{x}{2} + y \cdot x\right) + z \]
\[z - x \cdot \left(-0.5 - y\right) \]
(FPCore (x y z) :precision binary64 (+ (+ (/ x 2.0) (* y x)) z))
(FPCore (x y z) :precision binary64 (- z (* x (- -0.5 y))))
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 * (-0.5 - 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 / 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 * ((-0.5d0) - y))
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 * (-0.5 - y));
}
def code(x, y, z):
	return ((x / 2.0) + (y * x)) + z
def code(x, y, z):
	return z - (x * (-0.5 - y))
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(-0.5 - y)))
end
function tmp = code(x, y, z)
	tmp = ((x / 2.0) + (y * x)) + z;
end
function tmp = code(x, y, z)
	tmp = z - (x * (-0.5 - y));
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[(-0.5 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\frac{x}{2} + y \cdot x\right) + z
z - x \cdot \left(-0.5 - y\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 0.0

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

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

    [Start]0.0

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

    associate-+l+ [=>]0.0

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

    *-commutative [=>]0.0

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

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

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

    [Start]0.0

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

    +-commutative [=>]0.0

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

    mul-1-neg [=>]0.0

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

    unsub-neg [=>]0.0

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

    sub-neg [=>]0.0

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

    metadata-eval [=>]0.0

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

    +-commutative [=>]0.0

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

    mul-1-neg [=>]0.0

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

    neg-sub0 [=>]0.0

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

    associate-+r- [=>]0.0

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

    metadata-eval [=>]0.0

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

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

Alternatives

Alternative 1
Error27.6
Cost720
\[\begin{array}{l} \mathbf{if}\;z \leq -2.02 \cdot 10^{-25}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 1.08 \cdot 10^{-172}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;z \leq 2.7 \cdot 10^{-135}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 5.9 \cdot 10^{+38}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 2
Error27.3
Cost720
\[\begin{array}{l} \mathbf{if}\;z \leq -1.3 \cdot 10^{-24}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{-263}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;z \leq 9 \cdot 10^{-114}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{+38}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 3
Error10.3
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -7.5 \cdot 10^{-25} \lor \neg \left(z \leq 540000\right):\\ \;\;\;\;z + x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y + 0.5\right)\\ \end{array} \]
Alternative 4
Error0.8
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -0.5 \lor \neg \left(y \leq 0.0072\right):\\ \;\;\;\;z + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;z + x \cdot 0.5\\ \end{array} \]
Alternative 5
Error14.9
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -5.2 \cdot 10^{+57}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 3.9 \cdot 10^{+56}:\\ \;\;\;\;x \cdot \left(y + 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 6
Error34.3
Cost64
\[z \]

Error

Reproduce?

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