Average Error: 0.0 → 0.0
Time: 11.8s
Precision: binary64
Cost: 832
\[x + \left(y - z\right) \cdot \left(t - x\right) \]
\[t \cdot \left(y - z\right) + x \cdot \left(\left(z + 1\right) - y\right) \]
(FPCore (x y z t) :precision binary64 (+ x (* (- y z) (- t x))))
(FPCore (x y z t) :precision binary64 (+ (* t (- y z)) (* x (- (+ z 1.0) y))))
double code(double x, double y, double z, double t) {
	return x + ((y - z) * (t - x));
}
double code(double x, double y, double z, double t) {
	return (t * (y - z)) + (x * ((z + 1.0) - y));
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x + ((y - z) * (t - x))
end function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = (t * (y - z)) + (x * ((z + 1.0d0) - y))
end function
public static double code(double x, double y, double z, double t) {
	return x + ((y - z) * (t - x));
}
public static double code(double x, double y, double z, double t) {
	return (t * (y - z)) + (x * ((z + 1.0) - y));
}
def code(x, y, z, t):
	return x + ((y - z) * (t - x))
def code(x, y, z, t):
	return (t * (y - z)) + (x * ((z + 1.0) - y))
function code(x, y, z, t)
	return Float64(x + Float64(Float64(y - z) * Float64(t - x)))
end
function code(x, y, z, t)
	return Float64(Float64(t * Float64(y - z)) + Float64(x * Float64(Float64(z + 1.0) - y)))
end
function tmp = code(x, y, z, t)
	tmp = x + ((y - z) * (t - x));
end
function tmp = code(x, y, z, t)
	tmp = (t * (y - z)) + (x * ((z + 1.0) - y));
end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := N[(N[(t * N[(y - z), $MachinePrecision]), $MachinePrecision] + N[(x * N[(N[(z + 1.0), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \left(y - z\right) \cdot \left(t - x\right)
t \cdot \left(y - z\right) + x \cdot \left(\left(z + 1\right) - y\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.0
Target0.0
Herbie0.0
\[x + \left(t \cdot \left(y - z\right) + \left(-x\right) \cdot \left(y - z\right)\right) \]

Derivation

  1. Initial program 0.0

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

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

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

    [Start]0.0

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

    +-commutative [=>]0.0

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

    mul-1-neg [=>]0.0

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

    unsub-neg [=>]0.0

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

    *-commutative [=>]0.0

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

    +-commutative [=>]0.0

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

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

Alternatives

Alternative 1
Error30.3
Cost2660
\[\begin{array}{l} t_1 := t \cdot \left(y - z\right)\\ t_2 := y \cdot \left(-x\right)\\ \mathbf{if}\;y - z \leq -1 \cdot 10^{+270}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y - z \leq -4 \cdot 10^{-63}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq 2 \cdot 10^{-34}:\\ \;\;\;\;x\\ \mathbf{elif}\;y - z \leq 5 \cdot 10^{+79}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq 2 \cdot 10^{+98}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;y - z \leq 5 \cdot 10^{+117}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq 5 \cdot 10^{+138}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;y - z \leq 2.5 \cdot 10^{+144}:\\ \;\;\;\;t \cdot y\\ \mathbf{elif}\;y - z \leq 10^{+159}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error26.7
Cost1377
\[\begin{array}{l} t_1 := t \cdot \left(y - z\right)\\ t_2 := x \cdot \left(1 - y\right)\\ t_3 := x \cdot \left(z + 1\right)\\ \mathbf{if}\;t \leq -5.2 \cdot 10^{+49}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -0.000235:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -9.2 \cdot 10^{-86}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.35 \cdot 10^{-280}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 2.05 \cdot 10^{-174}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 7.5 \cdot 10^{-147} \lor \neg \left(t \leq 3.7 \cdot 10^{-119}\right) \land t \leq 2.1 \cdot 10^{-70}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error39.4
Cost1312
\[\begin{array}{l} t_1 := y \cdot \left(-x\right)\\ \mathbf{if}\;y \leq -1.1 \cdot 10^{+70}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -10000000000000:\\ \;\;\;\;t \cdot y\\ \mathbf{elif}\;y \leq -6.5 \cdot 10^{-20}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;y \leq -4 \cdot 10^{-63}:\\ \;\;\;\;t \cdot y\\ \mathbf{elif}\;y \leq -1.3 \cdot 10^{-205}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{-304}:\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{elif}\;y \leq 3.8 \cdot 10^{-32}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{+122}:\\ \;\;\;\;t \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error38.8
Cost1048
\[\begin{array}{l} t_1 := y \cdot \left(-x\right)\\ \mathbf{if}\;y \leq -1.8 \cdot 10^{+74}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -9500000000000:\\ \;\;\;\;t \cdot y\\ \mathbf{elif}\;y \leq -4.6 \cdot 10^{-20}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;y \leq -4.5 \cdot 10^{-63}:\\ \;\;\;\;t \cdot y\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-32}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+123}:\\ \;\;\;\;t \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error39.7
Cost984
\[\begin{array}{l} \mathbf{if}\;z \leq -2.55 \cdot 10^{-5}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq 9.3 \cdot 10^{-240}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{-132}:\\ \;\;\;\;t \cdot y\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-58}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{-15}:\\ \;\;\;\;t \cdot y\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 6
Error23.9
Cost980
\[\begin{array}{l} t_1 := x \cdot \left(z + 1\right)\\ t_2 := t \cdot \left(y - z\right)\\ \mathbf{if}\;x \leq -1.4 \cdot 10^{+127}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -3.6 \cdot 10^{+110}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -8.6 \cdot 10^{-30}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-159}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 4.8:\\ \;\;\;\;y \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error23.1
Cost980
\[\begin{array}{l} t_1 := x \cdot \left(z + 1\right)\\ t_2 := y \cdot \left(t - x\right)\\ t_3 := z \cdot \left(x - t\right)\\ \mathbf{if}\;y \leq -10000000000000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -9.6 \cdot 10^{-23}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq -9.5 \cdot 10^{-190}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{-305}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{-23}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error11.9
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -7.5 \cdot 10^{-34} \lor \neg \left(z \leq 5.8 \cdot 10^{-29}\right):\\ \;\;\;\;z \cdot \left(x - t\right)\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \left(x - t\right)\\ \end{array} \]
Alternative 9
Error11.2
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -9500000000000:\\ \;\;\;\;x - y \cdot \left(x - t\right)\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{-25}:\\ \;\;\;\;x - z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(t - x\right)\\ \end{array} \]
Alternative 10
Error0.0
Cost576
\[x + \left(y - z\right) \cdot \left(t - x\right) \]
Alternative 11
Error38.7
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -3.2 \cdot 10^{-63}:\\ \;\;\;\;t \cdot y\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{-32}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t \cdot y\\ \end{array} \]
Alternative 12
Error47.8
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2023016 
(FPCore (x y z t)
  :name "Data.Metrics.Snapshot:quantile from metrics-0.3.0.2"
  :precision binary64

  :herbie-target
  (+ x (+ (* t (- y z)) (* (- x) (- y z))))

  (+ x (* (- y z) (- t x))))