?

Average Error: 0.1 → 0.1
Time: 14.1s
Precision: binary64
Cost: 704

?

\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ \end{array} \]
\[\frac{\left(x + y\right) - z}{t \cdot 2} \]
\[0.5 \cdot \left(\frac{y}{t} + \frac{x - z}{t}\right) \]
(FPCore (x y z t) :precision binary64 (/ (- (+ x y) z) (* t 2.0)))
(FPCore (x y z t) :precision binary64 (* 0.5 (+ (/ y t) (/ (- 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) + ((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) + ((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) + ((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) + ((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(0.5 * Float64(Float64(y / t) + 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) + ((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[(0.5 * N[(N[(y / t), $MachinePrecision] + N[(N[(x - z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\left(x + y\right) - z}{t \cdot 2}
0.5 \cdot \left(\frac{y}{t} + \frac{x - z}{t}\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 0.1

    \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
  2. Taylor expanded in y around 0 0.1

    \[\leadsto \color{blue}{0.5 \cdot \frac{y}{t} + 0.5 \cdot \frac{x - z}{t}} \]
  3. Simplified0.1

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

    [Start]0.1

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

    rational.json-simplify-1 [=>]0.1

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

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

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

    rational.json-simplify-51 [=>]0.1

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

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

Alternatives

Alternative 1
Error8.7
Cost1236
\[\begin{array}{l} t_1 := 0.5 \cdot \frac{x - z}{t}\\ \mathbf{if}\;y \leq 2.8 \cdot 10^{-90}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{-37}:\\ \;\;\;\;0.5 \cdot \frac{y - z}{t}\\ \mathbf{elif}\;y \leq 430000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{+58}:\\ \;\;\;\;0.5 \cdot \frac{y + x}{t}\\ \mathbf{elif}\;y \leq 1.75 \cdot 10^{+103}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\frac{y}{t} - \frac{z}{t}\right)\\ \end{array} \]
Alternative 2
Error8.8
Cost1108
\[\begin{array}{l} t_1 := 0.5 \cdot \frac{y - z}{t}\\ t_2 := 0.5 \cdot \frac{x - z}{t}\\ \mathbf{if}\;y \leq 3.15 \cdot 10^{-90}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{-37}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 500000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{+55}:\\ \;\;\;\;0.5 \cdot \frac{y + x}{t}\\ \mathbf{elif}\;y \leq 1.66 \cdot 10^{+103}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error13.4
Cost976
\[\begin{array}{l} t_1 := \frac{z}{t} \cdot -0.5\\ t_2 := 0.5 \cdot \frac{y + x}{t}\\ \mathbf{if}\;z \leq -2.15 \cdot 10^{+131}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.7 \cdot 10^{+58}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -6.5 \cdot 10^{+49}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{+69}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error26.5
Cost848
\[\begin{array}{l} t_1 := 0.5 \cdot \frac{y}{t}\\ t_2 := \frac{-0.5}{t} \cdot z\\ \mathbf{if}\;x \leq -3 \cdot 10^{+84}:\\ \;\;\;\;0.5 \cdot \frac{x}{t}\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{-191}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{-251}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-150}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error26.4
Cost848
\[\begin{array}{l} t_1 := 0.5 \cdot \frac{y}{t}\\ t_2 := \frac{z}{t} \cdot -0.5\\ \mathbf{if}\;x \leq -2.9 \cdot 10^{+84}:\\ \;\;\;\;0.5 \cdot \frac{x}{t}\\ \mathbf{elif}\;x \leq -4.4 \cdot 10^{-192}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.62 \cdot 10^{-251}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-151}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error9.7
Cost844
\[\begin{array}{l} t_1 := 0.5 \cdot \frac{y + x}{t}\\ t_2 := 0.5 \cdot \frac{x - z}{t}\\ \mathbf{if}\;y \leq 460000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+58}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{+96}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error0.3
Cost576
\[\frac{0.5}{t} \cdot \left(x + \left(y - z\right)\right) \]
Alternative 8
Error0.1
Cost576
\[\frac{\left(x + y\right) - z}{t \cdot 2} \]
Alternative 9
Error27.3
Cost452
\[\begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{+14}:\\ \;\;\;\;0.5 \cdot \frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{t}\\ \end{array} \]
Alternative 10
Error41.4
Cost320
\[0.5 \cdot \frac{x}{t} \]

Error

Reproduce?

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