Average Error: 6.0 → 0.4
Time: 11.9s
Precision: binary64
Cost: 1480
\[x + \frac{y \cdot \left(z - t\right)}{a} \]
\[\begin{array}{l} t_1 := y \cdot \left(z - t\right)\\ t_2 := x + \frac{y}{\frac{a}{z - t}}\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+258}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 10^{+235}:\\ \;\;\;\;x + \frac{y \cdot z - y \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \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))) (t_2 (+ x (/ y (/ a (- z t))))))
   (if (<= t_1 -1e+258)
     t_2
     (if (<= t_1 1e+235) (+ x (/ (- (* y z) (* y t)) a)) t_2))))
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 t_2 = x + (y / (a / (z - t)));
	double tmp;
	if (t_1 <= -1e+258) {
		tmp = t_2;
	} else if (t_1 <= 1e+235) {
		tmp = x + (((y * z) - (y * t)) / a);
	} else {
		tmp = t_2;
	}
	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) :: t_2
    real(8) :: tmp
    t_1 = y * (z - t)
    t_2 = x + (y / (a / (z - t)))
    if (t_1 <= (-1d+258)) then
        tmp = t_2
    else if (t_1 <= 1d+235) then
        tmp = x + (((y * z) - (y * t)) / a)
    else
        tmp = t_2
    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 t_2 = x + (y / (a / (z - t)));
	double tmp;
	if (t_1 <= -1e+258) {
		tmp = t_2;
	} else if (t_1 <= 1e+235) {
		tmp = x + (((y * z) - (y * t)) / a);
	} else {
		tmp = t_2;
	}
	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)
	t_2 = x + (y / (a / (z - t)))
	tmp = 0
	if t_1 <= -1e+258:
		tmp = t_2
	elif t_1 <= 1e+235:
		tmp = x + (((y * z) - (y * t)) / a)
	else:
		tmp = t_2
	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))
	t_2 = Float64(x + Float64(y / Float64(a / Float64(z - t))))
	tmp = 0.0
	if (t_1 <= -1e+258)
		tmp = t_2;
	elseif (t_1 <= 1e+235)
		tmp = Float64(x + Float64(Float64(Float64(y * z) - Float64(y * t)) / a));
	else
		tmp = t_2;
	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);
	t_2 = x + (y / (a / (z - t)));
	tmp = 0.0;
	if (t_1 <= -1e+258)
		tmp = t_2;
	elseif (t_1 <= 1e+235)
		tmp = x + (((y * z) - (y * t)) / a);
	else
		tmp = t_2;
	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]}, Block[{t$95$2 = N[(x + N[(y / N[(a / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+258], t$95$2, If[LessEqual[t$95$1, 1e+235], N[(x + N[(N[(N[(y * z), $MachinePrecision] - N[(y * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
x + \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
t_1 := y \cdot \left(z - t\right)\\
t_2 := x + \frac{y}{\frac{a}{z - t}}\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{+258}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_1 \leq 10^{+235}:\\
\;\;\;\;x + \frac{y \cdot z - y \cdot t}{a}\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.0
Target0.7
Herbie0.4
\[\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 (*.f64 y (-.f64 z t)) < -1.00000000000000006e258 or 1.0000000000000001e235 < (*.f64 y (-.f64 z t))

    1. Initial program 38.3

      \[x + \frac{y \cdot \left(z - t\right)}{a} \]
    2. Applied egg-rr0.5

      \[\leadsto x + \color{blue}{{\left(\frac{\frac{a}{z - t}}{y}\right)}^{-1}} \]
    3. Applied egg-rr0.4

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

    if -1.00000000000000006e258 < (*.f64 y (-.f64 z t)) < 1.0000000000000001e235

    1. Initial program 0.4

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

      \[\leadsto x + \frac{\color{blue}{z \cdot y + \left(-t\right) \cdot y}}{a} \]
    3. Applied egg-rr0.4

      \[\leadsto x + \frac{\color{blue}{z \cdot y - y \cdot t}}{a} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.4

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

Alternatives

Alternative 1
Error0.4
Cost1352
\[\begin{array}{l} t_1 := y \cdot \left(z - t\right)\\ t_2 := x + \frac{y}{\frac{a}{z - t}}\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+258}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 10^{+235}:\\ \;\;\;\;x + \frac{t_1}{a}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error27.5
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -5.156459900251924 \cdot 10^{-137}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3.2420929651385853 \cdot 10^{-250}:\\ \;\;\;\;\frac{y \cdot z}{a}\\ \mathbf{elif}\;x \leq 1.1870925662703923 \cdot 10^{-227}:\\ \;\;\;\;\frac{-t}{\frac{a}{y}}\\ \mathbf{elif}\;x \leq 9.435992693415405 \cdot 10^{-174}:\\ \;\;\;\;y \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error6.0
Cost840
\[\begin{array}{l} t_1 := x + \frac{y}{\frac{a}{z - t}}\\ \mathbf{if}\;x \leq -2.0453762434853886 \cdot 10^{-260}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.292744097665409 \cdot 10^{-264}:\\ \;\;\;\;\frac{y \cdot \left(z - t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error27.5
Cost716
\[\begin{array}{l} \mathbf{if}\;x \leq -1.4893988804110956 \cdot 10^{-184}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.1870925662703923 \cdot 10^{-227}:\\ \;\;\;\;\frac{y \cdot t}{-a}\\ \mathbf{elif}\;x \leq 9.435992693415405 \cdot 10^{-174}:\\ \;\;\;\;y \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error12.2
Cost712
\[\begin{array}{l} t_1 := x + \frac{y \cdot z}{a}\\ \mathbf{if}\;z \leq -1.9839249830848782 \cdot 10^{-49}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.3928591157141355 \cdot 10^{+58}:\\ \;\;\;\;x - \frac{y}{\frac{a}{t}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error12.1
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1.9839249830848782 \cdot 10^{-49}:\\ \;\;\;\;x + \frac{y \cdot z}{a}\\ \mathbf{elif}\;z \leq 2.3928591157141355 \cdot 10^{+58}:\\ \;\;\;\;x - \frac{y}{\frac{a}{t}}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z}{a}\\ \end{array} \]
Alternative 7
Error27.5
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -2.5548399540783596 \cdot 10^{-124}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 9.435992693415405 \cdot 10^{-174}:\\ \;\;\;\;\frac{y}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error27.5
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -5.156459900251924 \cdot 10^{-137}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 9.435992693415405 \cdot 10^{-174}:\\ \;\;\;\;\frac{y \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error17.8
Cost580
\[\begin{array}{l} \mathbf{if}\;z \leq -9 \cdot 10^{+180}:\\ \;\;\;\;z \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{a}{t}}\\ \end{array} \]
Alternative 10
Error30.3
Cost64
\[x \]

Error

Reproduce

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