?

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

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 0.0

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

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

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

    [Start]0.0

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

    rational.json-simplify-1 [=>]0.0

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

    rational.json-simplify-2 [=>]0.0

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

    rational.json-simplify-51 [<=]0.0

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

    rational.json-simplify-2 [<=]0.0

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

    rational.json-simplify-2 [<=]0.0

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

    rational.json-simplify-5 [<=]0.0

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

    metadata-eval [<=]0.0

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

    rational.json-simplify-45 [<=]0.0

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

    rational.json-simplify-12 [<=]0.0

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

    rational.json-simplify-9 [<=]0.0

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

    rational.json-simplify-2 [=>]0.0

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

    rational.json-simplify-2 [=>]0.0

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

    rational.json-simplify-51 [=>]0.0

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

    rational.json-simplify-2 [<=]0.0

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

    rational.json-simplify-2 [<=]0.0

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

    rational.json-simplify-43 [<=]0.0

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

    rational.json-simplify-51 [<=]0.0

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

    rational.json-simplify-2 [<=]0.0

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

    rational.json-simplify-2 [<=]0.0

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

    rational.json-simplify-12 [<=]0.0

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

    rational.json-simplify-9 [<=]0.0

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

    rational.json-simplify-2 [<=]0.0

    \[ -1 \cdot z + \color{blue}{-1 \cdot \left(\left(-1 \cdot z + -1 \cdot y\right) \cdot x\right)} \]
  4. Taylor expanded in z around 0 0.0

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

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

    [Start]0.0

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

    rational.json-simplify-2 [=>]0.0

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

    rational.json-simplify-16 [=>]0.0

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

    rational.json-simplify-1 [=>]0.0

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

    rational.json-simplify-51 [<=]0.0

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

    rational.json-simplify-2 [=>]0.0

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

    rational.json-simplify-8 [<=]0.0

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

    rational.json-simplify-12 [=>]0.0

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

    rational.json-simplify-48 [<=]0.0

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

    rational.json-simplify-1 [<=]0.0

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

    rational.json-simplify-4 [=>]0.0

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

    rational.json-simplify-48 [<=]0.0

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

    rational.json-simplify-1 [=>]0.0

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

    rational.json-simplify-2 [=>]0.0

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

    rational.json-simplify-51 [=>]0.0

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

    rational.json-simplify-1 [=>]0.0

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

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

Alternatives

Alternative 1
Error23.6
Cost852
\[\begin{array}{l} \mathbf{if}\;x \leq -3.5 \cdot 10^{+178}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq -1:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-25}:\\ \;\;\;\;-z\\ \mathbf{elif}\;x \leq 350000000:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 2.25 \cdot 10^{+42}:\\ \;\;\;\;z \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 2
Error14.2
Cost848
\[\begin{array}{l} t_0 := \left(y + z\right) \cdot x\\ \mathbf{if}\;x \leq -1.1 \cdot 10^{-12}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -5.6 \cdot 10^{-27}:\\ \;\;\;\;-z\\ \mathbf{elif}\;x \leq -1.7 \cdot 10^{-165}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{-21}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error14.2
Cost848
\[\begin{array}{l} t_0 := \left(y + z\right) \cdot x\\ t_1 := \left(x - 1\right) \cdot z\\ \mathbf{if}\;x \leq -1.15 \cdot 10^{-12}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -5.5 \cdot 10^{-30}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.7 \cdot 10^{-165}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-10}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error25.8
Cost720
\[\begin{array}{l} \mathbf{if}\;x \leq -1.2 \cdot 10^{-12}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq -1.05 \cdot 10^{-28}:\\ \;\;\;\;-z\\ \mathbf{elif}\;x \leq -1.7 \cdot 10^{-165}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-23}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 5
Error0.8
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\left(y + z\right) \cdot x\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-9}:\\ \;\;\;\;y \cdot x - z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y + z \cdot x\\ \end{array} \]
Alternative 6
Error0.8
Cost584
\[\begin{array}{l} t_0 := \left(y + z\right) \cdot x\\ \mathbf{if}\;x \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-9}:\\ \;\;\;\;y \cdot x - z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error35.1
Cost128
\[-z \]

Error

Reproduce?

herbie shell --seed 2023074 
(FPCore (x y z)
  :name "Graphics.Rendering.Chart.Drawing:drawTextsR from Chart-1.5.3"
  :precision binary64
  (+ (* x y) (* (- x 1.0) z)))