Average Error: 6.0 → 0.9
Time: 10.0s
Precision: binary64
Cost: 1352
\[x - \frac{y \cdot \left(z - t\right)}{a} \]
\[\begin{array}{l} t_1 := y \cdot \left(z - t\right)\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{+237}:\\ \;\;\;\;x + \frac{y}{a} \cdot \left(t - z\right)\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+104}:\\ \;\;\;\;x + \frac{y \cdot \left(t - z\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{t - z}{a}\\ \end{array} \]
(FPCore (x y z t a) :precision binary64 (- x (/ (* y (- z t)) a)))
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (* y (- z t))))
   (if (<= t_1 -2e+237)
     (+ x (* (/ y a) (- t z)))
     (if (<= t_1 2e+104)
       (+ x (/ (* y (- t z)) a))
       (+ x (* y (/ (- t z) a)))))))
double code(double x, double y, double z, double t, double a) {
	return x - ((y * (z - t)) / a);
}
double code(double x, double y, double z, double t, double a) {
	double t_1 = y * (z - t);
	double tmp;
	if (t_1 <= -2e+237) {
		tmp = x + ((y / a) * (t - z));
	} else if (t_1 <= 2e+104) {
		tmp = x + ((y * (t - z)) / a);
	} else {
		tmp = x + (y * ((t - z) / a));
	}
	return tmp;
}
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = x - ((y * (z - t)) / a)
end function
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8) :: t_1
    real(8) :: tmp
    t_1 = y * (z - t)
    if (t_1 <= (-2d+237)) then
        tmp = x + ((y / a) * (t - z))
    else if (t_1 <= 2d+104) then
        tmp = x + ((y * (t - z)) / a)
    else
        tmp = x + (y * ((t - z) / a))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	return x - ((y * (z - t)) / a);
}
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = y * (z - t);
	double tmp;
	if (t_1 <= -2e+237) {
		tmp = x + ((y / a) * (t - z));
	} else if (t_1 <= 2e+104) {
		tmp = x + ((y * (t - z)) / a);
	} else {
		tmp = x + (y * ((t - z) / a));
	}
	return tmp;
}
def code(x, y, z, t, a):
	return x - ((y * (z - t)) / a)
def code(x, y, z, t, a):
	t_1 = y * (z - t)
	tmp = 0
	if t_1 <= -2e+237:
		tmp = x + ((y / a) * (t - z))
	elif t_1 <= 2e+104:
		tmp = x + ((y * (t - z)) / a)
	else:
		tmp = x + (y * ((t - z) / a))
	return tmp
function code(x, y, z, t, a)
	return Float64(x - Float64(Float64(y * Float64(z - t)) / a))
end
function code(x, y, z, t, a)
	t_1 = Float64(y * Float64(z - t))
	tmp = 0.0
	if (t_1 <= -2e+237)
		tmp = Float64(x + Float64(Float64(y / a) * Float64(t - z)));
	elseif (t_1 <= 2e+104)
		tmp = Float64(x + Float64(Float64(y * Float64(t - z)) / a));
	else
		tmp = Float64(x + Float64(y * Float64(Float64(t - z) / a)));
	end
	return tmp
end
function tmp = code(x, y, z, t, a)
	tmp = x - ((y * (z - t)) / a);
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = y * (z - t);
	tmp = 0.0;
	if (t_1 <= -2e+237)
		tmp = x + ((y / a) * (t - z));
	elseif (t_1 <= 2e+104)
		tmp = x + ((y * (t - z)) / a);
	else
		tmp = x + (y * ((t - z) / a));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+237], N[(x + N[(N[(y / a), $MachinePrecision] * N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+104], N[(x + N[(N[(y * N[(t - z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(N[(t - z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
x - \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
t_1 := y \cdot \left(z - t\right)\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{+237}:\\
\;\;\;\;x + \frac{y}{a} \cdot \left(t - z\right)\\

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+104}:\\
\;\;\;\;x + \frac{y \cdot \left(t - z\right)}{a}\\

\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{t - z}{a}\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.0
Target0.8
Herbie0.9
\[\begin{array}{l} \mathbf{if}\;y < -1.0761266216389975 \cdot 10^{-10}:\\ \;\;\;\;x - \frac{1}{\frac{\frac{a}{z - t}}{y}}\\ \mathbf{elif}\;y < 2.894426862792089 \cdot 10^{-49}:\\ \;\;\;\;x - \frac{y \cdot \left(z - t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\ \end{array} \]

Derivation

  1. Split input into 3 regimes
  2. if (*.f64 y (-.f64 z t)) < -1.99999999999999988e237

    1. Initial program 35.7

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

      \[\leadsto \color{blue}{x - \frac{y}{a} \cdot \left(z - t\right)} \]
      Proof
      (-.f64 x (*.f64 (/.f64 y a) (-.f64 z t))): 0 points increase in error, 0 points decrease in error
      (-.f64 x (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 y (-.f64 z t)) a))): 55 points increase in error, 26 points decrease in error

    if -1.99999999999999988e237 < (*.f64 y (-.f64 z t)) < 2e104

    1. Initial program 0.4

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

    if 2e104 < (*.f64 y (-.f64 z t))

    1. Initial program 16.1

      \[x - \frac{y \cdot \left(z - t\right)}{a} \]
    2. Simplified3.4

      \[\leadsto \color{blue}{x - y \cdot \frac{z - t}{a}} \]
      Proof
      (-.f64 x (*.f64 y (/.f64 (-.f64 z t) a))): 0 points increase in error, 0 points decrease in error
      (-.f64 x (Rewrite<= *-commutative_binary64 (*.f64 (/.f64 (-.f64 z t) a) y))): 0 points increase in error, 0 points decrease in error
      (-.f64 x (Rewrite=> *-commutative_binary64 (*.f64 y (/.f64 (-.f64 z t) a)))): 0 points increase in error, 0 points decrease in error
      (-.f64 x (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 y (-.f64 z t)) a))): 49 points increase in error, 37 points decrease in error
  3. Recombined 3 regimes into one program.
  4. Final simplification0.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) \leq -2 \cdot 10^{+237}:\\ \;\;\;\;x + \frac{y}{a} \cdot \left(t - z\right)\\ \mathbf{elif}\;y \cdot \left(z - t\right) \leq 2 \cdot 10^{+104}:\\ \;\;\;\;x + \frac{y \cdot \left(t - z\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{t - z}{a}\\ \end{array} \]

Alternatives

Alternative 1
Error13.8
Cost1240
\[\begin{array}{l} t_1 := \frac{y}{a} \cdot \left(t - z\right)\\ t_2 := x - y \cdot \frac{z}{a}\\ t_3 := x + t \cdot \frac{y}{a}\\ \mathbf{if}\;z \leq -1.7 \cdot 10^{+147}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -8 \cdot 10^{+112}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.05 \cdot 10^{+76}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 2.05 \cdot 10^{+84}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+127}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.7 \cdot 10^{+164}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error28.5
Cost980
\[\begin{array}{l} t_1 := t \cdot \frac{y}{a}\\ \mathbf{if}\;x \leq -5.2 \cdot 10^{-63}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{-255}:\\ \;\;\;\;z \cdot \frac{-y}{a}\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-193}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-112}:\\ \;\;\;\;\frac{y \cdot \left(-z\right)}{a}\\ \mathbf{elif}\;x \leq 5.3 \cdot 10^{-59}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error5.9
Cost840
\[\begin{array}{l} t_1 := x + y \cdot \frac{t - z}{a}\\ \mathbf{if}\;a \leq -3.1 \cdot 10^{-186}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 7.8 \cdot 10^{-228}:\\ \;\;\;\;\frac{y}{a} \cdot \left(t - z\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error28.8
Cost716
\[\begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{-64}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{-307}:\\ \;\;\;\;y \cdot \left(-\frac{z}{a}\right)\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-179}:\\ \;\;\;\;\frac{y}{\frac{a}{t}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error28.2
Cost716
\[\begin{array}{l} \mathbf{if}\;x \leq -9 \cdot 10^{-65}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{-255}:\\ \;\;\;\;z \cdot \frac{-y}{a}\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{-58}:\\ \;\;\;\;t \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error19.0
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -8.5 \cdot 10^{+15}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.08 \cdot 10^{-57}:\\ \;\;\;\;\frac{y}{a} \cdot \left(t - z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error13.9
Cost712
\[\begin{array}{l} t_1 := x + t \cdot \frac{y}{a}\\ \mathbf{if}\;x \leq -2.6 \cdot 10^{-64}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-153}:\\ \;\;\;\;\frac{y}{a} \cdot \left(t - z\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error9.4
Cost712
\[\begin{array}{l} t_1 := x + t \cdot \frac{y}{a}\\ \mathbf{if}\;t \leq -9.8 \cdot 10^{+33}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.7 \cdot 10^{+62}:\\ \;\;\;\;x - z \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error9.2
Cost712
\[\begin{array}{l} t_1 := x + t \cdot \frac{y}{a}\\ \mathbf{if}\;t \leq -5.2 \cdot 10^{+33}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.25 \cdot 10^{+62}:\\ \;\;\;\;x - \frac{z}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error28.7
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -4.2 \cdot 10^{-131}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{-179}:\\ \;\;\;\;y \cdot \frac{t}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error28.8
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -5.5 \cdot 10^{-103}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-181}:\\ \;\;\;\;\frac{y}{\frac{a}{t}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Error2.3
Cost576
\[x + \frac{y}{a} \cdot \left(t - z\right) \]
Alternative 13
Error31.2
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022329 
(FPCore (x y z t a)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, F"
  :precision binary64

  :herbie-target
  (if (< y -1.0761266216389975e-10) (- x (/ 1.0 (/ (/ a (- z t)) y))) (if (< y 2.894426862792089e-49) (- x (/ (* y (- z t)) a)) (- x (/ y (/ a (- z t))))))

  (- x (/ (* y (- z t)) a)))