Average Error: 6.5 → 0.7
Time: 25.5s
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}{a} \cdot \left(z - t\right)\\ \mathbf{if}\;t_1 \leq -4 \cdot 10^{+252}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 10^{+74}:\\ \;\;\;\;x + \frac{1}{a} \cdot t_1\\ \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 -4e+252) t_2 (if (<= t_1 1e+74) (+ x (* (/ 1.0 a) t_1)) 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 <= -4e+252) {
		tmp = t_2;
	} else if (t_1 <= 1e+74) {
		tmp = x + ((1.0 / a) * t_1);
	} 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 <= (-4d+252)) then
        tmp = t_2
    else if (t_1 <= 1d+74) then
        tmp = x + ((1.0d0 / a) * t_1)
    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 <= -4e+252) {
		tmp = t_2;
	} else if (t_1 <= 1e+74) {
		tmp = x + ((1.0 / a) * t_1);
	} 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 <= -4e+252:
		tmp = t_2
	elif t_1 <= 1e+74:
		tmp = x + ((1.0 / a) * t_1)
	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(Float64(y / a) * Float64(z - t)))
	tmp = 0.0
	if (t_1 <= -4e+252)
		tmp = t_2;
	elseif (t_1 <= 1e+74)
		tmp = Float64(x + Float64(Float64(1.0 / a) * t_1));
	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 <= -4e+252)
		tmp = t_2;
	elseif (t_1 <= 1e+74)
		tmp = x + ((1.0 / a) * t_1);
	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[(N[(y / a), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+252], t$95$2, If[LessEqual[t$95$1, 1e+74], N[(x + N[(N[(1.0 / a), $MachinePrecision] * t$95$1), $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}{a} \cdot \left(z - t\right)\\
\mathbf{if}\;t_1 \leq -4 \cdot 10^{+252}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_1 \leq 10^{+74}:\\
\;\;\;\;x + \frac{1}{a} \cdot t_1\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.5
Target0.7
Herbie0.7
\[\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)) < -4.0000000000000004e252 or 9.99999999999999952e73 < (*.f64 y (-.f64 z t))

    1. Initial program 22.5

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

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

    if -4.0000000000000004e252 < (*.f64 y (-.f64 z t)) < 9.99999999999999952e73

    1. Initial program 0.3

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

      \[\leadsto x + \color{blue}{\frac{1}{a} \cdot \left(y \cdot \left(z - t\right)\right)} \]
  3. Recombined 2 regimes into one program.

Alternatives

Alternative 1
Error0.7
Cost1352
\[\begin{array}{l} t_1 := y \cdot \left(z - t\right)\\ t_2 := x + \frac{y}{a} \cdot \left(z - t\right)\\ \mathbf{if}\;t_1 \leq -3 \cdot 10^{+241}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 10^{+74}:\\ \;\;\;\;x + \frac{t_1}{a}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error29.1
Cost1308
\[\begin{array}{l} t_1 := -\frac{y \cdot t}{a}\\ \mathbf{if}\;x \leq -5.6 \cdot 10^{-92}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -6.8 \cdot 10^{-181}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -5.2 \cdot 10^{-248}:\\ \;\;\;\;\frac{y \cdot z}{a}\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-267}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-60}:\\ \;\;\;\;\frac{y}{a} \cdot z\\ \mathbf{elif}\;x \leq 2.36 \cdot 10^{+64}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{+91}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error28.8
Cost1308
\[\begin{array}{l} t_1 := \left(-t\right) \cdot \frac{y}{a}\\ \mathbf{if}\;x \leq -7.8 \cdot 10^{-93}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -7.8 \cdot 10^{-180}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{-247}:\\ \;\;\;\;\frac{y \cdot z}{a}\\ \mathbf{elif}\;x \leq 1.12 \cdot 10^{-228}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{-70}:\\ \;\;\;\;\frac{y}{a} \cdot z\\ \mathbf{elif}\;x \leq 2.36 \cdot 10^{+64}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{+91}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error31.5
Cost1112
\[\begin{array}{l} t_1 := \frac{y}{a} \cdot z\\ \mathbf{if}\;a \leq -2.3 \cdot 10^{+17}:\\ \;\;\;\;x\\ \mathbf{elif}\;a \leq -2.1 \cdot 10^{-41}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -4 \cdot 10^{-250}:\\ \;\;\;\;x\\ \mathbf{elif}\;a \leq 1.4 \cdot 10^{-104}:\\ \;\;\;\;\frac{y \cdot z}{a}\\ \mathbf{elif}\;a \leq 8.6 \cdot 10^{+134}:\\ \;\;\;\;x\\ \mathbf{elif}\;a \leq 4.3 \cdot 10^{+161}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error16.5
Cost976
\[\begin{array}{l} t_1 := \frac{y}{a} \cdot \left(z - t\right)\\ t_2 := \frac{y \cdot z}{a} + x\\ \mathbf{if}\;x \leq -5.5 \cdot 10^{-66}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{-34}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.36 \cdot 10^{+64}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{+91}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error16.7
Cost976
\[\begin{array}{l} t_1 := \frac{y \cdot z}{a} + x\\ \mathbf{if}\;x \leq -1.7 \cdot 10^{-65}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 6 \cdot 10^{-35}:\\ \;\;\;\;\frac{y}{a} \cdot \left(z - t\right)\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{+63}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{+91}:\\ \;\;\;\;\frac{\left(z - t\right) \cdot y}{a}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error10.2
Cost840
\[\begin{array}{l} t_1 := \left(-\frac{y}{a} \cdot t\right) + x\\ \mathbf{if}\;t \leq -1.7 \cdot 10^{-39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 35000000000000:\\ \;\;\;\;x + \frac{1}{a} \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error10.2
Cost776
\[\begin{array}{l} t_1 := \left(-\frac{y}{a} \cdot t\right) + x\\ \mathbf{if}\;t \leq -1.25 \cdot 10^{-42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 34000000000000:\\ \;\;\;\;\frac{y \cdot z}{a} + x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error20.0
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -7.5 \cdot 10^{-66}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{+91}:\\ \;\;\;\;\frac{y}{a} \cdot \left(z - t\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error2.4
Cost576
\[x + \frac{y}{a} \cdot \left(z - t\right) \]
Alternative 11
Error29.9
Cost452
\[\begin{array}{l} \mathbf{if}\;z \leq -5.3 \cdot 10^{+98}:\\ \;\;\;\;\frac{y}{a} \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Error30.5
Cost64
\[x \]

Error

Reproduce

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