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

Percentage Accurate: 93.3% → 97.4%
Time: 10.6s
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.3% 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.4% 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 92.9%

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

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

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

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

Alternative 2: 49.1% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_1 := t \cdot \frac{y}{-a}\\
\mathbf{if}\;t \leq -3.3 \cdot 10^{+45}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t \leq 4.6 \cdot 10^{-234}:\\
\;\;\;\;x\\

\mathbf{elif}\;t \leq 1.05 \cdot 10^{+100}:\\
\;\;\;\;z \cdot \frac{y}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < -3.3000000000000001e45 or 1.0499999999999999e100 < t

    1. Initial program 90.6%

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

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

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

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

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

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

        \[\leadsto x + \left(-\color{blue}{t \cdot \frac{y}{a}}\right) \]
      3. distribute-lft-neg-in89.5%

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

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

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

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

        \[\leadsto \color{blue}{-\frac{t \cdot y}{a}} \]
      2. distribute-frac-neg261.2%

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

        \[\leadsto \color{blue}{t \cdot \frac{y}{-a}} \]
    10. Simplified64.9%

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

    if -3.3000000000000001e45 < t < 4.59999999999999981e-234

    1. Initial program 95.0%

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

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

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

      \[\leadsto \color{blue}{x} \]

    if 4.59999999999999981e-234 < t < 1.0499999999999999e100

    1. Initial program 93.9%

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

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

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

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

      \[\leadsto \frac{\color{blue}{y \cdot z}}{a} \]
    7. Step-by-step derivation
      1. *-commutative47.1%

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

        \[\leadsto \color{blue}{z \cdot \frac{y}{a}} \]
    8. Applied egg-rr53.0%

      \[\leadsto \color{blue}{z \cdot \frac{y}{a}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 84.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -6.6 \cdot 10^{-58} \lor \neg \left(t \leq 2 \cdot 10^{+100}\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 -6.6e-58) (not (<= t 2e+100)))
   (- x (* t (/ y a)))
   (+ x (* z (/ y a)))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((t <= -6.6e-58) || !(t <= 2e+100)) {
		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 <= (-6.6d-58)) .or. (.not. (t <= 2d+100))) 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 <= -6.6e-58) || !(t <= 2e+100)) {
		tmp = x - (t * (y / a));
	} else {
		tmp = x + (z * (y / a));
	}
	return tmp;
}
def code(x, y, z, t, a):
	tmp = 0
	if (t <= -6.6e-58) or not (t <= 2e+100):
		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 <= -6.6e-58) || !(t <= 2e+100))
		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 <= -6.6e-58) || ~((t <= 2e+100)))
		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, -6.6e-58], N[Not[LessEqual[t, 2e+100]], $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 -6.6 \cdot 10^{-58} \lor \neg \left(t \leq 2 \cdot 10^{+100}\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 < -6.60000000000000052e-58 or 2.00000000000000003e100 < t

    1. Initial program 91.2%

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

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

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

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

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

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

        \[\leadsto x + \left(-\color{blue}{t \cdot \frac{y}{a}}\right) \]
      3. distribute-lft-neg-in90.2%

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

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

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

    if -6.60000000000000052e-58 < t < 2.00000000000000003e100

    1. Initial program 94.5%

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

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

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

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

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

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

Alternative 4: 76.4% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -1.22 \cdot 10^{+56} \lor \neg \left(t \leq 1.65 \cdot 10^{+114}\right):\\ \;\;\;\;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.22e+56) (not (<= t 1.65e+114)))
   (* t (/ y (- a)))
   (+ x (/ z (/ a y)))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((t <= -1.22e+56) || !(t <= 1.65e+114)) {
		tmp = 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.22d+56)) .or. (.not. (t <= 1.65d+114))) then
        tmp = 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.22e+56) || !(t <= 1.65e+114)) {
		tmp = t * (y / -a);
	} else {
		tmp = x + (z / (a / y));
	}
	return tmp;
}
def code(x, y, z, t, a):
	tmp = 0
	if (t <= -1.22e+56) or not (t <= 1.65e+114):
		tmp = t * (y / -a)
	else:
		tmp = x + (z / (a / y))
	return tmp
function code(x, y, z, t, a)
	tmp = 0.0
	if ((t <= -1.22e+56) || !(t <= 1.65e+114))
		tmp = Float64(t * Float64(y / Float64(-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.22e+56) || ~((t <= 1.65e+114)))
		tmp = 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.22e+56], N[Not[LessEqual[t, 1.65e+114]], $MachinePrecision]], N[(t * N[(y / (-a)), $MachinePrecision]), $MachinePrecision], N[(x + N[(z / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.22 \cdot 10^{+56} \lor \neg \left(t \leq 1.65 \cdot 10^{+114}\right):\\
\;\;\;\;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.22e56 or 1.65e114 < t

    1. Initial program 89.8%

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

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

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

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

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

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

        \[\leadsto x + \left(-\color{blue}{t \cdot \frac{y}{a}}\right) \]
      3. distribute-lft-neg-in91.6%

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

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

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

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

        \[\leadsto \color{blue}{-\frac{t \cdot y}{a}} \]
      2. distribute-frac-neg264.0%

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

        \[\leadsto \color{blue}{t \cdot \frac{y}{-a}} \]
    10. Simplified68.0%

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

    if -1.22e56 < t < 1.65e114

    1. Initial program 94.7%

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

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

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

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

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

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

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

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

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

Alternative 5: 76.4% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -2.7 \cdot 10^{+57} \lor \neg \left(t \leq 1.4 \cdot 10^{+114}\right):\\ \;\;\;\;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.7e+57) (not (<= t 1.4e+114)))
   (* t (/ y (- a)))
   (+ x (* z (/ y a)))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((t <= -2.7e+57) || !(t <= 1.4e+114)) {
		tmp = 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.7d+57)) .or. (.not. (t <= 1.4d+114))) then
        tmp = 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.7e+57) || !(t <= 1.4e+114)) {
		tmp = t * (y / -a);
	} else {
		tmp = x + (z * (y / a));
	}
	return tmp;
}
def code(x, y, z, t, a):
	tmp = 0
	if (t <= -2.7e+57) or not (t <= 1.4e+114):
		tmp = t * (y / -a)
	else:
		tmp = x + (z * (y / a))
	return tmp
function code(x, y, z, t, a)
	tmp = 0.0
	if ((t <= -2.7e+57) || !(t <= 1.4e+114))
		tmp = Float64(t * Float64(y / Float64(-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.7e+57) || ~((t <= 1.4e+114)))
		tmp = 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.7e+57], N[Not[LessEqual[t, 1.4e+114]], $MachinePrecision]], N[(t * N[(y / (-a)), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.7 \cdot 10^{+57} \lor \neg \left(t \leq 1.4 \cdot 10^{+114}\right):\\
\;\;\;\;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.6999999999999998e57 or 1.4e114 < t

    1. Initial program 89.8%

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

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

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

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

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

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

        \[\leadsto x + \left(-\color{blue}{t \cdot \frac{y}{a}}\right) \]
      3. distribute-lft-neg-in91.6%

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

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

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

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

        \[\leadsto \color{blue}{-\frac{t \cdot y}{a}} \]
      2. distribute-frac-neg264.0%

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

        \[\leadsto \color{blue}{t \cdot \frac{y}{-a}} \]
    10. Simplified68.0%

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

    if -2.6999999999999998e57 < t < 1.4e114

    1. Initial program 94.7%

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

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

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

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

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

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

Alternative 6: 52.0% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.8 \cdot 10^{+62} \lor \neg \left(z \leq 115000\right):\\
\;\;\;\;z \cdot \frac{y}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.80000000000000014e62 or 115000 < z

    1. Initial program 88.1%

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

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

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

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

      \[\leadsto \frac{\color{blue}{y \cdot z}}{a} \]
    7. Step-by-step derivation
      1. *-commutative54.6%

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

        \[\leadsto \color{blue}{z \cdot \frac{y}{a}} \]
    8. Applied egg-rr61.7%

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

    if -2.80000000000000014e62 < z < 115000

    1. Initial program 96.2%

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

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

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

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

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

Alternative 7: 92.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + y \cdot \frac{z - t}{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(y * Float64(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[(y * N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

    \[\leadsto \color{blue}{x + y \cdot \frac{z - t}{a}} \]
  4. Add Preprocessing
  5. 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.9%

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

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

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

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

Developer Target 1: 99.3% 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 2024163 
(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)))