?

Average Error: 0.0 → 0.0
Time: 28.4s
Precision: binary64
Cost: 832

?

\[x + \left(y - z\right) \cdot \left(t - x\right) \]
\[t \cdot \left(y - z\right) + x \cdot \left(z - \left(y - 1\right)\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 (- y 1.0)))))
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 - (y - 1.0)));
}
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 - (y - 1.0d0)))
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 - (y - 1.0)));
}
def code(x, y, z, t):
	return x + ((y - z) * (t - x))
def code(x, y, z, t):
	return (t * (y - z)) + (x * (z - (y - 1.0)))
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(z - Float64(y - 1.0))))
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 - (y - 1.0)));
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[(z - N[(y - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \left(y - z\right) \cdot \left(t - x\right)
t \cdot \left(y - z\right) + x \cdot \left(z - \left(y - 1\right)\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 0 0.0

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

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

    [Start]0.0

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

    rational.json-simplify-2 [=>]0.0

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

    rational.json-simplify-17 [=>]0.0

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

    rational.json-simplify-2 [=>]0.0

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

    rational.json-simplify-9 [=>]0.0

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

    rational.json-simplify-12 [=>]0.0

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

    rational.json-simplify-42 [=>]0.0

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

    metadata-eval [=>]0.0

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

    rational.json-simplify-45 [=>]0.0

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

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

Alternatives

Alternative 1
Error26.1
Cost1376
\[\begin{array}{l} t_1 := y \cdot \left(t - x\right)\\ t_2 := z \cdot \left(x - t\right)\\ \mathbf{if}\;z \leq -3.3 \cdot 10^{-39}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.2 \cdot 10^{-57}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -9.5 \cdot 10^{-88}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.75 \cdot 10^{-112}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -2.15 \cdot 10^{-223}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -9.6 \cdot 10^{-295}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{-85}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6.4 \cdot 10^{+25}:\\ \;\;\;\;t \cdot \left(y - z\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error30.0
Cost1360
\[\begin{array}{l} t_1 := t \cdot \left(y - z\right)\\ \mathbf{if}\;y - z \leq -4 \cdot 10^{+120}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq -2 \cdot 10^{+78}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;y - z \leq -5 \cdot 10^{-59}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y - z \leq 10^{-28}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error27.7
Cost1112
\[\begin{array}{l} t_1 := y \cdot \left(t - x\right)\\ t_2 := t \cdot \left(y - z\right)\\ \mathbf{if}\;y \leq -5800000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.08 \cdot 10^{-225}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 4.4 \cdot 10^{-222}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{-142}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{-81}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{+28}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error22.8
Cost980
\[\begin{array}{l} t_1 := t \cdot \left(y - z\right)\\ t_2 := z \cdot \left(x - t\right)\\ t_3 := \left(1 - y\right) \cdot x\\ \mathbf{if}\;z \leq -8 \cdot 10^{-34}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{-158}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{-134}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{-79}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{+25}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error17.2
Cost976
\[\begin{array}{l} t_1 := t \cdot \left(y - z\right)\\ t_2 := x \cdot \left(z - \left(y - 1\right)\right)\\ \mathbf{if}\;x \leq -3.3 \cdot 10^{-96}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{-190}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{-170}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-94}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error18.5
Cost912
\[\begin{array}{l} t_1 := y \cdot \left(t - x\right)\\ t_2 := x + z \cdot \left(-t\right)\\ \mathbf{if}\;y \leq -7 \cdot 10^{-7}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-222}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 3.4 \cdot 10^{-201}:\\ \;\;\;\;z \cdot \left(x - t\right)\\ \mathbf{elif}\;y \leq 5 \cdot 10^{-13}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error11.1
Cost844
\[\begin{array}{l} t_1 := y \cdot \left(t - x\right)\\ \mathbf{if}\;y \leq -2.6 \cdot 10^{-5}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{-185}:\\ \;\;\;\;x + z \cdot \left(x - t\right)\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{+29}:\\ \;\;\;\;x + t \cdot \left(y - z\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error10.6
Cost844
\[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ \mathbf{if}\;z \leq -6.7 \cdot 10^{-34}:\\ \;\;\;\;x + t_1\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{-171}:\\ \;\;\;\;y \cdot \left(t - x\right) + x\\ \mathbf{elif}\;z \leq 6.1 \cdot 10^{+25}:\\ \;\;\;\;x + t \cdot \left(y - z\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error38.8
Cost784
\[\begin{array}{l} t_1 := t \cdot \left(-z\right)\\ \mathbf{if}\;z \leq -1.8 \cdot 10^{-41}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{-59}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 2.95 \cdot 10^{+78}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.22 \cdot 10^{+117}:\\ \;\;\;\;z \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error38.6
Cost720
\[\begin{array}{l} \mathbf{if}\;y \leq -4.4 \cdot 10^{-9}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{-215}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-186}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{-13}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot t\\ \end{array} \]
Alternative 11
Error17.9
Cost716
\[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ \mathbf{if}\;z \leq -5.8:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{-59}:\\ \;\;\;\;y \cdot t + x\\ \mathbf{elif}\;z \leq 5.4 \cdot 10^{+25}:\\ \;\;\;\;t \cdot \left(y - z\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error12.0
Cost712
\[\begin{array}{l} t_1 := x + t \cdot \left(y - z\right)\\ \mathbf{if}\;t \leq -5.4 \cdot 10^{-124}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.2 \cdot 10^{-173}:\\ \;\;\;\;x \cdot \left(z - \left(y - 1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error0.0
Cost576
\[x + \left(y - z\right) \cdot \left(t - x\right) \]
Alternative 14
Error38.2
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -4.4 \cdot 10^{-8}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;y \leq 3 \cdot 10^{-13}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot t\\ \end{array} \]
Alternative 15
Error47.7
Cost64
\[x \]

Error

Reproduce?

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