Optimisation.CirclePacking:place from circle-packing-0.1.0.4, E

Percentage Accurate: 93.0% → 93.4%
Time: 11.9s
Alternatives: 7
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ x + \frac{y \cdot \left(z - t\right)}{a} \end{array} \]
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) a)))
double code(double x, double y, double z, double t, double a) {
	return x + ((y * (z - t)) / a);
}
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
public static double code(double x, double y, double z, double t, double a) {
	return x + ((y * (z - t)) / a);
}
def code(x, y, z, t, a):
	return x + ((y * (z - t)) / a)
function code(x, y, z, t, a)
	return Float64(x + Float64(Float64(y * Float64(z - t)) / a))
end
function tmp = code(x, y, z, t, a)
	tmp = x + ((y * (z - t)) / a);
end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \frac{y \cdot \left(z - t\right)}{a}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 7 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 93.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \frac{y \cdot \left(z - t\right)}{a} \end{array} \]
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) a)))
double code(double x, double y, double z, double t, double a) {
	return x + ((y * (z - t)) / a);
}
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
public static double code(double x, double y, double z, double t, double a) {
	return x + ((y * (z - t)) / a);
}
def code(x, y, z, t, a):
	return x + ((y * (z - t)) / a)
function code(x, y, z, t, a)
	return Float64(x + Float64(Float64(y * Float64(z - t)) / a))
end
function tmp = code(x, y, z, t, a)
	tmp = x + ((y * (z - t)) / a);
end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \frac{y \cdot \left(z - t\right)}{a}
\end{array}

Alternative 1: 93.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x + y \cdot \frac{z - t}{a}\\ \mathbf{if}\;y \leq -5 \cdot 10^{-195}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{-289}:\\ \;\;\;\;x + \frac{z \cdot y}{a}\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{-154}:\\ \;\;\;\;x - \frac{t \cdot y}{a}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (+ x (* y (/ (- z t) a)))))
   (if (<= y -5e-195)
     t_1
     (if (<= y 8.2e-289)
       (+ x (/ (* z y) a))
       (if (<= y 3.6e-154) (- x (/ (* t y) a)) t_1)))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = x + (y * ((z - t) / a));
	double tmp;
	if (y <= -5e-195) {
		tmp = t_1;
	} else if (y <= 8.2e-289) {
		tmp = x + ((z * y) / a);
	} else if (y <= 3.6e-154) {
		tmp = x - ((t * y) / a);
	} else {
		tmp = t_1;
	}
	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
    real(8) :: t_1
    real(8) :: tmp
    t_1 = x + (y * ((z - t) / a))
    if (y <= (-5d-195)) then
        tmp = t_1
    else if (y <= 8.2d-289) then
        tmp = x + ((z * y) / a)
    else if (y <= 3.6d-154) then
        tmp = x - ((t * y) / a)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = x + (y * ((z - t) / a));
	double tmp;
	if (y <= -5e-195) {
		tmp = t_1;
	} else if (y <= 8.2e-289) {
		tmp = x + ((z * y) / a);
	} else if (y <= 3.6e-154) {
		tmp = x - ((t * y) / a);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t, a):
	t_1 = x + (y * ((z - t) / a))
	tmp = 0
	if y <= -5e-195:
		tmp = t_1
	elif y <= 8.2e-289:
		tmp = x + ((z * y) / a)
	elif y <= 3.6e-154:
		tmp = x - ((t * y) / a)
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t, a)
	t_1 = Float64(x + Float64(y * Float64(Float64(z - t) / a)))
	tmp = 0.0
	if (y <= -5e-195)
		tmp = t_1;
	elseif (y <= 8.2e-289)
		tmp = Float64(x + Float64(Float64(z * y) / a));
	elseif (y <= 3.6e-154)
		tmp = Float64(x - Float64(Float64(t * y) / a));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = x + (y * ((z - t) / a));
	tmp = 0.0;
	if (y <= -5e-195)
		tmp = t_1;
	elseif (y <= 8.2e-289)
		tmp = x + ((z * y) / a);
	elseif (y <= 3.6e-154)
		tmp = x - ((t * y) / a);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5e-195], t$95$1, If[LessEqual[y, 8.2e-289], N[(x + N[(N[(z * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.6e-154], N[(x - N[(N[(t * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x + y \cdot \frac{z - t}{a}\\
\mathbf{if}\;y \leq -5 \cdot 10^{-195}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 8.2 \cdot 10^{-289}:\\
\;\;\;\;x + \frac{z \cdot y}{a}\\

\mathbf{elif}\;y \leq 3.6 \cdot 10^{-154}:\\
\;\;\;\;x - \frac{t \cdot y}{a}\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -5.00000000000000009e-195 or 3.6000000000000003e-154 < y

    1. Initial program 92.4%

      \[x + \frac{y \cdot \left(z - t\right)}{a} \]
    2. Step-by-step derivation
      1. associate-/l*97.9%

        \[\leadsto x + \color{blue}{y \cdot \frac{z - t}{a}} \]
    3. Simplified97.9%

      \[\leadsto \color{blue}{x + y \cdot \frac{z - t}{a}} \]
    4. Add Preprocessing

    if -5.00000000000000009e-195 < y < 8.1999999999999996e-289

    1. Initial program 100.0%

      \[x + \frac{y \cdot \left(z - t\right)}{a} \]
    2. Step-by-step derivation
      1. associate-/l*69.2%

        \[\leadsto x + \color{blue}{y \cdot \frac{z - t}{a}} \]
    3. Simplified69.2%

      \[\leadsto \color{blue}{x + y \cdot \frac{z - t}{a}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 90.7%

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

    if 8.1999999999999996e-289 < y < 3.6000000000000003e-154

    1. Initial program 99.8%

      \[x + \frac{y \cdot \left(z - t\right)}{a} \]
    2. Step-by-step derivation
      1. associate-/l*75.6%

        \[\leadsto x + \color{blue}{y \cdot \frac{z - t}{a}} \]
    3. Simplified75.6%

      \[\leadsto \color{blue}{x + y \cdot \frac{z - t}{a}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 99.8%

      \[\leadsto \color{blue}{x + -1 \cdot \frac{t \cdot y}{a}} \]
    6. Step-by-step derivation
      1. mul-1-neg99.8%

        \[\leadsto x + \color{blue}{\left(-\frac{t \cdot y}{a}\right)} \]
      2. unsub-neg99.8%

        \[\leadsto \color{blue}{x - \frac{t \cdot y}{a}} \]
      3. *-commutative99.8%

        \[\leadsto x - \frac{\color{blue}{y \cdot t}}{a} \]
      4. associate-/l*75.6%

        \[\leadsto x - \color{blue}{y \cdot \frac{t}{a}} \]
    7. Simplified75.6%

      \[\leadsto \color{blue}{x - y \cdot \frac{t}{a}} \]
    8. Step-by-step derivation
      1. associate-*r/99.8%

        \[\leadsto x - \color{blue}{\frac{y \cdot t}{a}} \]
    9. Applied egg-rr99.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{-195}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a}\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{-289}:\\ \;\;\;\;x + \frac{z \cdot y}{a}\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{-154}:\\ \;\;\;\;x - \frac{t \cdot y}{a}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 86.4% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -1.76 \cdot 10^{+37} \lor \neg \left(t \leq 5.4 \cdot 10^{+40}\right):\\ \;\;\;\;x - t \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z}{\frac{a}{y}}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (if (or (<= t -1.76e+37) (not (<= t 5.4e+40)))
   (- x (* t (/ y a)))
   (+ x (/ z (/ a y)))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((t <= -1.76e+37) || !(t <= 5.4e+40)) {
		tmp = x - (t * (y / a));
	} else {
		tmp = x + (z / (a / y));
	}
	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
    real(8) :: tmp
    if ((t <= (-1.76d+37)) .or. (.not. (t <= 5.4d+40))) then
        tmp = x - (t * (y / a))
    else
        tmp = x + (z / (a / y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((t <= -1.76e+37) || !(t <= 5.4e+40)) {
		tmp = x - (t * (y / a));
	} else {
		tmp = x + (z / (a / y));
	}
	return tmp;
}
def code(x, y, z, t, a):
	tmp = 0
	if (t <= -1.76e+37) or not (t <= 5.4e+40):
		tmp = x - (t * (y / a))
	else:
		tmp = x + (z / (a / y))
	return tmp
function code(x, y, z, t, a)
	tmp = 0.0
	if ((t <= -1.76e+37) || !(t <= 5.4e+40))
		tmp = Float64(x - Float64(t * Float64(y / a)));
	else
		tmp = Float64(x + Float64(z / Float64(a / y)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if ((t <= -1.76e+37) || ~((t <= 5.4e+40)))
		tmp = x - (t * (y / a));
	else
		tmp = x + (z / (a / y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -1.76e+37], N[Not[LessEqual[t, 5.4e+40]], $MachinePrecision]], N[(x - N[(t * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.76 \cdot 10^{+37} \lor \neg \left(t \leq 5.4 \cdot 10^{+40}\right):\\
\;\;\;\;x - t \cdot \frac{y}{a}\\

\mathbf{else}:\\
\;\;\;\;x + \frac{z}{\frac{a}{y}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.76e37 or 5.40000000000000019e40 < t

    1. Initial program 88.6%

      \[x + \frac{y \cdot \left(z - t\right)}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative88.6%

        \[\leadsto x + \frac{\color{blue}{\left(z - t\right) \cdot y}}{a} \]
      2. associate-/l*97.8%

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

      \[\leadsto x + \color{blue}{\left(z - t\right) \cdot \frac{y}{a}} \]
    5. Taylor expanded in z around 0 81.1%

      \[\leadsto \color{blue}{x + -1 \cdot \frac{t \cdot y}{a}} \]
    6. Step-by-step derivation
      1. associate-*l/78.1%

        \[\leadsto x + -1 \cdot \color{blue}{\left(\frac{t}{a} \cdot y\right)} \]
      2. *-commutative78.1%

        \[\leadsto x + -1 \cdot \color{blue}{\left(y \cdot \frac{t}{a}\right)} \]
      3. neg-mul-178.1%

        \[\leadsto x + \color{blue}{\left(-y \cdot \frac{t}{a}\right)} \]
      4. sub-neg78.1%

        \[\leadsto \color{blue}{x - y \cdot \frac{t}{a}} \]
      5. *-commutative78.1%

        \[\leadsto x - \color{blue}{\frac{t}{a} \cdot y} \]
      6. associate-*l/81.1%

        \[\leadsto x - \color{blue}{\frac{t \cdot y}{a}} \]
      7. associate-*r/88.5%

        \[\leadsto x - \color{blue}{t \cdot \frac{y}{a}} \]
    7. Simplified88.5%

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

    if -1.76e37 < t < 5.40000000000000019e40

    1. Initial program 97.6%

      \[x + \frac{y \cdot \left(z - t\right)}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative97.6%

        \[\leadsto x + \frac{\color{blue}{\left(z - t\right) \cdot y}}{a} \]
      2. associate-/l*96.3%

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

      \[\leadsto x + \color{blue}{\left(z - t\right) \cdot \frac{y}{a}} \]
    5. Taylor expanded in z around inf 91.2%

      \[\leadsto x + \color{blue}{z} \cdot \frac{y}{a} \]
    6. Step-by-step derivation
      1. clear-num91.2%

        \[\leadsto x + z \cdot \color{blue}{\frac{1}{\frac{a}{y}}} \]
      2. un-div-inv91.6%

        \[\leadsto x + \color{blue}{\frac{z}{\frac{a}{y}}} \]
    7. Applied egg-rr91.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.76 \cdot 10^{+37} \lor \neg \left(t \leq 5.4 \cdot 10^{+40}\right):\\ \;\;\;\;x - t \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z}{\frac{a}{y}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 76.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -1.42 \cdot 10^{+194} \lor \neg \left(t \leq 7.5 \cdot 10^{+86}\right):\\ \;\;\;\;\frac{t}{\frac{a}{-y}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z}{\frac{a}{y}}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (if (or (<= t -1.42e+194) (not (<= t 7.5e+86)))
   (/ t (/ a (- y)))
   (+ x (/ z (/ a y)))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((t <= -1.42e+194) || !(t <= 7.5e+86)) {
		tmp = t / (a / -y);
	} else {
		tmp = x + (z / (a / y));
	}
	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
    real(8) :: tmp
    if ((t <= (-1.42d+194)) .or. (.not. (t <= 7.5d+86))) then
        tmp = t / (a / -y)
    else
        tmp = x + (z / (a / y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((t <= -1.42e+194) || !(t <= 7.5e+86)) {
		tmp = t / (a / -y);
	} else {
		tmp = x + (z / (a / y));
	}
	return tmp;
}
def code(x, y, z, t, a):
	tmp = 0
	if (t <= -1.42e+194) or not (t <= 7.5e+86):
		tmp = t / (a / -y)
	else:
		tmp = x + (z / (a / y))
	return tmp
function code(x, y, z, t, a)
	tmp = 0.0
	if ((t <= -1.42e+194) || !(t <= 7.5e+86))
		tmp = Float64(t / Float64(a / Float64(-y)));
	else
		tmp = Float64(x + Float64(z / Float64(a / y)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if ((t <= -1.42e+194) || ~((t <= 7.5e+86)))
		tmp = t / (a / -y);
	else
		tmp = x + (z / (a / y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -1.42e+194], N[Not[LessEqual[t, 7.5e+86]], $MachinePrecision]], N[(t / N[(a / (-y)), $MachinePrecision]), $MachinePrecision], N[(x + N[(z / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.42 \cdot 10^{+194} \lor \neg \left(t \leq 7.5 \cdot 10^{+86}\right):\\
\;\;\;\;\frac{t}{\frac{a}{-y}}\\

\mathbf{else}:\\
\;\;\;\;x + \frac{z}{\frac{a}{y}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.4199999999999999e194 or 7.4999999999999997e86 < t

    1. Initial program 89.0%

      \[x + \frac{y \cdot \left(z - t\right)}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative89.0%

        \[\leadsto x + \frac{\color{blue}{\left(z - t\right) \cdot y}}{a} \]
      2. associate-/l*96.5%

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

      \[\leadsto x + \color{blue}{\left(z - t\right) \cdot \frac{y}{a}} \]
    5. Taylor expanded in z around 0 84.6%

      \[\leadsto \color{blue}{x + -1 \cdot \frac{t \cdot y}{a}} \]
    6. Step-by-step derivation
      1. associate-*l/80.0%

        \[\leadsto x + -1 \cdot \color{blue}{\left(\frac{t}{a} \cdot y\right)} \]
      2. *-commutative80.0%

        \[\leadsto x + -1 \cdot \color{blue}{\left(y \cdot \frac{t}{a}\right)} \]
      3. neg-mul-180.0%

        \[\leadsto x + \color{blue}{\left(-y \cdot \frac{t}{a}\right)} \]
      4. sub-neg80.0%

        \[\leadsto \color{blue}{x - y \cdot \frac{t}{a}} \]
      5. *-commutative80.0%

        \[\leadsto x - \color{blue}{\frac{t}{a} \cdot y} \]
      6. associate-*l/84.6%

        \[\leadsto x - \color{blue}{\frac{t \cdot y}{a}} \]
      7. associate-*r/93.8%

        \[\leadsto x - \color{blue}{t \cdot \frac{y}{a}} \]
    7. Simplified93.8%

      \[\leadsto \color{blue}{x - t \cdot \frac{y}{a}} \]
    8. Taylor expanded in x around 0 70.3%

      \[\leadsto \color{blue}{-1 \cdot \frac{t \cdot y}{a}} \]
    9. Step-by-step derivation
      1. mul-1-neg70.3%

        \[\leadsto \color{blue}{-\frac{t \cdot y}{a}} \]
      2. associate-*l/65.7%

        \[\leadsto -\color{blue}{\frac{t}{a} \cdot y} \]
      3. associate-/r/77.7%

        \[\leadsto -\color{blue}{\frac{t}{\frac{a}{y}}} \]
    10. Simplified77.7%

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

    if -1.4199999999999999e194 < t < 7.4999999999999997e86

    1. Initial program 95.6%

      \[x + \frac{y \cdot \left(z - t\right)}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative95.6%

        \[\leadsto x + \frac{\color{blue}{\left(z - t\right) \cdot y}}{a} \]
      2. associate-/l*97.0%

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

      \[\leadsto x + \color{blue}{\left(z - t\right) \cdot \frac{y}{a}} \]
    5. Taylor expanded in z around inf 87.6%

      \[\leadsto x + \color{blue}{z} \cdot \frac{y}{a} \]
    6. Step-by-step derivation
      1. clear-num87.5%

        \[\leadsto x + z \cdot \color{blue}{\frac{1}{\frac{a}{y}}} \]
      2. un-div-inv87.9%

        \[\leadsto x + \color{blue}{\frac{z}{\frac{a}{y}}} \]
    7. Applied egg-rr87.9%

      \[\leadsto x + \color{blue}{\frac{z}{\frac{a}{y}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification85.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.42 \cdot 10^{+194} \lor \neg \left(t \leq 7.5 \cdot 10^{+86}\right):\\ \;\;\;\;\frac{t}{\frac{a}{-y}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z}{\frac{a}{y}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 76.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -9.5 \cdot 10^{+198} \lor \neg \left(t \leq 5.4 \cdot 10^{+85}\right):\\ \;\;\;\;\frac{t}{\frac{a}{-y}}\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \frac{y}{a}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (if (or (<= t -9.5e+198) (not (<= t 5.4e+85)))
   (/ t (/ a (- y)))
   (+ x (* z (/ y a)))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((t <= -9.5e+198) || !(t <= 5.4e+85)) {
		tmp = t / (a / -y);
	} else {
		tmp = x + (z * (y / 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
    real(8) :: tmp
    if ((t <= (-9.5d+198)) .or. (.not. (t <= 5.4d+85))) then
        tmp = t / (a / -y)
    else
        tmp = x + (z * (y / a))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((t <= -9.5e+198) || !(t <= 5.4e+85)) {
		tmp = t / (a / -y);
	} else {
		tmp = x + (z * (y / a));
	}
	return tmp;
}
def code(x, y, z, t, a):
	tmp = 0
	if (t <= -9.5e+198) or not (t <= 5.4e+85):
		tmp = t / (a / -y)
	else:
		tmp = x + (z * (y / a))
	return tmp
function code(x, y, z, t, a)
	tmp = 0.0
	if ((t <= -9.5e+198) || !(t <= 5.4e+85))
		tmp = Float64(t / Float64(a / Float64(-y)));
	else
		tmp = Float64(x + Float64(z * Float64(y / a)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if ((t <= -9.5e+198) || ~((t <= 5.4e+85)))
		tmp = t / (a / -y);
	else
		tmp = x + (z * (y / a));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -9.5e+198], N[Not[LessEqual[t, 5.4e+85]], $MachinePrecision]], N[(t / N[(a / (-y)), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -9.5 \cdot 10^{+198} \lor \neg \left(t \leq 5.4 \cdot 10^{+85}\right):\\
\;\;\;\;\frac{t}{\frac{a}{-y}}\\

\mathbf{else}:\\
\;\;\;\;x + z \cdot \frac{y}{a}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -9.5e198 or 5.39999999999999966e85 < t

    1. Initial program 89.0%

      \[x + \frac{y \cdot \left(z - t\right)}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative89.0%

        \[\leadsto x + \frac{\color{blue}{\left(z - t\right) \cdot y}}{a} \]
      2. associate-/l*96.5%

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

      \[\leadsto x + \color{blue}{\left(z - t\right) \cdot \frac{y}{a}} \]
    5. Taylor expanded in z around 0 84.6%

      \[\leadsto \color{blue}{x + -1 \cdot \frac{t \cdot y}{a}} \]
    6. Step-by-step derivation
      1. associate-*l/80.0%

        \[\leadsto x + -1 \cdot \color{blue}{\left(\frac{t}{a} \cdot y\right)} \]
      2. *-commutative80.0%

        \[\leadsto x + -1 \cdot \color{blue}{\left(y \cdot \frac{t}{a}\right)} \]
      3. neg-mul-180.0%

        \[\leadsto x + \color{blue}{\left(-y \cdot \frac{t}{a}\right)} \]
      4. sub-neg80.0%

        \[\leadsto \color{blue}{x - y \cdot \frac{t}{a}} \]
      5. *-commutative80.0%

        \[\leadsto x - \color{blue}{\frac{t}{a} \cdot y} \]
      6. associate-*l/84.6%

        \[\leadsto x - \color{blue}{\frac{t \cdot y}{a}} \]
      7. associate-*r/93.8%

        \[\leadsto x - \color{blue}{t \cdot \frac{y}{a}} \]
    7. Simplified93.8%

      \[\leadsto \color{blue}{x - t \cdot \frac{y}{a}} \]
    8. Taylor expanded in x around 0 70.3%

      \[\leadsto \color{blue}{-1 \cdot \frac{t \cdot y}{a}} \]
    9. Step-by-step derivation
      1. mul-1-neg70.3%

        \[\leadsto \color{blue}{-\frac{t \cdot y}{a}} \]
      2. associate-*l/65.7%

        \[\leadsto -\color{blue}{\frac{t}{a} \cdot y} \]
      3. associate-/r/77.7%

        \[\leadsto -\color{blue}{\frac{t}{\frac{a}{y}}} \]
    10. Simplified77.7%

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

    if -9.5e198 < t < 5.39999999999999966e85

    1. Initial program 95.6%

      \[x + \frac{y \cdot \left(z - t\right)}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative95.6%

        \[\leadsto x + \frac{\color{blue}{\left(z - t\right) \cdot y}}{a} \]
      2. associate-/l*97.0%

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

      \[\leadsto x + \color{blue}{\left(z - t\right) \cdot \frac{y}{a}} \]
    5. Taylor expanded in z around inf 87.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -9.5 \cdot 10^{+198} \lor \neg \left(t \leq 5.4 \cdot 10^{+85}\right):\\ \;\;\;\;\frac{t}{\frac{a}{-y}}\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \frac{y}{a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 51.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -1.6 \cdot 10^{+143} \lor \neg \left(t \leq 1.5 \cdot 10^{+83}\right):\\ \;\;\;\;\frac{t}{\frac{a}{-y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (if (or (<= t -1.6e+143) (not (<= t 1.5e+83))) (/ t (/ a (- y))) x))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((t <= -1.6e+143) || !(t <= 1.5e+83)) {
		tmp = t / (a / -y);
	} else {
		tmp = x;
	}
	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
    real(8) :: tmp
    if ((t <= (-1.6d+143)) .or. (.not. (t <= 1.5d+83))) then
        tmp = t / (a / -y)
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((t <= -1.6e+143) || !(t <= 1.5e+83)) {
		tmp = t / (a / -y);
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z, t, a):
	tmp = 0
	if (t <= -1.6e+143) or not (t <= 1.5e+83):
		tmp = t / (a / -y)
	else:
		tmp = x
	return tmp
function code(x, y, z, t, a)
	tmp = 0.0
	if ((t <= -1.6e+143) || !(t <= 1.5e+83))
		tmp = Float64(t / Float64(a / Float64(-y)));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if ((t <= -1.6e+143) || ~((t <= 1.5e+83)))
		tmp = t / (a / -y);
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -1.6e+143], N[Not[LessEqual[t, 1.5e+83]], $MachinePrecision]], N[(t / N[(a / (-y)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.6 \cdot 10^{+143} \lor \neg \left(t \leq 1.5 \cdot 10^{+83}\right):\\
\;\;\;\;\frac{t}{\frac{a}{-y}}\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.60000000000000008e143 or 1.5e83 < t

    1. Initial program 89.7%

      \[x + \frac{y \cdot \left(z - t\right)}{a} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative89.7%

        \[\leadsto x + \frac{\color{blue}{\left(z - t\right) \cdot y}}{a} \]
      2. associate-/l*97.1%

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

      \[\leadsto x + \color{blue}{\left(z - t\right) \cdot \frac{y}{a}} \]
    5. Taylor expanded in z around 0 81.1%

      \[\leadsto \color{blue}{x + -1 \cdot \frac{t \cdot y}{a}} \]
    6. Step-by-step derivation
      1. associate-*l/77.3%

        \[\leadsto x + -1 \cdot \color{blue}{\left(\frac{t}{a} \cdot y\right)} \]
      2. *-commutative77.3%

        \[\leadsto x + -1 \cdot \color{blue}{\left(y \cdot \frac{t}{a}\right)} \]
      3. neg-mul-177.3%

        \[\leadsto x + \color{blue}{\left(-y \cdot \frac{t}{a}\right)} \]
      4. sub-neg77.3%

        \[\leadsto \color{blue}{x - y \cdot \frac{t}{a}} \]
      5. *-commutative77.3%

        \[\leadsto x - \color{blue}{\frac{t}{a} \cdot y} \]
      6. associate-*l/81.1%

        \[\leadsto x - \color{blue}{\frac{t \cdot y}{a}} \]
      7. associate-*r/89.9%

        \[\leadsto x - \color{blue}{t \cdot \frac{y}{a}} \]
    7. Simplified89.9%

      \[\leadsto \color{blue}{x - t \cdot \frac{y}{a}} \]
    8. Taylor expanded in x around 0 67.5%

      \[\leadsto \color{blue}{-1 \cdot \frac{t \cdot y}{a}} \]
    9. Step-by-step derivation
      1. mul-1-neg67.5%

        \[\leadsto \color{blue}{-\frac{t \cdot y}{a}} \]
      2. associate-*l/63.7%

        \[\leadsto -\color{blue}{\frac{t}{a} \cdot y} \]
      3. associate-/r/74.8%

        \[\leadsto -\color{blue}{\frac{t}{\frac{a}{y}}} \]
    10. Simplified74.8%

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

    if -1.60000000000000008e143 < t < 1.5e83

    1. Initial program 95.9%

      \[x + \frac{y \cdot \left(z - t\right)}{a} \]
    2. Step-by-step derivation
      1. associate-/l*95.1%

        \[\leadsto x + \color{blue}{y \cdot \frac{z - t}{a}} \]
    3. Simplified95.1%

      \[\leadsto \color{blue}{x + y \cdot \frac{z - t}{a}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 46.1%

      \[\leadsto \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification54.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.6 \cdot 10^{+143} \lor \neg \left(t \leq 1.5 \cdot 10^{+83}\right):\\ \;\;\;\;\frac{t}{\frac{a}{-y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 97.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \left(z - t\right) \cdot \frac{y}{a} \end{array} \]
(FPCore (x y z t a) :precision binary64 (+ x (* (- z t) (/ y a))))
double code(double x, double y, double z, double t, double a) {
	return x + ((z - t) * (y / a));
}
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 + ((z - t) * (y / a))
end function
public static double code(double x, double y, double z, double t, double a) {
	return x + ((z - t) * (y / a));
}
def code(x, y, z, t, a):
	return x + ((z - t) * (y / a))
function code(x, y, z, t, a)
	return Float64(x + Float64(Float64(z - t) * Float64(y / a)))
end
function tmp = code(x, y, z, t, a)
	tmp = x + ((z - t) * (y / a));
end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(z - t), $MachinePrecision] * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \left(z - t\right) \cdot \frac{y}{a}
\end{array}
Derivation
  1. Initial program 94.1%

    \[x + \frac{y \cdot \left(z - t\right)}{a} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. *-commutative94.1%

      \[\leadsto x + \frac{\color{blue}{\left(z - t\right) \cdot y}}{a} \]
    2. associate-/l*96.9%

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

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

Alternative 7: 40.4% accurate, 9.0× speedup?

\[\begin{array}{l} \\ x \end{array} \]
(FPCore (x y z t a) :precision binary64 x)
double code(double x, double y, double z, double t, double a) {
	return x;
}
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
end function
public static double code(double x, double y, double z, double t, double a) {
	return x;
}
def code(x, y, z, t, a):
	return x
function code(x, y, z, t, a)
	return x
end
function tmp = code(x, y, z, t, a)
	tmp = x;
end
code[x_, y_, z_, t_, a_] := x
\begin{array}{l}

\\
x
\end{array}
Derivation
  1. Initial program 94.1%

    \[x + \frac{y \cdot \left(z - t\right)}{a} \]
  2. Step-by-step derivation
    1. associate-/l*92.1%

      \[\leadsto x + \color{blue}{y \cdot \frac{z - t}{a}} \]
  3. Simplified92.1%

    \[\leadsto \color{blue}{x + y \cdot \frac{z - t}{a}} \]
  4. Add Preprocessing
  5. Taylor expanded in x around inf 37.9%

    \[\leadsto \color{blue}{x} \]
  6. Add Preprocessing

Developer Target 1: 99.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{a}{z - t}\\ \mathbf{if}\;y < -1.0761266216389975 \cdot 10^{-10}:\\ \;\;\;\;x + \frac{1}{\frac{t\_1}{y}}\\ \mathbf{elif}\;y < 2.894426862792089 \cdot 10^{-49}:\\ \;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{t\_1}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (/ a (- z t))))
   (if (< y -1.0761266216389975e-10)
     (+ x (/ 1.0 (/ t_1 y)))
     (if (< y 2.894426862792089e-49)
       (+ x (/ (* y (- z t)) a))
       (+ x (/ y t_1))))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = a / (z - t);
	double tmp;
	if (y < -1.0761266216389975e-10) {
		tmp = x + (1.0 / (t_1 / y));
	} else if (y < 2.894426862792089e-49) {
		tmp = x + ((y * (z - t)) / a);
	} else {
		tmp = x + (y / t_1);
	}
	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
    real(8) :: t_1
    real(8) :: tmp
    t_1 = a / (z - t)
    if (y < (-1.0761266216389975d-10)) then
        tmp = x + (1.0d0 / (t_1 / y))
    else if (y < 2.894426862792089d-49) then
        tmp = x + ((y * (z - t)) / a)
    else
        tmp = x + (y / t_1)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = a / (z - t);
	double tmp;
	if (y < -1.0761266216389975e-10) {
		tmp = x + (1.0 / (t_1 / y));
	} else if (y < 2.894426862792089e-49) {
		tmp = x + ((y * (z - t)) / a);
	} else {
		tmp = x + (y / t_1);
	}
	return tmp;
}
def code(x, y, z, t, a):
	t_1 = a / (z - t)
	tmp = 0
	if y < -1.0761266216389975e-10:
		tmp = x + (1.0 / (t_1 / y))
	elif y < 2.894426862792089e-49:
		tmp = x + ((y * (z - t)) / a)
	else:
		tmp = x + (y / t_1)
	return tmp
function code(x, y, z, t, a)
	t_1 = Float64(a / Float64(z - t))
	tmp = 0.0
	if (y < -1.0761266216389975e-10)
		tmp = Float64(x + Float64(1.0 / Float64(t_1 / y)));
	elseif (y < 2.894426862792089e-49)
		tmp = Float64(x + Float64(Float64(y * Float64(z - t)) / a));
	else
		tmp = Float64(x + Float64(y / t_1));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = a / (z - t);
	tmp = 0.0;
	if (y < -1.0761266216389975e-10)
		tmp = x + (1.0 / (t_1 / y));
	elseif (y < 2.894426862792089e-49)
		tmp = x + ((y * (z - t)) / a);
	else
		tmp = x + (y / t_1);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(a / N[(z - t), $MachinePrecision]), $MachinePrecision]}, If[Less[y, -1.0761266216389975e-10], N[(x + N[(1.0 / N[(t$95$1 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Less[y, 2.894426862792089e-49], N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(x + N[(y / t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{a}{z - t}\\
\mathbf{if}\;y < -1.0761266216389975 \cdot 10^{-10}:\\
\;\;\;\;x + \frac{1}{\frac{t\_1}{y}}\\

\mathbf{elif}\;y < 2.894426862792089 \cdot 10^{-49}:\\
\;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a}\\

\mathbf{else}:\\
\;\;\;\;x + \frac{y}{t\_1}\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024135 
(FPCore (x y z t a)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, E"
  :precision binary64

  :alt
  (! :herbie-platform default (if (< y -430450648655599/4000000000000000000000000) (+ x (/ 1 (/ (/ a (- z t)) y))) (if (< y 2894426862792089/10000000000000000000000000000000000000000000000000000000000000000) (+ x (/ (* y (- z t)) a)) (+ x (/ y (/ a (- z t)))))))

  (+ x (/ (* y (- z t)) a)))