?

Average Error: 0.0 → 0.0
Time: 7.3s
Precision: binary64
Cost: 640

?

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

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

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

    [Start]0.0

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

    rational_best-simplify-2 [=>]0.0

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

    rational_best-simplify-44 [=>]0.0

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

    rational_best-simplify-19 [=>]0.0

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

    rational_best-simplify-1 [=>]0.0

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

    rational_best-simplify-2 [=>]0.0

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

    rational_best-simplify-12 [=>]0.0

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

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

Alternatives

Alternative 1
Error16.9
Cost848
\[\begin{array}{l} t_0 := x \cdot \left(1 - z\right)\\ \mathbf{if}\;x \leq -2.15 \cdot 10^{-128}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-175}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;x \leq 2.05 \cdot 10^{-156}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-26}:\\ \;\;\;\;z \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error23.7
Cost784
\[\begin{array}{l} t_0 := z \cdot \left(-x\right)\\ \mathbf{if}\;z \leq -1.2 \cdot 10^{+39}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.6 \cdot 10^{-14}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-10}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 5.2 \cdot 10^{+27}:\\ \;\;\;\;z \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error13.7
Cost584
\[\begin{array}{l} t_0 := x \cdot \left(1 - z\right)\\ \mathbf{if}\;x \leq -1.7 \cdot 10^{-126}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-24}:\\ \;\;\;\;\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 -72000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;x + z \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error25.4
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -3.9 \cdot 10^{-128}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-21}:\\ \;\;\;\;z \cdot y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error0.0
Cost448
\[x + \left(y - x\right) \cdot z \]
Alternative 7
Error35.2
Cost64
\[x \]

Error

Reproduce?

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