?

Average Error: 9.46% → 1.58%
Time: 12.7s
Precision: binary64
Cost: 841

?

\[x - \frac{y \cdot \left(z - t\right)}{a} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -6.8 \cdot 10^{-83} \lor \neg \left(y \leq 5 \cdot 10^{-54}\right):\\ \;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot \left(z - t\right)}{a}\\ \end{array} \]
(FPCore (x y z t a) :precision binary64 (- x (/ (* y (- z t)) a)))
(FPCore (x y z t a)
 :precision binary64
 (if (or (<= y -6.8e-83) (not (<= y 5e-54)))
   (- x (/ y (/ a (- z t))))
   (- x (/ (* y (- z t)) 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 tmp;
	if ((y <= -6.8e-83) || !(y <= 5e-54)) {
		tmp = x - (y / (a / (z - t)));
	} else {
		tmp = x - ((y * (z - t)) / 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) :: tmp
    if ((y <= (-6.8d-83)) .or. (.not. (y <= 5d-54))) then
        tmp = x - (y / (a / (z - t)))
    else
        tmp = x - ((y * (z - t)) / 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 tmp;
	if ((y <= -6.8e-83) || !(y <= 5e-54)) {
		tmp = x - (y / (a / (z - t)));
	} else {
		tmp = x - ((y * (z - t)) / a);
	}
	return tmp;
}
def code(x, y, z, t, a):
	return x - ((y * (z - t)) / a)
def code(x, y, z, t, a):
	tmp = 0
	if (y <= -6.8e-83) or not (y <= 5e-54):
		tmp = x - (y / (a / (z - t)))
	else:
		tmp = x - ((y * (z - t)) / 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)
	tmp = 0.0
	if ((y <= -6.8e-83) || !(y <= 5e-54))
		tmp = Float64(x - Float64(y / Float64(a / Float64(z - t))));
	else
		tmp = Float64(x - Float64(Float64(y * Float64(z - t)) / 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)
	tmp = 0.0;
	if ((y <= -6.8e-83) || ~((y <= 5e-54)))
		tmp = x - (y / (a / (z - t)));
	else
		tmp = x - ((y * (z - t)) / 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_] := If[Or[LessEqual[y, -6.8e-83], N[Not[LessEqual[y, 5e-54]], $MachinePrecision]], N[(x - N[(y / N[(a / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]
x - \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;y \leq -6.8 \cdot 10^{-83} \lor \neg \left(y \leq 5 \cdot 10^{-54}\right):\\
\;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original9.46%
Target1.29%
Herbie1.58%
\[\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 2 regimes
  2. if y < -6.7999999999999995e-83 or 5.00000000000000015e-54 < y

    1. Initial program 17.62

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

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

      [Start]17.62

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

      associate-/l* [=>]2.22

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

    if -6.7999999999999995e-83 < y < 5.00000000000000015e-54

    1. Initial program 0.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.8 \cdot 10^{-83} \lor \neg \left(y \leq 5 \cdot 10^{-54}\right):\\ \;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot \left(z - t\right)}{a}\\ \end{array} \]

Alternatives

Alternative 1
Error44.71%
Cost1176
\[\begin{array}{l} t_1 := z \cdot \frac{-y}{a}\\ t_2 := \frac{y}{\frac{a}{t}}\\ \mathbf{if}\;x \leq -3.4 \cdot 10^{-212}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -4.1 \cdot 10^{-297}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{-186}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.4 \cdot 10^{-173}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-79}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-31}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error45.12%
Cost1176
\[\begin{array}{l} t_1 := \frac{y}{\frac{a}{t}}\\ \mathbf{if}\;x \leq -3.4 \cdot 10^{-212}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -5 \cdot 10^{-297}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 6 \cdot 10^{-187}:\\ \;\;\;\;z \cdot \frac{-y}{a}\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{-172}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{-85}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.4 \cdot 10^{-23}:\\ \;\;\;\;y \cdot \frac{-z}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error44.75%
Cost1045
\[\begin{array}{l} \mathbf{if}\;x \leq -3.4 \cdot 10^{-212}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -5.8 \cdot 10^{-296}:\\ \;\;\;\;\frac{y}{\frac{a}{t}}\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-176} \lor \neg \left(x \leq 7.5 \cdot 10^{-80}\right) \land x \leq 1.55 \cdot 10^{-32}:\\ \;\;\;\;\frac{z}{\frac{-a}{y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error44.91%
Cost1044
\[\begin{array}{l} \mathbf{if}\;x \leq -3.1 \cdot 10^{-212}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -5.1 \cdot 10^{-297}:\\ \;\;\;\;\frac{y}{\frac{a}{t}}\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{-179}:\\ \;\;\;\;\frac{z}{\frac{-a}{y}}\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-79}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{-32}:\\ \;\;\;\;\frac{-y}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error24.54%
Cost978
\[\begin{array}{l} \mathbf{if}\;x \leq -7.5 \cdot 10^{-168} \lor \neg \left(x \leq 2.45 \cdot 10^{-177}\right) \land \left(x \leq 4.9 \cdot 10^{-82} \lor \neg \left(x \leq 4.8 \cdot 10^{-30}\right)\right):\\ \;\;\;\;x + \frac{y \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a} \cdot \left(t - z\right)\\ \end{array} \]
Alternative 6
Error33.27%
Cost977
\[\begin{array}{l} \mathbf{if}\;x \leq -2.4 \cdot 10^{+37}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -5.4 \cdot 10^{-92} \lor \neg \left(x \leq -2.5 \cdot 10^{-168}\right) \land x \leq 0.00047:\\ \;\;\;\;y \cdot \frac{t - z}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error32.75%
Cost976
\[\begin{array}{l} \mathbf{if}\;x \leq -2.3 \cdot 10^{+37}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3.4 \cdot 10^{-91}:\\ \;\;\;\;y \cdot \frac{t - z}{a}\\ \mathbf{elif}\;x \leq -2.4 \cdot 10^{-167}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 9.6 \cdot 10^{+104}:\\ \;\;\;\;\frac{y}{a} \cdot \left(t - z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error44.72%
Cost912
\[\begin{array}{l} \mathbf{if}\;x \leq -7.2 \cdot 10^{-168}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.4 \cdot 10^{-180}:\\ \;\;\;\;\frac{y \cdot \left(-z\right)}{a}\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{-81}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.55 \cdot 10^{-32}:\\ \;\;\;\;\frac{-y}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error3.71%
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -2.3 \cdot 10^{-201} \lor \neg \left(z \leq 6 \cdot 10^{-99}\right):\\ \;\;\;\;x - \left(z - t\right) \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\ \end{array} \]
Alternative 10
Error19.62%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -3.6 \cdot 10^{-99} \lor \neg \left(z \leq 8.5 \cdot 10^{-11}\right):\\ \;\;\;\;x - y \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot t}{a}\\ \end{array} \]
Alternative 11
Error15.92%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -1.45 \cdot 10^{-99} \lor \neg \left(z \leq 7 \cdot 10^{-11}\right):\\ \;\;\;\;x - \frac{z}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot t}{a}\\ \end{array} \]
Alternative 12
Error45.25%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -2.8 \cdot 10^{-212}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{-173}:\\ \;\;\;\;y \cdot \frac{t}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 13
Error45.17%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{-213}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-173}:\\ \;\;\;\;\frac{y}{\frac{a}{t}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 14
Error3.77%
Cost576
\[x - \left(z - t\right) \cdot \frac{y}{a} \]
Alternative 15
Error48.78%
Cost64
\[x \]

Error

Reproduce?

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