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

Percentage Accurate: 93.6% → 97.5%
Time: 8.4s
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.6% 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.5% accurate, 1.0× speedup?

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

\\
x + \frac{y}{a} \cdot \left(z - t\right)
\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/97.5%

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

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

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

Alternative 2: 76.0% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.7 \cdot 10^{+114} \lor \neg \left(t \leq 3.1 \cdot 10^{+91}\right):\\
\;\;\;\;\frac{y}{a} \cdot \left(-t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.7e114 or 3.09999999999999998e91 < t

    1. Initial program 88.8%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x + \frac{y}{a} \cdot \left(-t\right)} \]
      5. *-commutative89.6%

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

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

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

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

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

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

        \[\leadsto -\color{blue}{\frac{y}{a} \cdot t} \]
      3. distribute-lft-neg-out69.8%

        \[\leadsto \color{blue}{\left(-\frac{y}{a}\right) \cdot t} \]
      4. *-commutative69.8%

        \[\leadsto \color{blue}{t \cdot \left(-\frac{y}{a}\right)} \]
      5. distribute-neg-frac69.8%

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

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

    if -1.7e114 < t < 3.09999999999999998e91

    1. Initial program 95.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.7 \cdot 10^{+114} \lor \neg \left(t \leq 3.1 \cdot 10^{+91}\right):\\ \;\;\;\;\frac{y}{a} \cdot \left(-t\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{a}{z}}\\ \end{array} \]

Alternative 3: 77.9% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.3 \cdot 10^{+124} \lor \neg \left(t \leq 6.8 \cdot 10^{+89}\right):\\
\;\;\;\;\frac{y}{a} \cdot \left(-t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -3.30000000000000015e124 or 6.8000000000000004e89 < t

    1. Initial program 88.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\color{blue}{\frac{y}{a} \cdot t} \]
      3. distribute-lft-neg-out70.6%

        \[\leadsto \color{blue}{\left(-\frac{y}{a}\right) \cdot t} \]
      4. *-commutative70.6%

        \[\leadsto \color{blue}{t \cdot \left(-\frac{y}{a}\right)} \]
      5. distribute-neg-frac70.6%

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

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

    if -3.30000000000000015e124 < t < 6.8000000000000004e89

    1. Initial program 95.3%

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

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

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

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

        \[\leadsto \color{blue}{\frac{y}{a} \cdot z} + x \]
      2. *-commutative82.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -3.3 \cdot 10^{+124} \lor \neg \left(t \leq 6.8 \cdot 10^{+89}\right):\\ \;\;\;\;\frac{y}{a} \cdot \left(-t\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{a} \cdot z\\ \end{array} \]

Alternative 4: 85.2% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;z \leq 2.05 \cdot 10^{+49}:\\
\;\;\;\;x - \frac{y}{a} \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.69999999999999992e25

    1. Initial program 88.2%

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

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

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

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

        \[\leadsto \color{blue}{\frac{y}{a} \cdot z} + x \]
      2. *-commutative84.5%

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

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

    if -1.69999999999999992e25 < z < 2.05e49

    1. Initial program 95.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.05e49 < z

    1. Initial program 91.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.7 \cdot 10^{+25}:\\ \;\;\;\;x + \frac{y}{a} \cdot z\\ \mathbf{elif}\;z \leq 2.05 \cdot 10^{+49}:\\ \;\;\;\;x - \frac{y}{a} \cdot t\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{a}{z}}\\ \end{array} \]

Alternative 5: 85.3% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;z \leq 3.4 \cdot 10^{+51}:\\
\;\;\;\;x - \frac{t}{\frac{a}{y}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.9000000000000001e26

    1. Initial program 88.2%

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

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

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

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

        \[\leadsto \color{blue}{\frac{y}{a} \cdot z} + x \]
      2. *-commutative84.5%

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

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

    if -1.9000000000000001e26 < z < 3.39999999999999984e51

    1. Initial program 95.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x - \color{blue}{\frac{t}{\frac{a}{y}}} \]
    9. Simplified90.4%

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

    if 3.39999999999999984e51 < z

    1. Initial program 91.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.9 \cdot 10^{+26}:\\ \;\;\;\;x + \frac{y}{a} \cdot z\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{+51}:\\ \;\;\;\;x - \frac{t}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{a}{z}}\\ \end{array} \]

Alternative 6: 52.1% accurate, 0.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.35e18 or 4.2500000000000003e86 < t

    1. Initial program 89.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\color{blue}{\frac{y}{a} \cdot t} \]
      3. distribute-lft-neg-out65.2%

        \[\leadsto \color{blue}{\left(-\frac{y}{a}\right) \cdot t} \]
      4. *-commutative65.2%

        \[\leadsto \color{blue}{t \cdot \left(-\frac{y}{a}\right)} \]
      5. distribute-neg-frac65.2%

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

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

    if -1.35e18 < t < 4.2500000000000003e86

    1. Initial program 95.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.35 \cdot 10^{+18} \lor \neg \left(t \leq 4.25 \cdot 10^{+86}\right):\\ \;\;\;\;\frac{y}{a} \cdot \left(-t\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 7: 39.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 92.9%

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

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

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

    \[\leadsto \color{blue}{x} \]
  5. Final simplification37.2%

    \[\leadsto x \]

Developer target: 99.3% 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 2023192 
(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)))