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

Percentage Accurate: 93.2% → 97.6%
Time: 9.1s
Alternatives: 8
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 8 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.2% 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.6% accurate, 0.6× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;x + \frac{y}{a} \cdot \left(t - z\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.9999999999999999e-67

    1. Initial program 84.6%

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

        \[\leadsto x - \color{blue}{\frac{y}{\frac{a}{z - t}}} \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{x - \frac{y}{\frac{a}{z - t}}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num99.8%

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

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

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

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

    if -4.9999999999999999e-67 < y

    1. Initial program 95.2%

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

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

      \[\leadsto \color{blue}{x - \frac{y}{a} \cdot \left(z - t\right)} \]
    4. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Final simplification99.0%

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

Alternative 2: 83.9% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.2 \cdot 10^{+96} \lor \neg \left(t \leq 5.1 \cdot 10^{+61}\right):\\
\;\;\;\;x + y \cdot \frac{t}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -3.20000000000000006e96 or 5.1000000000000001e61 < t

    1. Initial program 90.9%

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

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

      \[\leadsto \color{blue}{x - \frac{y}{\frac{a}{z - t}}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num93.2%

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

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

        \[\leadsto x - \color{blue}{\frac{z - t}{a}} \cdot y \]
    6. Applied egg-rr92.0%

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

      \[\leadsto x - \color{blue}{\left(-1 \cdot \frac{t}{a}\right)} \cdot y \]
    8. Step-by-step derivation
      1. neg-mul-183.8%

        \[\leadsto x - \color{blue}{\left(-\frac{t}{a}\right)} \cdot y \]
    9. Simplified83.8%

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

    if -3.20000000000000006e96 < t < 5.1000000000000001e61

    1. Initial program 92.8%

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

        \[\leadsto x - \color{blue}{\frac{y}{a} \cdot \left(z - t\right)} \]
    3. Simplified96.9%

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

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

        \[\leadsto x - \color{blue}{\frac{y}{a} \cdot z} \]
      2. *-commutative92.0%

        \[\leadsto x - \color{blue}{z \cdot \frac{y}{a}} \]
    7. Simplified92.0%

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

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

Alternative 3: 86.2% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.8 \cdot 10^{+96} \lor \neg \left(t \leq 6.2 \cdot 10^{+60}\right):\\
\;\;\;\;x + t \cdot \frac{y}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -2.8e96 or 6.2000000000000001e60 < t

    1. Initial program 90.9%

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

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

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

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

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

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

        \[\leadsto x - \color{blue}{\left(-\frac{y}{a} \cdot t\right)} \]
      4. distribute-rgt-neg-out87.7%

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

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

    if -2.8e96 < t < 6.2000000000000001e60

    1. Initial program 92.8%

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

        \[\leadsto x - \color{blue}{\frac{y}{a} \cdot \left(z - t\right)} \]
    3. Simplified96.9%

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

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

        \[\leadsto x - \color{blue}{\frac{y}{a} \cdot z} \]
      2. *-commutative92.0%

        \[\leadsto x - \color{blue}{z \cdot \frac{y}{a}} \]
    7. Simplified92.0%

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

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

Alternative 4: 97.1% accurate, 1.0× speedup?

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

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

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

      \[\leadsto x - \color{blue}{\frac{y}{a} \cdot \left(z - t\right)} \]
  3. Simplified97.2%

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

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

Alternative 5: 40.1% accurate, 1.3× speedup?

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

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

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

      \[\leadsto x - \color{blue}{\frac{y}{a} \cdot \left(z - t\right)} \]
  3. Simplified97.2%

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

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

      \[\leadsto x - \color{blue}{\frac{y}{a} \cdot z} \]
    2. *-commutative75.6%

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

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

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

      \[\leadsto x - \color{blue}{\frac{z \cdot \left(-y\right)}{-a}} \]
    3. add-sqr-sqrt34.6%

      \[\leadsto x - \frac{z \cdot \left(-y\right)}{\color{blue}{\sqrt{-a} \cdot \sqrt{-a}}} \]
    4. sqrt-unprod52.5%

      \[\leadsto x - \frac{z \cdot \left(-y\right)}{\color{blue}{\sqrt{\left(-a\right) \cdot \left(-a\right)}}} \]
    5. sqr-neg52.5%

      \[\leadsto x - \frac{z \cdot \left(-y\right)}{\sqrt{\color{blue}{a \cdot a}}} \]
    6. sqrt-unprod22.7%

      \[\leadsto x - \frac{z \cdot \left(-y\right)}{\color{blue}{\sqrt{a} \cdot \sqrt{a}}} \]
    7. add-sqr-sqrt41.4%

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

    \[\leadsto x - \color{blue}{\frac{z \cdot \left(-y\right)}{a}} \]
  10. Step-by-step derivation
    1. associate-/l*42.1%

      \[\leadsto x - \color{blue}{\frac{z}{\frac{a}{-y}}} \]
  11. Simplified42.1%

    \[\leadsto x - \color{blue}{\frac{z}{\frac{a}{-y}}} \]
  12. Taylor expanded in x around 0 41.4%

    \[\leadsto \color{blue}{x + \frac{y \cdot z}{a}} \]
  13. Step-by-step derivation
    1. +-commutative41.4%

      \[\leadsto \color{blue}{\frac{y \cdot z}{a} + x} \]
    2. associate-*r/40.6%

      \[\leadsto \color{blue}{y \cdot \frac{z}{a}} + x \]
  14. Simplified40.6%

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

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

Alternative 6: 40.1% accurate, 1.3× speedup?

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

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

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

      \[\leadsto x - \color{blue}{\frac{y}{a} \cdot \left(z - t\right)} \]
  3. Simplified97.2%

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

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

      \[\leadsto x - \color{blue}{\frac{y}{a} \cdot z} \]
    2. *-commutative75.6%

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

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

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

      \[\leadsto x - \color{blue}{\frac{z \cdot \left(-y\right)}{-a}} \]
    3. add-sqr-sqrt34.6%

      \[\leadsto x - \frac{z \cdot \left(-y\right)}{\color{blue}{\sqrt{-a} \cdot \sqrt{-a}}} \]
    4. sqrt-unprod52.5%

      \[\leadsto x - \frac{z \cdot \left(-y\right)}{\color{blue}{\sqrt{\left(-a\right) \cdot \left(-a\right)}}} \]
    5. sqr-neg52.5%

      \[\leadsto x - \frac{z \cdot \left(-y\right)}{\sqrt{\color{blue}{a \cdot a}}} \]
    6. sqrt-unprod22.7%

      \[\leadsto x - \frac{z \cdot \left(-y\right)}{\color{blue}{\sqrt{a} \cdot \sqrt{a}}} \]
    7. add-sqr-sqrt41.4%

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

    \[\leadsto x - \color{blue}{\frac{z \cdot \left(-y\right)}{a}} \]
  10. Step-by-step derivation
    1. associate-/l*42.1%

      \[\leadsto x - \color{blue}{\frac{z}{\frac{a}{-y}}} \]
  11. Simplified42.1%

    \[\leadsto x - \color{blue}{\frac{z}{\frac{a}{-y}}} \]
  12. Step-by-step derivation
    1. sub-neg42.1%

      \[\leadsto \color{blue}{x + \left(-\frac{z}{\frac{a}{-y}}\right)} \]
    2. associate-/r/40.6%

      \[\leadsto x + \left(-\color{blue}{\frac{z}{a} \cdot \left(-y\right)}\right) \]
    3. *-un-lft-identity40.6%

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

      \[\leadsto x + \left(-\color{blue}{\left(\frac{1}{a} \cdot z\right)} \cdot \left(-y\right)\right) \]
    5. distribute-rgt-neg-in40.6%

      \[\leadsto x + \color{blue}{\left(\frac{1}{a} \cdot z\right) \cdot \left(-\left(-y\right)\right)} \]
    6. remove-double-neg40.6%

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

      \[\leadsto x + \color{blue}{y \cdot \left(\frac{1}{a} \cdot z\right)} \]
    8. associate-*r*42.1%

      \[\leadsto x + \color{blue}{\left(y \cdot \frac{1}{a}\right) \cdot z} \]
    9. div-inv42.1%

      \[\leadsto x + \color{blue}{\frac{y}{a}} \cdot z \]
    10. associate-/r/40.9%

      \[\leadsto x + \color{blue}{\frac{y}{\frac{a}{z}}} \]
    11. +-commutative40.9%

      \[\leadsto \color{blue}{\frac{y}{\frac{a}{z}} + x} \]
    12. associate-/r/42.1%

      \[\leadsto \color{blue}{\frac{y}{a} \cdot z} + x \]
    13. associate-*l/41.4%

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

    \[\leadsto \color{blue}{\frac{y \cdot z}{a} + x} \]
  14. Final simplification41.4%

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

Alternative 7: 71.1% 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 92.1%

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

      \[\leadsto x - \color{blue}{\frac{y}{a} \cdot \left(z - t\right)} \]
  3. Simplified97.2%

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

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

      \[\leadsto x - \color{blue}{\frac{y}{a} \cdot z} \]
    2. *-commutative75.6%

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

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

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

Alternative 8: 39.2% 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 92.1%

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

      \[\leadsto x - \color{blue}{\frac{y}{a} \cdot \left(z - t\right)} \]
  3. Simplified97.2%

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

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

      \[\leadsto x - \color{blue}{\frac{y}{a} \cdot z} \]
    2. *-commutative75.6%

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

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

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

      \[\leadsto x - \color{blue}{\frac{z \cdot \left(-y\right)}{-a}} \]
    3. add-sqr-sqrt34.6%

      \[\leadsto x - \frac{z \cdot \left(-y\right)}{\color{blue}{\sqrt{-a} \cdot \sqrt{-a}}} \]
    4. sqrt-unprod52.5%

      \[\leadsto x - \frac{z \cdot \left(-y\right)}{\color{blue}{\sqrt{\left(-a\right) \cdot \left(-a\right)}}} \]
    5. sqr-neg52.5%

      \[\leadsto x - \frac{z \cdot \left(-y\right)}{\sqrt{\color{blue}{a \cdot a}}} \]
    6. sqrt-unprod22.7%

      \[\leadsto x - \frac{z \cdot \left(-y\right)}{\color{blue}{\sqrt{a} \cdot \sqrt{a}}} \]
    7. add-sqr-sqrt41.4%

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

    \[\leadsto x - \color{blue}{\frac{z \cdot \left(-y\right)}{a}} \]
  10. Step-by-step derivation
    1. associate-/l*42.1%

      \[\leadsto x - \color{blue}{\frac{z}{\frac{a}{-y}}} \]
  11. Simplified42.1%

    \[\leadsto x - \color{blue}{\frac{z}{\frac{a}{-y}}} \]
  12. Taylor expanded in x around inf 40.2%

    \[\leadsto \color{blue}{x} \]
  13. Final simplification40.2%

    \[\leadsto x \]
  14. Add Preprocessing

Developer target: 99.1% 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 2024026 
(FPCore (x y z t a)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, F"
  :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)))