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

Percentage Accurate: 92.6% → 96.0%
Time: 13.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: 92.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: 96.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := y \cdot \left(z - t\right)\\ \mathbf{if}\;t\_1 \leq -\infty:\\ \;\;\;\;\frac{y}{\frac{a}{z - t}} + x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{t\_1}{a}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (* y (- z t))))
   (if (<= t_1 (- INFINITY)) (+ (/ y (/ a (- z t))) x) (+ x (/ t_1 a)))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = y * (z - t);
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = (y / (a / (z - t))) + x;
	} else {
		tmp = x + (t_1 / a);
	}
	return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = y * (z - t);
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = (y / (a / (z - t))) + x;
	} else {
		tmp = x + (t_1 / a);
	}
	return tmp;
}
def code(x, y, z, t, a):
	t_1 = y * (z - t)
	tmp = 0
	if t_1 <= -math.inf:
		tmp = (y / (a / (z - t))) + x
	else:
		tmp = x + (t_1 / a)
	return tmp
function code(x, y, z, t, a)
	t_1 = Float64(y * Float64(z - t))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(Float64(y / Float64(a / Float64(z - t))) + x);
	else
		tmp = Float64(x + Float64(t_1 / a));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = y * (z - t);
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = (y / (a / (z - t))) + x;
	else
		tmp = x + (t_1 / a);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(y / N[(a / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(t$95$1 / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := y \cdot \left(z - t\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\frac{y}{\frac{a}{z - t}} + x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 y (-.f64 z t)) < -inf.0

    1. Initial program 60.0%

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

        \[\leadsto \frac{y \cdot \left(z - t\right)}{a} + \color{blue}{x} \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\left(\frac{y \cdot \left(z - t\right)}{a}\right), \color{blue}{x}\right) \]
      3. associate-/l*N/A

        \[\leadsto \mathsf{+.f64}\left(\left(y \cdot \frac{z - t}{a}\right), x\right) \]
      4. clear-numN/A

        \[\leadsto \mathsf{+.f64}\left(\left(y \cdot \frac{1}{\frac{a}{z - t}}\right), x\right) \]
      5. un-div-invN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\frac{y}{\frac{a}{z - t}}\right), x\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{/.f64}\left(y, \left(\frac{a}{z - t}\right)\right), x\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{/.f64}\left(y, \mathsf{/.f64}\left(a, \left(z - t\right)\right)\right), x\right) \]
      8. --lowering--.f6499.9%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{/.f64}\left(y, \mathsf{/.f64}\left(a, \mathsf{\_.f64}\left(z, t\right)\right)\right), x\right) \]
    4. Applied egg-rr99.9%

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

    if -inf.0 < (*.f64 y (-.f64 z t))

    1. Initial program 98.2%

      \[x + \frac{y \cdot \left(z - t\right)}{a} \]
    2. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 96.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := y \cdot \left(z - t\right)\\ \mathbf{if}\;t\_1 \leq -\infty:\\ \;\;\;\;x + y \cdot \frac{z - t}{a}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{t\_1}{a}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (* y (- z t))))
   (if (<= t_1 (- INFINITY)) (+ x (* y (/ (- z t) a))) (+ x (/ t_1 a)))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = y * (z - t);
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = x + (y * ((z - t) / a));
	} else {
		tmp = x + (t_1 / a);
	}
	return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = y * (z - t);
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = x + (y * ((z - t) / a));
	} else {
		tmp = x + (t_1 / a);
	}
	return tmp;
}
def code(x, y, z, t, a):
	t_1 = y * (z - t)
	tmp = 0
	if t_1 <= -math.inf:
		tmp = x + (y * ((z - t) / a))
	else:
		tmp = x + (t_1 / a)
	return tmp
function code(x, y, z, t, a)
	t_1 = Float64(y * Float64(z - t))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(x + Float64(y * Float64(Float64(z - t) / a)));
	else
		tmp = Float64(x + Float64(t_1 / a));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = y * (z - t);
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = x + (y * ((z - t) / a));
	else
		tmp = x + (t_1 / a);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(t$95$1 / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := y \cdot \left(z - t\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;x + y \cdot \frac{z - t}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 y (-.f64 z t)) < -inf.0

    1. Initial program 60.0%

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

        \[\leadsto \mathsf{+.f64}\left(x, \left(y \cdot \color{blue}{\frac{z - t}{a}}\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(x, \left(\frac{z - t}{a} \cdot \color{blue}{y}\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(\left(\frac{z - t}{a}\right), \color{blue}{y}\right)\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(z - t\right), a\right), y\right)\right) \]
      5. --lowering--.f6499.8%

        \[\leadsto \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(z, t\right), a\right), y\right)\right) \]
    4. Applied egg-rr99.8%

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

    if -inf.0 < (*.f64 y (-.f64 z t))

    1. Initial program 98.2%

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

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

Alternative 3: 85.9% accurate, 0.5× speedup?

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

    1. Initial program 94.4%

      \[x + \frac{y \cdot \left(z - t\right)}{a} \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0

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

        \[\leadsto x + \left(\mathsf{neg}\left(\frac{t \cdot y}{a}\right)\right) \]
      2. unsub-negN/A

        \[\leadsto x - \color{blue}{\frac{t \cdot y}{a}} \]
      3. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(x, \color{blue}{\left(\frac{t \cdot y}{a}\right)}\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\left(t \cdot y\right), \color{blue}{a}\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\left(y \cdot t\right), a\right)\right) \]
      6. *-lowering-*.f6488.2%

        \[\leadsto \mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\mathsf{*.f64}\left(y, t\right), a\right)\right) \]
    5. Simplified88.2%

      \[\leadsto \color{blue}{x - \frac{y \cdot t}{a}} \]
    6. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(x, \color{blue}{\left(\frac{y \cdot t}{a}\right)}\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(x, \left(\frac{t \cdot y}{a}\right)\right) \]
      3. associate-/l*N/A

        \[\leadsto \mathsf{\_.f64}\left(x, \left(t \cdot \color{blue}{\frac{y}{a}}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(x, \mathsf{*.f64}\left(t, \color{blue}{\left(\frac{y}{a}\right)}\right)\right) \]
      5. /-lowering-/.f6490.3%

        \[\leadsto \mathsf{\_.f64}\left(x, \mathsf{*.f64}\left(t, \mathsf{/.f64}\left(y, \color{blue}{a}\right)\right)\right) \]
    7. Applied egg-rr90.3%

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

    if -1.6999999999999999e-22 < t < 8.1e73

    1. Initial program 94.3%

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

        \[\leadsto \mathsf{+.f64}\left(x, \left(\frac{\left(z - t\right) \cdot y}{a}\right)\right) \]
      2. associate-/l*N/A

        \[\leadsto \mathsf{+.f64}\left(x, \left(\left(z - t\right) \cdot \color{blue}{\frac{y}{a}}\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(x, \left(\frac{y}{a} \cdot \color{blue}{\left(z - t\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(\left(\frac{y}{a}\right), \color{blue}{\left(z - t\right)}\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(\mathsf{/.f64}\left(y, a\right), \left(\color{blue}{z} - t\right)\right)\right) \]
      6. --lowering--.f6496.7%

        \[\leadsto \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(\mathsf{/.f64}\left(y, a\right), \mathsf{\_.f64}\left(z, \color{blue}{t}\right)\right)\right) \]
    4. Applied egg-rr96.7%

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

      \[\leadsto \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(\mathsf{/.f64}\left(y, a\right), \color{blue}{z}\right)\right) \]
    6. Step-by-step derivation
      1. Simplified91.5%

        \[\leadsto x + \frac{y}{a} \cdot \color{blue}{z} \]
    7. Recombined 2 regimes into one program.
    8. Final simplification91.0%

      \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.7 \cdot 10^{-22} \lor \neg \left(t \leq 8.1 \cdot 10^{+73}\right):\\ \;\;\;\;x - t \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \frac{y}{a}\\ \end{array} \]
    9. Add Preprocessing

    Alternative 4: 52.6% accurate, 0.6× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.3 \cdot 10^{+23} \lor \neg \left(z \leq 1.8 \cdot 10^{+55}\right):\\ \;\;\;\;z \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
    (FPCore (x y z t a)
     :precision binary64
     (if (or (<= z -1.3e+23) (not (<= z 1.8e+55))) (* z (/ y a)) x))
    double code(double x, double y, double z, double t, double a) {
    	double tmp;
    	if ((z <= -1.3e+23) || !(z <= 1.8e+55)) {
    		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 <= (-1.3d+23)) .or. (.not. (z <= 1.8d+55))) 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 <= -1.3e+23) || !(z <= 1.8e+55)) {
    		tmp = z * (y / a);
    	} else {
    		tmp = x;
    	}
    	return tmp;
    }
    
    def code(x, y, z, t, a):
    	tmp = 0
    	if (z <= -1.3e+23) or not (z <= 1.8e+55):
    		tmp = z * (y / a)
    	else:
    		tmp = x
    	return tmp
    
    function code(x, y, z, t, a)
    	tmp = 0.0
    	if ((z <= -1.3e+23) || !(z <= 1.8e+55))
    		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 <= -1.3e+23) || ~((z <= 1.8e+55)))
    		tmp = z * (y / a);
    	else
    		tmp = x;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.3e+23], N[Not[LessEqual[z, 1.8e+55]], $MachinePrecision]], N[(z * N[(y / a), $MachinePrecision]), $MachinePrecision], x]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;z \leq -1.3 \cdot 10^{+23} \lor \neg \left(z \leq 1.8 \cdot 10^{+55}\right):\\
    \;\;\;\;z \cdot \frac{y}{a}\\
    
    \mathbf{else}:\\
    \;\;\;\;x\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if z < -1.29999999999999996e23 or 1.79999999999999994e55 < z

      1. Initial program 91.2%

        \[x + \frac{y \cdot \left(z - t\right)}{a} \]
      2. Add Preprocessing
      3. Taylor expanded in z around inf

        \[\leadsto \color{blue}{\frac{y \cdot z}{a}} \]
      4. Step-by-step derivation
        1. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\left(y \cdot z\right), \color{blue}{a}\right) \]
        2. *-lowering-*.f6462.5%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(y, z\right), a\right) \]
      5. Simplified62.5%

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

          \[\leadsto \frac{y}{a} \cdot \color{blue}{z} \]
        2. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\left(\frac{y}{a}\right), \color{blue}{z}\right) \]
        3. /-lowering-/.f6465.2%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(y, a\right), z\right) \]
      7. Applied egg-rr65.2%

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

      if -1.29999999999999996e23 < z < 1.79999999999999994e55

      1. Initial program 97.1%

        \[x + \frac{y \cdot \left(z - t\right)}{a} \]
      2. Add Preprocessing
      3. Taylor expanded in x around inf

        \[\leadsto \color{blue}{x} \]
      4. Step-by-step derivation
        1. Simplified52.3%

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

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

      Alternative 5: 52.6% accurate, 0.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -4 \cdot 10^{+26}:\\ \;\;\;\;\frac{z}{\frac{a}{y}}\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{+55}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{y}{a}\\ \end{array} \end{array} \]
      (FPCore (x y z t a)
       :precision binary64
       (if (<= z -4e+26) (/ z (/ a y)) (if (<= z 4.1e+55) x (* z (/ y a)))))
      double code(double x, double y, double z, double t, double a) {
      	double tmp;
      	if (z <= -4e+26) {
      		tmp = z / (a / y);
      	} else if (z <= 4.1e+55) {
      		tmp = x;
      	} else {
      		tmp = 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 (z <= (-4d+26)) then
              tmp = z / (a / y)
          else if (z <= 4.1d+55) then
              tmp = x
          else
              tmp = 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 (z <= -4e+26) {
      		tmp = z / (a / y);
      	} else if (z <= 4.1e+55) {
      		tmp = x;
      	} else {
      		tmp = z * (y / a);
      	}
      	return tmp;
      }
      
      def code(x, y, z, t, a):
      	tmp = 0
      	if z <= -4e+26:
      		tmp = z / (a / y)
      	elif z <= 4.1e+55:
      		tmp = x
      	else:
      		tmp = z * (y / a)
      	return tmp
      
      function code(x, y, z, t, a)
      	tmp = 0.0
      	if (z <= -4e+26)
      		tmp = Float64(z / Float64(a / y));
      	elseif (z <= 4.1e+55)
      		tmp = x;
      	else
      		tmp = Float64(z * Float64(y / a));
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z, t, a)
      	tmp = 0.0;
      	if (z <= -4e+26)
      		tmp = z / (a / y);
      	elseif (z <= 4.1e+55)
      		tmp = x;
      	else
      		tmp = z * (y / a);
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_, t_, a_] := If[LessEqual[z, -4e+26], N[(z / N[(a / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4.1e+55], x, N[(z * N[(y / a), $MachinePrecision]), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;z \leq -4 \cdot 10^{+26}:\\
      \;\;\;\;\frac{z}{\frac{a}{y}}\\
      
      \mathbf{elif}\;z \leq 4.1 \cdot 10^{+55}:\\
      \;\;\;\;x\\
      
      \mathbf{else}:\\
      \;\;\;\;z \cdot \frac{y}{a}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if z < -4.00000000000000019e26

        1. Initial program 88.5%

          \[x + \frac{y \cdot \left(z - t\right)}{a} \]
        2. Add Preprocessing
        3. Taylor expanded in z around inf

          \[\leadsto \color{blue}{\frac{y \cdot z}{a}} \]
        4. Step-by-step derivation
          1. /-lowering-/.f64N/A

            \[\leadsto \mathsf{/.f64}\left(\left(y \cdot z\right), \color{blue}{a}\right) \]
          2. *-lowering-*.f6457.6%

            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(y, z\right), a\right) \]
        5. Simplified57.6%

          \[\leadsto \color{blue}{\frac{y \cdot z}{a}} \]
        6. Step-by-step derivation
          1. clear-numN/A

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

            \[\leadsto \frac{1}{\frac{\frac{a}{y}}{\color{blue}{z}}} \]
          3. clear-numN/A

            \[\leadsto \frac{z}{\color{blue}{\frac{a}{y}}} \]
          4. /-lowering-/.f64N/A

            \[\leadsto \mathsf{/.f64}\left(z, \color{blue}{\left(\frac{a}{y}\right)}\right) \]
          5. /-lowering-/.f6461.7%

            \[\leadsto \mathsf{/.f64}\left(z, \mathsf{/.f64}\left(a, \color{blue}{y}\right)\right) \]
        7. Applied egg-rr61.7%

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

        if -4.00000000000000019e26 < z < 4.09999999999999981e55

        1. Initial program 97.1%

          \[x + \frac{y \cdot \left(z - t\right)}{a} \]
        2. Add Preprocessing
        3. Taylor expanded in x around inf

          \[\leadsto \color{blue}{x} \]
        4. Step-by-step derivation
          1. Simplified52.3%

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

          if 4.09999999999999981e55 < z

          1. Initial program 94.5%

            \[x + \frac{y \cdot \left(z - t\right)}{a} \]
          2. Add Preprocessing
          3. Taylor expanded in z around inf

            \[\leadsto \color{blue}{\frac{y \cdot z}{a}} \]
          4. Step-by-step derivation
            1. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\left(y \cdot z\right), \color{blue}{a}\right) \]
            2. *-lowering-*.f6468.5%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(y, z\right), a\right) \]
          5. Simplified68.5%

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

              \[\leadsto \frac{y}{a} \cdot \color{blue}{z} \]
            2. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\left(\frac{y}{a}\right), \color{blue}{z}\right) \]
            3. /-lowering-/.f6469.4%

              \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(y, a\right), z\right) \]
          7. Applied egg-rr69.4%

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4 \cdot 10^{+26}:\\ \;\;\;\;\frac{z}{\frac{a}{y}}\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{+55}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{y}{a}\\ \end{array} \]
        7. Add Preprocessing

        Alternative 6: 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 94.3%

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

            \[\leadsto \mathsf{+.f64}\left(x, \left(\frac{\left(z - t\right) \cdot y}{a}\right)\right) \]
          2. associate-/l*N/A

            \[\leadsto \mathsf{+.f64}\left(x, \left(\left(z - t\right) \cdot \color{blue}{\frac{y}{a}}\right)\right) \]
          3. *-commutativeN/A

            \[\leadsto \mathsf{+.f64}\left(x, \left(\frac{y}{a} \cdot \color{blue}{\left(z - t\right)}\right)\right) \]
          4. *-lowering-*.f64N/A

            \[\leadsto \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(\left(\frac{y}{a}\right), \color{blue}{\left(z - t\right)}\right)\right) \]
          5. /-lowering-/.f64N/A

            \[\leadsto \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(\mathsf{/.f64}\left(y, a\right), \left(\color{blue}{z} - t\right)\right)\right) \]
          6. --lowering--.f6496.6%

            \[\leadsto \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(\mathsf{/.f64}\left(y, a\right), \mathsf{\_.f64}\left(z, \color{blue}{t}\right)\right)\right) \]
        4. Applied egg-rr96.6%

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

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

        Alternative 7: 72.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 94.3%

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

            \[\leadsto \mathsf{+.f64}\left(x, \left(\frac{\left(z - t\right) \cdot y}{a}\right)\right) \]
          2. associate-/l*N/A

            \[\leadsto \mathsf{+.f64}\left(x, \left(\left(z - t\right) \cdot \color{blue}{\frac{y}{a}}\right)\right) \]
          3. *-commutativeN/A

            \[\leadsto \mathsf{+.f64}\left(x, \left(\frac{y}{a} \cdot \color{blue}{\left(z - t\right)}\right)\right) \]
          4. *-lowering-*.f64N/A

            \[\leadsto \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(\left(\frac{y}{a}\right), \color{blue}{\left(z - t\right)}\right)\right) \]
          5. /-lowering-/.f64N/A

            \[\leadsto \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(\mathsf{/.f64}\left(y, a\right), \left(\color{blue}{z} - t\right)\right)\right) \]
          6. --lowering--.f6496.6%

            \[\leadsto \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(\mathsf{/.f64}\left(y, a\right), \mathsf{\_.f64}\left(z, \color{blue}{t}\right)\right)\right) \]
        4. Applied egg-rr96.6%

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

          \[\leadsto \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(\mathsf{/.f64}\left(y, a\right), \color{blue}{z}\right)\right) \]
        6. Step-by-step derivation
          1. Simplified72.2%

            \[\leadsto x + \frac{y}{a} \cdot \color{blue}{z} \]
          2. Final simplification72.2%

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

          Alternative 8: 40.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 94.3%

            \[x + \frac{y \cdot \left(z - t\right)}{a} \]
          2. Add Preprocessing
          3. Taylor expanded in x around inf

            \[\leadsto \color{blue}{x} \]
          4. Step-by-step derivation
            1. Simplified37.1%

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

            Developer Target 1: 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 2024130 
            (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)))