?

Average Error: 9.46% → 1.57%
Time: 11.4s
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.57%
\[\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.89

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

    \[\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
Error33.29%
Cost977
\[\begin{array}{l} \mathbf{if}\;x \leq -1.9 \cdot 10^{+37}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -6.6 \cdot 10^{-92} \lor \neg \left(x \leq -2.5 \cdot 10^{-168}\right) \land x \leq 0.017:\\ \;\;\;\;y \cdot \frac{z - t}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error32.82%
Cost976
\[\begin{array}{l} \mathbf{if}\;x \leq -5.3 \cdot 10^{+39}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -5.4 \cdot 10^{-92}:\\ \;\;\;\;y \cdot \frac{z - t}{a}\\ \mathbf{elif}\;x \leq -2.4 \cdot 10^{-167}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 8.8 \cdot 10^{+104}:\\ \;\;\;\;\left(z - t\right) \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error45.76%
Cost849
\[\begin{array}{l} \mathbf{if}\;x \leq -5.6 \cdot 10^{-177}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{-177} \lor \neg \left(x \leq 1.8 \cdot 10^{-82}\right) \land x \leq 1.7:\\ \;\;\;\;y \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error45.23%
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -6.5 \cdot 10^{-168}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-176}:\\ \;\;\;\;z \cdot \frac{y}{a}\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{-77}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 0.065:\\ \;\;\;\;y \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error45.42%
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -2.2 \cdot 10^{-167}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.72 \cdot 10^{-180}:\\ \;\;\;\;z \cdot \frac{y}{a}\\ \mathbf{elif}\;x \leq 3.9 \cdot 10^{-78}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 28500:\\ \;\;\;\;\frac{y}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error45.28%
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -1.55 \cdot 10^{-167}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.42 \cdot 10^{-180}:\\ \;\;\;\;\frac{z}{\frac{a}{y}}\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-78}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 0.1:\\ \;\;\;\;\frac{y}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error45.56%
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -1.35 \cdot 10^{-167}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.7 \cdot 10^{-180}:\\ \;\;\;\;\frac{y \cdot z}{a}\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-82}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 0.11:\\ \;\;\;\;\frac{y}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error3.72%
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 9
Error23.43%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -3.4 \cdot 10^{-212} \lor \neg \left(x \leq 1.4 \cdot 10^{-174}\right):\\ \;\;\;\;x + \frac{z}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{z - t}{a}\\ \end{array} \]
Alternative 10
Error14.97%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -1.8 \cdot 10^{-94} \lor \neg \left(z \leq 1.06 \cdot 10^{-10}\right):\\ \;\;\;\;x + \frac{z}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;x - t \cdot \frac{y}{a}\\ \end{array} \]
Alternative 11
Error3.78%
Cost576
\[x + \left(z - t\right) \cdot \frac{y}{a} \]
Alternative 12
Error48.81%
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, E"
  :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)))