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

Percentage Accurate: 93.1% → 97.1%
Time: 7.1s
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.1% 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: 97.1% accurate, 1.0× speedup?

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

\\
x + \frac{z - t}{\frac{a}{y}}
\end{array}
Derivation
  1. Initial program 91.8%

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

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

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

    \[\leadsto \color{blue}{x + \frac{z - t}{\frac{a}{y}}} \]
  4. Add Preprocessing
  5. Final simplification97.0%

    \[\leadsto x + \frac{z - t}{\frac{a}{y}} \]
  6. Add Preprocessing

Alternative 2: 84.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.1 \cdot 10^{+86} \lor \neg \left(z \leq 1.1 \cdot 10^{+46}\right):\\
\;\;\;\;x + z \cdot \frac{y}{a}\\

\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{t}{a}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -4.0999999999999999e86 or 1.1e46 < z

    1. Initial program 91.3%

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

        \[\leadsto x + \color{blue}{\frac{y}{\frac{a}{z - t}}} \]
    3. Simplified91.8%

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

      \[\leadsto x + \frac{y}{\color{blue}{\frac{a}{z}}} \]
    6. Step-by-step derivation
      1. associate-/r/89.4%

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

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

    if -4.0999999999999999e86 < z < 1.1e46

    1. Initial program 92.2%

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{a}, z - t, x\right)} \]
    3. Simplified96.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{a}, z - t, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 85.6%

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

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

        \[\leadsto x + \left(-\color{blue}{\frac{t}{a} \cdot y}\right) \]
      3. unsub-neg88.7%

        \[\leadsto \color{blue}{x - \frac{t}{a} \cdot y} \]
      4. *-commutative88.7%

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

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

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

Alternative 3: 86.2% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.1 \cdot 10^{+86} \lor \neg \left(z \leq 7 \cdot 10^{+41}\right):\\
\;\;\;\;x + z \cdot \frac{y}{a}\\

\mathbf{else}:\\
\;\;\;\;x - t \cdot \frac{y}{a}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -4.0999999999999999e86 or 6.9999999999999998e41 < z

    1. Initial program 91.3%

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

        \[\leadsto x + \color{blue}{\frac{y}{\frac{a}{z - t}}} \]
    3. Simplified91.8%

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

      \[\leadsto x + \frac{y}{\color{blue}{\frac{a}{z}}} \]
    6. Step-by-step derivation
      1. associate-/r/89.4%

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

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

    if -4.0999999999999999e86 < z < 6.9999999999999998e41

    1. Initial program 92.2%

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{a}, z - t, x\right)} \]
    3. Simplified96.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{a}, z - t, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 85.6%

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

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

        \[\leadsto x + \left(-\color{blue}{\frac{t}{a} \cdot y}\right) \]
      3. unsub-neg88.7%

        \[\leadsto \color{blue}{x - \frac{t}{a} \cdot y} \]
      4. *-commutative88.7%

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

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

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

        \[\leadsto x - \color{blue}{\frac{t}{\frac{a}{y}}} \]
    9. Applied egg-rr91.3%

      \[\leadsto x - \color{blue}{\frac{t}{\frac{a}{y}}} \]
    10. Step-by-step derivation
      1. *-un-lft-identity91.3%

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

        \[\leadsto x - \color{blue}{\frac{1}{\frac{a}{y}} \cdot t} \]
      3. clear-num90.7%

        \[\leadsto x - \color{blue}{\frac{y}{a}} \cdot t \]
    11. Applied egg-rr90.7%

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

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

Alternative 4: 86.3% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.7 \cdot 10^{+87} \lor \neg \left(z \leq 8.2 \cdot 10^{+43}\right):\\
\;\;\;\;x + z \cdot \frac{y}{a}\\

\mathbf{else}:\\
\;\;\;\;x - \frac{t}{\frac{a}{y}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.70000000000000007e87 or 8.2000000000000001e43 < z

    1. Initial program 91.3%

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

        \[\leadsto x + \color{blue}{\frac{y}{\frac{a}{z - t}}} \]
    3. Simplified91.8%

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

      \[\leadsto x + \frac{y}{\color{blue}{\frac{a}{z}}} \]
    6. Step-by-step derivation
      1. associate-/r/89.4%

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

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

    if -2.70000000000000007e87 < z < 8.2000000000000001e43

    1. Initial program 92.2%

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{a}, z - t, x\right)} \]
    3. Simplified96.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{a}, z - t, x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 85.6%

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

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

        \[\leadsto x + \left(-\color{blue}{\frac{t}{a} \cdot y}\right) \]
      3. unsub-neg88.7%

        \[\leadsto \color{blue}{x - \frac{t}{a} \cdot y} \]
      4. *-commutative88.7%

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

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

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

        \[\leadsto x - \color{blue}{\frac{t}{\frac{a}{y}}} \]
    9. Applied egg-rr91.3%

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

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

Alternative 5: 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 91.8%

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

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

    \[\leadsto \color{blue}{x + \frac{y}{\frac{a}{z - t}}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. associate-/r/96.6%

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

    \[\leadsto x + \color{blue}{\frac{y}{a} \cdot \left(z - t\right)} \]
  7. Final simplification96.6%

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

Alternative 6: 71.3% accurate, 1.3× speedup?

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

\\
x + z \cdot \frac{y}{a}
\end{array}
Derivation
  1. Initial program 91.8%

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

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

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

    \[\leadsto x + \frac{y}{\color{blue}{\frac{a}{z}}} \]
  6. Step-by-step derivation
    1. associate-/r/66.6%

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

    \[\leadsto x + \color{blue}{\frac{y}{a} \cdot z} \]
  8. Final simplification66.6%

    \[\leadsto x + z \cdot \frac{y}{a} \]
  9. Add Preprocessing

Alternative 7: 40.0% 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 91.8%

    \[x + \frac{y \cdot \left(z - t\right)}{a} \]
  2. Step-by-step derivation
    1. +-commutative91.8%

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

      \[\leadsto \color{blue}{\frac{y}{a} \cdot \left(z - t\right)} + x \]
    3. fma-def96.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{a}, z - t, x\right)} \]
  3. Simplified96.6%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{a}, z - t, x\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in y around 0 34.8%

    \[\leadsto \color{blue}{x} \]
  6. Final simplification34.8%

    \[\leadsto x \]
  7. Add Preprocessing

Developer target: 99.2% accurate, 0.7× 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 2024011 
(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)))