?

Average Error: 0.04% → 0.04%
Time: 13.6s
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.04%
Target0.04%
Herbie0.04%
\[x + \left(t \cdot \left(y - z\right) + \left(-x\right) \cdot \left(y - z\right)\right) \]

Derivation?

  1. Initial program 0.04

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

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

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

    [Start]0.04

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

    +-commutative [=>]0.04

    \[ \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.04

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

    unsub-neg [=>]0.04

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

    *-commutative [=>]0.04

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

    +-commutative [=>]0.04

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

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

Alternatives

Alternative 1
Error55.43%
Cost1772
\[\begin{array}{l} t_1 := t \cdot \left(y - z\right)\\ \mathbf{if}\;z \leq -1 \cdot 10^{+167}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.35 \cdot 10^{+61}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq -3.1 \cdot 10^{-14}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -5.8 \cdot 10^{-72}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{-100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.85 \cdot 10^{-243}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{-278}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.9 \cdot 10^{-247}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{-110}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{-65}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 6.8 \cdot 10^{+180}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 2
Error61.55%
Cost1576
\[\begin{array}{l} t_1 := t \cdot \left(-z\right)\\ \mathbf{if}\;z \leq -1.1 \cdot 10^{+170}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -5.5 \cdot 10^{+61}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq -5.2 \cdot 10^{-12}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4 \cdot 10^{-244}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 5.4 \cdot 10^{-279}:\\ \;\;\;\;t \cdot y\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{-246}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3 \cdot 10^{-108}:\\ \;\;\;\;t \cdot y\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{-65}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 2 \cdot 10^{-42}:\\ \;\;\;\;t \cdot y\\ \mathbf{elif}\;z \leq 7 \cdot 10^{+106}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 3
Error64.42%
Cost1248
\[\begin{array}{l} \mathbf{if}\;z \leq -2.25 \cdot 10^{+61}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq -0.07:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq -4.8 \cdot 10^{-246}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 10^{-278}:\\ \;\;\;\;t \cdot y\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{-247}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-112}:\\ \;\;\;\;t \cdot y\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{-65}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{+65}:\\ \;\;\;\;t \cdot y\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 4
Error36.33%
Cost1244
\[\begin{array}{l} t_1 := y \cdot \left(t - x\right)\\ t_2 := z \cdot \left(x - t\right)\\ t_3 := x \cdot \left(1 - y\right)\\ \mathbf{if}\;z \leq -30000000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -2.5 \cdot 10^{-245}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 10^{-278}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{-247}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{-107}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{-65}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 3 \cdot 10^{+22}:\\ \;\;\;\;t \cdot \left(y - z\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error63.56%
Cost1116
\[\begin{array}{l} \mathbf{if}\;z \leq -33000000:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq -9 \cdot 10^{-246}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{-278}:\\ \;\;\;\;t \cdot y\\ \mathbf{elif}\;z \leq 1.08 \cdot 10^{-246}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 8 \cdot 10^{-112}:\\ \;\;\;\;t \cdot y\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{-65}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{+65}:\\ \;\;\;\;t \cdot y\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 6
Error39.43%
Cost1112
\[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ t_2 := t \cdot \left(y - z\right)\\ t_3 := x \cdot \left(1 - y\right)\\ \mathbf{if}\;t \leq -1.5 \cdot 10^{-38}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -9.5 \cdot 10^{-48}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -3.5 \cdot 10^{-92}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -1.55 \cdot 10^{-272}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -5.5 \cdot 10^{-283}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 7.8 \cdot 10^{-80}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error38.95%
Cost1112
\[\begin{array}{l} t_1 := t \cdot \left(y - z\right)\\ t_2 := x \cdot \left(1 - y\right)\\ \mathbf{if}\;t \leq -3.9 \cdot 10^{-38}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -8.2 \cdot 10^{-47}:\\ \;\;\;\;z \cdot \left(x - t\right)\\ \mathbf{elif}\;t \leq -6.8 \cdot 10^{-92}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.45 \cdot 10^{-269}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 2 \cdot 10^{-265}:\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \mathbf{elif}\;t \leq 4 \cdot 10^{-81}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error29.61%
Cost980
\[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ \mathbf{if}\;z \leq -2.1 \cdot 10^{+15}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -0.0095:\\ \;\;\;\;y \cdot \left(t - x\right)\\ \mathbf{elif}\;z \leq -3 \cdot 10^{-21}:\\ \;\;\;\;x - t \cdot z\\ \mathbf{elif}\;z \leq -5 \cdot 10^{-148}:\\ \;\;\;\;x \cdot \left(1 - y\right)\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-34}:\\ \;\;\;\;x + t \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error39.38%
Cost848
\[\begin{array}{l} t_1 := t \cdot \left(y - z\right)\\ t_2 := x \cdot \left(1 - y\right)\\ \mathbf{if}\;t \leq -3.5 \cdot 10^{-91}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.55 \cdot 10^{-272}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -6.5 \cdot 10^{-283}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;t \leq 5.4 \cdot 10^{-81}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error29.6%
Cost716
\[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ \mathbf{if}\;z \leq -54000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.85 \cdot 10^{-148}:\\ \;\;\;\;x \cdot \left(1 - y\right)\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{-34}:\\ \;\;\;\;x + t \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error17.01%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -2.6 \cdot 10^{+15} \lor \neg \left(z \leq 1.32 \cdot 10^{-15}\right):\\ \;\;\;\;z \cdot \left(x - t\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(t - x\right)\\ \end{array} \]
Alternative 12
Error17.11%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -2 \cdot 10^{+17} \lor \neg \left(z \leq 1.32 \cdot 10^{-15}\right):\\ \;\;\;\;z \cdot x - t \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(t - x\right)\\ \end{array} \]
Alternative 13
Error16.61%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -8.5 \cdot 10^{+16}:\\ \;\;\;\;z \cdot \left(x - t\right)\\ \mathbf{elif}\;z \leq 1.16 \cdot 10^{-15}:\\ \;\;\;\;x + y \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot \left(t - x\right)\\ \end{array} \]
Alternative 14
Error0.04%
Cost576
\[x + \left(y - z\right) \cdot \left(t - x\right) \]
Alternative 15
Error60.03%
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{-44}:\\ \;\;\;\;t \cdot y\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-8}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t \cdot y\\ \end{array} \]
Alternative 16
Error74.13%
Cost64
\[x \]

Error

Reproduce?

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