?

Average Error: 0.0 → 0.0
Time: 5.0s
Precision: binary64
Cost: 512

?

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

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(1 - x\right) \cdot z \]
  2. Taylor expanded in x around 0 0.0

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

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

    [Start]0.0

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

    rational_best-simplify-1 [=>]0.0

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

    rational_best-simplify-2 [=>]0.0

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

    rational_best-simplify-12 [=>]0.0

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

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

Alternatives

Alternative 1
Error23.8
Cost1312
\[\begin{array}{l} t_0 := z \cdot \left(-x\right)\\ \mathbf{if}\;x \leq -1.9 \cdot 10^{+239}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -2 \cdot 10^{+115}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq -3.4 \cdot 10^{+40}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -4.2 \cdot 10^{-75}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-18}:\\ \;\;\;\;z\\ \mathbf{elif}\;x \leq 1.55 \cdot 10^{+97}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{+125}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.55 \cdot 10^{+191}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error16.2
Cost584
\[\begin{array}{l} t_0 := z \cdot \left(1 - x\right)\\ \mathbf{if}\;z \leq -4.8 \cdot 10^{-139}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 6.4 \cdot 10^{-31}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error12.3
Cost584
\[\begin{array}{l} t_0 := \left(y - z\right) \cdot x\\ \mathbf{if}\;x \leq -4.6 \cdot 10^{-71}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{-11}:\\ \;\;\;\;z \cdot \left(1 - x\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error0.9
Cost584
\[\begin{array}{l} t_0 := \left(y - z\right) \cdot x\\ \mathbf{if}\;x \leq -110000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-8}:\\ \;\;\;\;z + y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error23.4
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -3.4 \cdot 10^{-72}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-19}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 6
Error35.0
Cost64
\[z \]

Error

Reproduce?

herbie shell --seed 2023092 
(FPCore (x y z)
  :name "Diagrams.Backend.Rasterific:$crender from diagrams-rasterific-1.3.1.3"
  :precision binary64
  (+ (* x y) (* (- 1.0 x) z)))