?

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

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 0.0

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

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

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

    [Start]0.0

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

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

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

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

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

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

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

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

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

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

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

    metadata-eval [<=]0.0

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

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

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

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

Alternatives

Alternative 1
Error23.7
Cost720
\[\begin{array}{l} \mathbf{if}\;z \leq -6.6 \cdot 10^{+135}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;z \leq -1.3 \cdot 10^{+74}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq -8 \cdot 10^{-89}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;z \leq 6.8 \cdot 10^{-60}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot y\\ \end{array} \]
Alternative 2
Error15.2
Cost584
\[\begin{array}{l} t_0 := x \cdot \left(1 - z\right)\\ \mathbf{if}\;x \leq -3.8 \cdot 10^{-112}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.8 \cdot 10^{-89}:\\ \;\;\;\;z \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error12.9
Cost584
\[\begin{array}{l} t_0 := x \cdot \left(1 - z\right)\\ \mathbf{if}\;x \leq -3.2 \cdot 10^{-59}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-62}:\\ \;\;\;\;\left(y - x\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error0.9
Cost584
\[\begin{array}{l} t_0 := \left(y - x\right) \cdot z\\ \mathbf{if}\;z \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.48 \cdot 10^{-5}:\\ \;\;\;\;x + z \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error24.4
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.65 \cdot 10^{-56}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-61}:\\ \;\;\;\;z \cdot y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error0.0
Cost448
\[x + \left(y - x\right) \cdot z \]
Alternative 7
Error34.6
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023075 
(FPCore (x y z)
  :name "Diagrams.ThreeD.Shapes:frustum from diagrams-lib-1.3.0.3, B"
  :precision binary64
  (+ x (* (- y x) z)))