?

Average Accuracy: 100.0% → 100.0%
Time: 3.6s
Precision: binary64
Cost: 576

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 100.0%

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

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

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

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

    [Start]100.0

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

    +-commutative [=>]100.0

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

    mul-1-neg [=>]100.0

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

    unsub-neg [=>]100.0

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

    *-lft-identity [<=]100.0

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

    distribute-rgt-out-- [=>]100.0

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

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

Alternatives

Alternative 1
Accuracy61.0%
Cost1312
\[\begin{array}{l} t_0 := x \cdot \left(-z\right)\\ \mathbf{if}\;z \leq -1.02 \cdot 10^{+142}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -490000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.9 \cdot 10^{-66}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 7 \cdot 10^{-156}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-131}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{-40}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{+17}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 2
Accuracy79.3%
Cost848
\[\begin{array}{l} t_0 := z \cdot \left(y - x\right)\\ \mathbf{if}\;z \leq -8 \cdot 10^{-64}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5.4 \cdot 10^{-156}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{-131}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-45}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Accuracy98.7%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 0.0025\right):\\ \;\;\;\;z \cdot \left(y - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot z\\ \end{array} \]
Alternative 4
Accuracy59.8%
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -4.9 \cdot 10^{+45}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{-39}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Accuracy100.0%
Cost448
\[x + z \cdot \left(y - x\right) \]
Alternative 6
Accuracy45.1%
Cost64
\[x \]

Error

Reproduce?

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