?

Average Error: 0.09% → 0.12%
Time: 10.6s
Precision: binary64
Cost: 832

?

\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ \end{array} \]
\[\frac{\left(x + y\right) - z}{t \cdot 2} \]
\[0.5 \cdot \frac{y}{t} + 0.5 \cdot \frac{x - z}{t} \]
(FPCore (x y z t) :precision binary64 (/ (- (+ x y) z) (* t 2.0)))
(FPCore (x y z t)
 :precision binary64
 (+ (* 0.5 (/ y t)) (* 0.5 (/ (- x z) t))))
double code(double x, double y, double z, double t) {
	return ((x + y) - z) / (t * 2.0);
}
double code(double x, double y, double z, double t) {
	return (0.5 * (y / t)) + (0.5 * ((x - z) / t));
}
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 * 2.0d0)
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 = (0.5d0 * (y / t)) + (0.5d0 * ((x - z) / t))
end function
public static double code(double x, double y, double z, double t) {
	return ((x + y) - z) / (t * 2.0);
}
public static double code(double x, double y, double z, double t) {
	return (0.5 * (y / t)) + (0.5 * ((x - z) / t));
}
def code(x, y, z, t):
	return ((x + y) - z) / (t * 2.0)
def code(x, y, z, t):
	return (0.5 * (y / t)) + (0.5 * ((x - z) / t))
function code(x, y, z, t)
	return Float64(Float64(Float64(x + y) - z) / Float64(t * 2.0))
end
function code(x, y, z, t)
	return Float64(Float64(0.5 * Float64(y / t)) + Float64(0.5 * Float64(Float64(x - z) / t)))
end
function tmp = code(x, y, z, t)
	tmp = ((x + y) - z) / (t * 2.0);
end
function tmp = code(x, y, z, t)
	tmp = (0.5 * (y / t)) + (0.5 * ((x - z) / t));
end
code[x_, y_, z_, t_] := N[(N[(N[(x + y), $MachinePrecision] - z), $MachinePrecision] / N[(t * 2.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := N[(N[(0.5 * N[(y / t), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(N[(x - z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\left(x + y\right) - z}{t \cdot 2}
0.5 \cdot \frac{y}{t} + 0.5 \cdot \frac{x - z}{t}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 0.09

    \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
  2. Simplified0.44

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

    [Start]0.09

    \[ \frac{\left(x + y\right) - z}{t \cdot 2} \]

    /-rgt-identity [<=]0.09

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

    metadata-eval [<=]0.09

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

    associate-/l* [=>]0.09

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

    associate-/l* [<=]0.03

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

    associate-*r/ [<=]0.44

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

    associate--l+ [=>]0.44

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

    metadata-eval [=>]0.44

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

    metadata-eval [=>]0.44

    \[ \left(x + \left(y - z\right)\right) \cdot \frac{\color{blue}{0.5}}{t} \]
  3. Taylor expanded in y around 0 0.12

    \[\leadsto \color{blue}{0.5 \cdot \frac{y}{t} + 0.5 \cdot \frac{x - z}{t}} \]
  4. Final simplification0.12

    \[\leadsto 0.5 \cdot \frac{y}{t} + 0.5 \cdot \frac{x - z}{t} \]

Alternatives

Alternative 1
Error41.48%
Cost1112
\[\begin{array}{l} t_1 := \frac{0.5}{\frac{t}{y}}\\ t_2 := \frac{x}{t \cdot 2}\\ t_3 := \frac{z}{t} \cdot -0.5\\ \mathbf{if}\;x \leq -1.35 \cdot 10^{+78}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -2 \cdot 10^{+27}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -5.3 \cdot 10^{-6}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.75 \cdot 10^{-37}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -1.22 \cdot 10^{-73}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.62 \cdot 10^{-227}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error41.43%
Cost1112
\[\begin{array}{l} t_1 := \frac{0.5 \cdot y}{t}\\ t_2 := \frac{x}{t \cdot 2}\\ t_3 := \frac{z}{t} \cdot -0.5\\ \mathbf{if}\;x \leq -1.05 \cdot 10^{+79}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -3.5 \cdot 10^{+25}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -1.5 \cdot 10^{-6}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -5.6 \cdot 10^{-37}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -2.25 \cdot 10^{-73}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -3.5 \cdot 10^{-226}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error10.67%
Cost844
\[\begin{array}{l} t_1 := \frac{x - z}{t \cdot 2}\\ \mathbf{if}\;x \leq -1.25 \cdot 10^{+28}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -8 \cdot 10^{-7}:\\ \;\;\;\;\frac{0.5}{t} \cdot \left(y + x\right)\\ \mathbf{elif}\;x \leq -2.65 \cdot 10^{-73}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{y - z}{t \cdot 2}\\ \end{array} \]
Alternative 4
Error10.67%
Cost844
\[\begin{array}{l} t_1 := \frac{x - z}{t \cdot 2}\\ \mathbf{if}\;x \leq -2.6 \cdot 10^{+26}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -5.9 \cdot 10^{-7}:\\ \;\;\;\;0.5 \cdot \left(\frac{y}{t} + \frac{x}{t}\right)\\ \mathbf{elif}\;x \leq -5.6 \cdot 10^{-74}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{y - z}{t \cdot 2}\\ \end{array} \]
Alternative 5
Error18.67%
Cost580
\[\begin{array}{l} \mathbf{if}\;y \leq 0.00165:\\ \;\;\;\;\left(x - z\right) \cdot \frac{0.5}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5 \cdot y}{t}\\ \end{array} \]
Alternative 6
Error13.98%
Cost580
\[\begin{array}{l} \mathbf{if}\;y \leq 2.65 \cdot 10^{-20}:\\ \;\;\;\;\left(x - z\right) \cdot \frac{0.5}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{t} \cdot \left(y + x\right)\\ \end{array} \]
Alternative 7
Error13.84%
Cost580
\[\begin{array}{l} \mathbf{if}\;y \leq 9.8 \cdot 10^{-17}:\\ \;\;\;\;\frac{x - z}{t \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{t} \cdot \left(y + x\right)\\ \end{array} \]
Alternative 8
Error0.44%
Cost576
\[\left(x + \left(y - z\right)\right) \cdot \frac{0.5}{t} \]
Alternative 9
Error0.09%
Cost576
\[\frac{\left(y + x\right) - z}{t \cdot 2} \]
Alternative 10
Error45.64%
Cost452
\[\begin{array}{l} \mathbf{if}\;y \leq 10^{-10}:\\ \;\;\;\;\frac{z}{t} \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{\frac{t}{y}}\\ \end{array} \]
Alternative 11
Error64.37%
Cost320
\[z \cdot \frac{-0.5}{t} \]
Alternative 12
Error64.26%
Cost320
\[\frac{z}{t} \cdot -0.5 \]

Error

Reproduce?

herbie shell --seed 2023090 
(FPCore (x y z t)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, B"
  :precision binary64
  (/ (- (+ x y) z) (* t 2.0)))