?

Average Error: 0.0 → 0.0
Time: 3.4s
Precision: binary64
Cost: 576

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 0.0

    \[x + y \cdot \left(z + x\right) \]
  2. Taylor expanded in x around -inf 0.0

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

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

    [Start]0.0

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

    mul-1-neg [=>]0.0

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

    unsub-neg [=>]0.0

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

    *-commutative [=>]0.0

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

    mul-1-neg [=>]0.0

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

    sub-neg [=>]0.0

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

    metadata-eval [=>]0.0

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

    +-commutative [=>]0.0

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

    neg-sub0 [=>]0.0

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

    associate-+r- [=>]0.0

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

    metadata-eval [=>]0.0

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

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

Alternatives

Alternative 1
Error23.8
Cost720
\[\begin{array}{l} \mathbf{if}\;y \leq -1.1 \cdot 10^{+75}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -1.1 \cdot 10^{+41}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq -3.9 \cdot 10^{-84}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 2
Error1.4
Cost716
\[\begin{array}{l} t_0 := y \cdot \left(z + x\right)\\ \mathbf{if}\;y \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-20}:\\ \;\;\;\;y \cdot z + x\\ \mathbf{elif}\;y \leq 860000000:\\ \;\;\;\;x \cdot \left(y + 1\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error12.9
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -3.9 \cdot 10^{-84} \lor \neg \left(y \leq 0.0064\right):\\ \;\;\;\;y \cdot \left(z + x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error12.8
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -3.35 \cdot 10^{-84} \lor \neg \left(y \leq 860000000\right):\\ \;\;\;\;y \cdot \left(z + x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y + 1\right)\\ \end{array} \]
Alternative 5
Error24.6
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 6
Error0.0
Cost448
\[x + y \cdot \left(z + x\right) \]
Alternative 7
Error34.8
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023031 
(FPCore (x y z)
  :name "Main:bigenough2 from A"
  :precision binary64
  (+ x (* y (+ z x))))