?

Average Error: 9.47% → 1.87%
Time: 12.8s
Precision: binary64
Cost: 1864

?

\[x - \frac{y \cdot \left(z - t\right)}{a} \]
\[\begin{array}{l} t_1 := x + \frac{y \cdot \left(t - z\right)}{a}\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{+124}:\\ \;\;\;\;x + \frac{t - z}{\frac{a}{y}}\\ \mathbf{elif}\;t_1 \leq 10^{+258}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{a} \cdot \left(t - z\right)\\ \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 (+ x (/ (* y (- t z)) a))))
   (if (<= t_1 -2e+124)
     (+ x (/ (- t z) (/ a y)))
     (if (<= t_1 1e+258) t_1 (+ x (* (/ y a) (- t z)))))))
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 = x + ((y * (t - z)) / a);
	double tmp;
	if (t_1 <= -2e+124) {
		tmp = x + ((t - z) / (a / y));
	} else if (t_1 <= 1e+258) {
		tmp = t_1;
	} else {
		tmp = x + ((y / a) * (t - z));
	}
	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 = x + ((y * (t - z)) / a)
    if (t_1 <= (-2d+124)) then
        tmp = x + ((t - z) / (a / y))
    else if (t_1 <= 1d+258) then
        tmp = t_1
    else
        tmp = x + ((y / a) * (t - z))
    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 = x + ((y * (t - z)) / a);
	double tmp;
	if (t_1 <= -2e+124) {
		tmp = x + ((t - z) / (a / y));
	} else if (t_1 <= 1e+258) {
		tmp = t_1;
	} else {
		tmp = x + ((y / a) * (t - z));
	}
	return tmp;
}
def code(x, y, z, t, a):
	return x - ((y * (z - t)) / a)
def code(x, y, z, t, a):
	t_1 = x + ((y * (t - z)) / a)
	tmp = 0
	if t_1 <= -2e+124:
		tmp = x + ((t - z) / (a / y))
	elif t_1 <= 1e+258:
		tmp = t_1
	else:
		tmp = x + ((y / a) * (t - z))
	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(x + Float64(Float64(y * Float64(t - z)) / a))
	tmp = 0.0
	if (t_1 <= -2e+124)
		tmp = Float64(x + Float64(Float64(t - z) / Float64(a / y)));
	elseif (t_1 <= 1e+258)
		tmp = t_1;
	else
		tmp = Float64(x + Float64(Float64(y / a) * Float64(t - z)));
	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 = x + ((y * (t - z)) / a);
	tmp = 0.0;
	if (t_1 <= -2e+124)
		tmp = x + ((t - z) / (a / y));
	elseif (t_1 <= 1e+258)
		tmp = t_1;
	else
		tmp = x + ((y / a) * (t - z));
	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[(x + N[(N[(y * N[(t - z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+124], N[(x + N[(N[(t - z), $MachinePrecision] / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+258], t$95$1, N[(x + N[(N[(y / a), $MachinePrecision] * N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
x - \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
t_1 := x + \frac{y \cdot \left(t - z\right)}{a}\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{+124}:\\
\;\;\;\;x + \frac{t - z}{\frac{a}{y}}\\

\mathbf{elif}\;t_1 \leq 10^{+258}:\\
\;\;\;\;t_1\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original9.47%
Target1.06%
Herbie1.87%
\[\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 x (/.f64 (*.f64 y (-.f64 z t)) a)) < -1.9999999999999999e124

    1. Initial program 17.5

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

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

      [Start]17.5

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

      associate-*l/ [<=]4.29

      \[ x - \color{blue}{\frac{y}{a} \cdot \left(z - t\right)} \]
    3. Applied egg-rr3.83

      \[\leadsto x - \color{blue}{\frac{z - t}{\frac{a}{y}}} \]

    if -1.9999999999999999e124 < (-.f64 x (/.f64 (*.f64 y (-.f64 z t)) a)) < 1.00000000000000006e258

    1. Initial program 0.72

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

    if 1.00000000000000006e258 < (-.f64 x (/.f64 (*.f64 y (-.f64 z t)) a))

    1. Initial program 42.19

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

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

      [Start]42.19

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

      associate-*l/ [<=]3.87

      \[ x - \color{blue}{\frac{y}{a} \cdot \left(z - t\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.87

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

Alternatives

Alternative 1
Error0.87%
Cost1353
\[\begin{array}{l} t_1 := y \cdot \left(z - t\right)\\ \mathbf{if}\;t_1 \leq -5 \cdot 10^{+147} \lor \neg \left(t_1 \leq 2 \cdot 10^{+198}\right):\\ \;\;\;\;x + \frac{y}{a} \cdot \left(t - z\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot \left(t - z\right)}{a}\\ \end{array} \]
Alternative 2
Error42.96%
Cost1112
\[\begin{array}{l} t_1 := t \cdot \frac{y}{a}\\ t_2 := z \cdot \frac{-y}{a}\\ \mathbf{if}\;x \leq -2.05 \cdot 10^{-139}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-304}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{-286}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 10^{-147}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{-115}:\\ \;\;\;\;y \cdot \frac{t}{a}\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-99}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error43.27%
Cost1112
\[\begin{array}{l} t_1 := t \cdot \frac{y}{a}\\ \mathbf{if}\;x \leq -1.95 \cdot 10^{-139}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-300}:\\ \;\;\;\;z \cdot \frac{-y}{a}\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-283}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-159}:\\ \;\;\;\;\frac{-y}{\frac{a}{z}}\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-115}:\\ \;\;\;\;y \cdot \frac{t}{a}\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-99}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error43.32%
Cost1112
\[\begin{array}{l} t_1 := t \cdot \frac{y}{a}\\ \mathbf{if}\;x \leq -2 \cdot 10^{-139}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 9.8 \cdot 10^{-303}:\\ \;\;\;\;z \cdot \frac{-y}{a}\\ \mathbf{elif}\;x \leq 1.12 \cdot 10^{-287}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-164}:\\ \;\;\;\;\frac{y \cdot \left(-z\right)}{a}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-115}:\\ \;\;\;\;y \cdot \frac{t}{a}\\ \mathbf{elif}\;x \leq 8.6 \cdot 10^{-98}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error18.75%
Cost977
\[\begin{array}{l} t_1 := x + t \cdot \frac{y}{a}\\ \mathbf{if}\;t \leq -2.05 \cdot 10^{-23}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 6 \cdot 10^{-96}:\\ \;\;\;\;x - \frac{y}{\frac{a}{z}}\\ \mathbf{elif}\;t \leq 6.6 \cdot 10^{+67} \lor \neg \left(t \leq 9 \cdot 10^{+189}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{t - z}{\frac{a}{y}}\\ \end{array} \]
Alternative 6
Error27.26%
Cost976
\[\begin{array}{l} t_1 := x + t \cdot \frac{y}{a}\\ t_2 := z \cdot \frac{-y}{a}\\ \mathbf{if}\;z \leq -6 \cdot 10^{+280}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 3 \cdot 10^{-78}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5.2 \cdot 10^{-31}:\\ \;\;\;\;y \cdot \frac{t - z}{a}\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{+240}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error20.91%
Cost844
\[\begin{array}{l} t_1 := x - \frac{y}{\frac{a}{z}}\\ \mathbf{if}\;z \leq -3.6 \cdot 10^{-39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{-181}:\\ \;\;\;\;x + t \cdot \frac{y}{a}\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{+244}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{-y}{a}\\ \end{array} \]
Alternative 8
Error4.67%
Cost841
\[\begin{array}{l} \mathbf{if}\;x \leq -1.3 \cdot 10^{-197} \lor \neg \left(x \leq 2 \cdot 10^{-120}\right):\\ \;\;\;\;x + \frac{y}{a} \cdot \left(t - z\right)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\ \end{array} \]
Alternative 9
Error31.98%
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -4.2 \cdot 10^{-65}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{-100}:\\ \;\;\;\;y \cdot \frac{t - z}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error43.71%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -2.8 \cdot 10^{-188}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-106}:\\ \;\;\;\;y \cdot \frac{t}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error43.65%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{-192}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-108}:\\ \;\;\;\;\frac{y}{\frac{a}{t}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Error4%
Cost576
\[x + \frac{y}{a} \cdot \left(t - z\right) \]
Alternative 13
Error47.88%
Cost64
\[x \]

Error

Reproduce?

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