?

Average Error: 0.0 → 0.0
Time: 12.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
Error29.9
Cost3702
\[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ t_2 := y \cdot \left(t - x\right)\\ t_3 := t \cdot \left(y - z\right)\\ \mathbf{if}\;y - z \leq -2.4 \cdot 10^{+204}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y - z \leq -2 \cdot 10^{+127}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq -2 \cdot 10^{+78}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y - z \leq -2 \cdot 10^{+57}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq -1 \cdot 10^{+53}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y - z \leq -2 \cdot 10^{-22}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y - z \leq 5 \cdot 10^{-159}:\\ \;\;\;\;x\\ \mathbf{elif}\;y - z \leq 2 \cdot 10^{-22}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y - z \leq 0.001:\\ \;\;\;\;x \cdot \left(1 - y\right)\\ \mathbf{elif}\;y - z \leq 10^{+65} \lor \neg \left(y - z \leq 2 \cdot 10^{+85} \lor \neg \left(y - z \leq 5 \cdot 10^{+180}\right) \land y - z \leq 5 \cdot 10^{+255}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error25.3
Cost3442
\[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ t_2 := y \cdot \left(t - x\right)\\ t_3 := x - t \cdot z\\ \mathbf{if}\;y - z \leq -2.4 \cdot 10^{+204}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y - z \leq -2 \cdot 10^{+127}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq -2 \cdot 10^{+78}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y - z \leq -2 \cdot 10^{+57}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq -1 \cdot 10^{+53}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y - z \leq -5 \cdot 10^{-21}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y - z \leq -5 \cdot 10^{-66}:\\ \;\;\;\;x + t \cdot y\\ \mathbf{elif}\;y - z \leq 0.001:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y - z \leq 10^{+65} \lor \neg \left(y - z \leq 2 \cdot 10^{+85} \lor \neg \left(y - z \leq 5 \cdot 10^{+180}\right) \land y - z \leq 5 \cdot 10^{+255}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error31.8
Cost2401
\[\begin{array}{l} t_1 := y \cdot \left(-x\right)\\ t_2 := t \cdot \left(y - z\right)\\ \mathbf{if}\;y - z \leq -5 \cdot 10^{+164}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y - z \leq -5 \cdot 10^{+143}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;y - z \leq -2 \cdot 10^{+91}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y - z \leq -2 \cdot 10^{+78}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq -2 \cdot 10^{-22}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y - z \leq 5 \cdot 10^{-159}:\\ \;\;\;\;x\\ \mathbf{elif}\;y - z \leq 2 \cdot 10^{+85} \lor \neg \left(y - z \leq 2 \cdot 10^{+143}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error39.7
Cost1445
\[\begin{array}{l} t_1 := t \cdot \left(-z\right)\\ t_2 := y \cdot \left(-x\right)\\ \mathbf{if}\;y \leq -0.34:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -5.5 \cdot 10^{-168}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -3.6 \cdot 10^{-253}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5.3 \cdot 10^{-307}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{-224}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 9 \cdot 10^{-49}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{+26} \lor \neg \left(y \leq 2.5 \cdot 10^{+169}\right) \land y \leq 3.8 \cdot 10^{+256}:\\ \;\;\;\;t \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error28.7
Cost1376
\[\begin{array}{l} t_1 := t \cdot \left(y - z\right)\\ t_2 := y \cdot \left(-x\right)\\ t_3 := x \cdot \left(z + 1\right)\\ \mathbf{if}\;t \leq -6.5 \cdot 10^{-14}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -4.5 \cdot 10^{-92}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -1.22 \cdot 10^{-110}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.2 \cdot 10^{-191}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -2.4 \cdot 10^{-280}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 9.2 \cdot 10^{-278}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 3.6 \cdot 10^{-220}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 4.3 \cdot 10^{-54}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error19.0
Cost1113
\[\begin{array}{l} t_1 := t \cdot \left(y - z\right)\\ t_2 := x \cdot \left(\left(z + 1\right) - y\right)\\ \mathbf{if}\;t \leq -2.7 \cdot 10^{-13}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -4.5 \cdot 10^{-92}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -2.35 \cdot 10^{-110}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.35 \cdot 10^{-51}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 3.4 \cdot 10^{+122} \lor \neg \left(t \leq 1.9 \cdot 10^{+211}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x - t \cdot z\\ \end{array} \]
Alternative 7
Error29.4
Cost1112
\[\begin{array}{l} t_1 := t \cdot \left(y - z\right)\\ t_2 := z \cdot \left(x - t\right)\\ \mathbf{if}\;z \leq -7 \cdot 10^{+50}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.9 \cdot 10^{-10}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq -1.56 \cdot 10^{-153}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{-165}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{-144}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-21}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error11.7
Cost978
\[\begin{array}{l} \mathbf{if}\;t \leq -1.02 \cdot 10^{-67} \lor \neg \left(t \leq -1.2 \cdot 10^{-90}\right) \land \left(t \leq -4 \cdot 10^{-144} \lor \neg \left(t \leq 9 \cdot 10^{-61}\right)\right):\\ \;\;\;\;t \cdot \left(y - z\right) + x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\left(z + 1\right) - y\right)\\ \end{array} \]
Alternative 9
Error38.6
Cost917
\[\begin{array}{l} t_1 := y \cdot \left(-x\right)\\ \mathbf{if}\;y \leq -0.34:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 9 \cdot 10^{-49}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4.4 \cdot 10^{+27} \lor \neg \left(y \leq 5.4 \cdot 10^{+169}\right) \land y \leq 8.4 \cdot 10^{+257}:\\ \;\;\;\;t \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error23.9
Cost848
\[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ t_2 := x \cdot \left(1 - y\right)\\ \mathbf{if}\;z \leq -7 \cdot 10^{+50}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.65 \cdot 10^{-40}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -2.2 \cdot 10^{-153}:\\ \;\;\;\;t \cdot \left(y - z\right)\\ \mathbf{elif}\;z \leq 8.6 \cdot 10^{-21}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error19.9
Cost848
\[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ \mathbf{if}\;z \leq -7.2 \cdot 10^{+50}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.9 \cdot 10^{-11}:\\ \;\;\;\;y \cdot \left(t - x\right)\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{-217}:\\ \;\;\;\;x + t \cdot y\\ \mathbf{elif}\;z \leq 8 \cdot 10^{-21}:\\ \;\;\;\;x \cdot \left(1 - y\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error39.5
Cost720
\[\begin{array}{l} \mathbf{if}\;z \leq -8 \cdot 10^{+19}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq -1.75 \cdot 10^{-153}:\\ \;\;\;\;t \cdot y\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{-23}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{+63}:\\ \;\;\;\;t \cdot y\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 13
Error0.0
Cost576
\[x + \left(y - z\right) \cdot \left(t - x\right) \]
Alternative 14
Error38.3
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -7.2 \cdot 10^{-6}:\\ \;\;\;\;t \cdot y\\ \mathbf{elif}\;y \leq 9 \cdot 10^{-49}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t \cdot y\\ \end{array} \]
Alternative 15
Error47.4
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023066 
(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))))