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

Percentage Accurate: 92.1% → 97.7%
Time: 9.4s
Alternatives: 9
Speedup: 1.1×

Specification

?
\[\begin{array}{l} \\ x + \frac{y \cdot \left(z - x\right)}{t} \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
double code(double x, double y, double z, double t) {
	return x + ((y * (z - x)) / t);
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x + ((y * (z - x)) / t)
end function
public static double code(double x, double y, double z, double t) {
	return x + ((y * (z - x)) / t);
}
def code(x, y, z, t):
	return x + ((y * (z - x)) / t)
function code(x, y, z, t)
	return Float64(x + Float64(Float64(y * Float64(z - x)) / t))
end
function tmp = code(x, y, z, t)
	tmp = x + ((y * (z - x)) / t);
end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \frac{y \cdot \left(z - x\right)}{t}
\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 9 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.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \frac{y \cdot \left(z - x\right)}{t} \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
double code(double x, double y, double z, double t) {
	return x + ((y * (z - x)) / t);
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x + ((y * (z - x)) / t)
end function
public static double code(double x, double y, double z, double t) {
	return x + ((y * (z - x)) / t);
}
def code(x, y, z, t):
	return x + ((y * (z - x)) / t)
function code(x, y, z, t)
	return Float64(x + Float64(Float64(y * Float64(z - x)) / t))
end
function tmp = code(x, y, z, t)
	tmp = x + ((y * (z - x)) / t);
end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \frac{y \cdot \left(z - x\right)}{t}
\end{array}

Alternative 1: 97.7% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\frac{y}{t}, z - x, x\right) \end{array} \]
(FPCore (x y z t) :precision binary64 (fma (/ y t) (- z x) x))
double code(double x, double y, double z, double t) {
	return fma((y / t), (z - x), x);
}
function code(x, y, z, t)
	return fma(Float64(y / t), Float64(z - x), x)
end
code[x_, y_, z_, t_] := N[(N[(y / t), $MachinePrecision] * N[(z - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)
\end{array}
Derivation
  1. Initial program 91.9%

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{y}{t}}, z - x, x\right) \]
    7. --lowering--.f6497.4

      \[\leadsto \mathsf{fma}\left(\frac{y}{t}, \color{blue}{z - x}, x\right) \]
  4. Applied egg-rr97.4%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)} \]
  5. Add Preprocessing

Alternative 2: 85.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(\frac{y}{t}, z, x\right)\\ \mathbf{if}\;z \leq -4 \cdot 10^{-51}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{-20}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{t}, -x, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (fma (/ y t) z x)))
   (if (<= z -4e-51) t_1 (if (<= z 1.55e-20) (fma (/ y t) (- x) x) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = fma((y / t), z, x);
	double tmp;
	if (z <= -4e-51) {
		tmp = t_1;
	} else if (z <= 1.55e-20) {
		tmp = fma((y / t), -x, x);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t)
	t_1 = fma(Float64(y / t), z, x)
	tmp = 0.0
	if (z <= -4e-51)
		tmp = t_1;
	elseif (z <= 1.55e-20)
		tmp = fma(Float64(y / t), Float64(-x), x);
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y / t), $MachinePrecision] * z + x), $MachinePrecision]}, If[LessEqual[z, -4e-51], t$95$1, If[LessEqual[z, 1.55e-20], N[(N[(y / t), $MachinePrecision] * (-x) + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{y}{t}, z, x\right)\\
\mathbf{if}\;z \leq -4 \cdot 10^{-51}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 1.55 \cdot 10^{-20}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t}, -x, x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -4e-51 or 1.55e-20 < z

    1. Initial program 87.5%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{y}{t}}, z - x, x\right) \]
      7. --lowering--.f6497.4

        \[\leadsto \mathsf{fma}\left(\frac{y}{t}, \color{blue}{z - x}, x\right) \]
    4. Applied egg-rr97.4%

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

      \[\leadsto \mathsf{fma}\left(\frac{y}{t}, \color{blue}{z}, x\right) \]
    6. Step-by-step derivation
      1. Simplified89.7%

        \[\leadsto \mathsf{fma}\left(\frac{y}{t}, \color{blue}{z}, x\right) \]

      if -4e-51 < z < 1.55e-20

      1. Initial program 97.5%

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{y}{t}}, z - x, x\right) \]
        7. --lowering--.f6497.4

          \[\leadsto \mathsf{fma}\left(\frac{y}{t}, \color{blue}{z - x}, x\right) \]
      4. Applied egg-rr97.4%

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

        \[\leadsto \mathsf{fma}\left(\frac{y}{t}, \color{blue}{-1 \cdot x}, x\right) \]
      6. Step-by-step derivation
        1. mul-1-negN/A

          \[\leadsto \mathsf{fma}\left(\frac{y}{t}, \color{blue}{\mathsf{neg}\left(x\right)}, x\right) \]
        2. neg-lowering-neg.f6491.8

          \[\leadsto \mathsf{fma}\left(\frac{y}{t}, \color{blue}{-x}, x\right) \]
      7. Simplified91.8%

        \[\leadsto \mathsf{fma}\left(\frac{y}{t}, \color{blue}{-x}, x\right) \]
    7. Recombined 2 regimes into one program.
    8. Add Preprocessing

    Alternative 3: 84.5% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(\frac{y}{t}, z, x\right)\\ \mathbf{if}\;z \leq -1.7 \cdot 10^{-54}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 5.1 \cdot 10^{-43}:\\ \;\;\;\;x - \frac{y \cdot x}{t}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
    (FPCore (x y z t)
     :precision binary64
     (let* ((t_1 (fma (/ y t) z x)))
       (if (<= z -1.7e-54) t_1 (if (<= z 5.1e-43) (- x (/ (* y x) t)) t_1))))
    double code(double x, double y, double z, double t) {
    	double t_1 = fma((y / t), z, x);
    	double tmp;
    	if (z <= -1.7e-54) {
    		tmp = t_1;
    	} else if (z <= 5.1e-43) {
    		tmp = x - ((y * x) / t);
    	} else {
    		tmp = t_1;
    	}
    	return tmp;
    }
    
    function code(x, y, z, t)
    	t_1 = fma(Float64(y / t), z, x)
    	tmp = 0.0
    	if (z <= -1.7e-54)
    		tmp = t_1;
    	elseif (z <= 5.1e-43)
    		tmp = Float64(x - Float64(Float64(y * x) / t));
    	else
    		tmp = t_1;
    	end
    	return tmp
    end
    
    code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y / t), $MachinePrecision] * z + x), $MachinePrecision]}, If[LessEqual[z, -1.7e-54], t$95$1, If[LessEqual[z, 5.1e-43], N[(x - N[(N[(y * x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_1 := \mathsf{fma}\left(\frac{y}{t}, z, x\right)\\
    \mathbf{if}\;z \leq -1.7 \cdot 10^{-54}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;z \leq 5.1 \cdot 10^{-43}:\\
    \;\;\;\;x - \frac{y \cdot x}{t}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if z < -1.69999999999999994e-54 or 5.0999999999999997e-43 < z

      1. Initial program 88.0%

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{y}{t}}, z - x, x\right) \]
        7. --lowering--.f6497.5

          \[\leadsto \mathsf{fma}\left(\frac{y}{t}, \color{blue}{z - x}, x\right) \]
      4. Applied egg-rr97.5%

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

        \[\leadsto \mathsf{fma}\left(\frac{y}{t}, \color{blue}{z}, x\right) \]
      6. Step-by-step derivation
        1. Simplified88.9%

          \[\leadsto \mathsf{fma}\left(\frac{y}{t}, \color{blue}{z}, x\right) \]

        if -1.69999999999999994e-54 < z < 5.0999999999999997e-43

        1. Initial program 97.3%

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

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

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

            \[\leadsto x \cdot \color{blue}{\left(1 - \frac{y}{t}\right)} \]
          3. distribute-lft-out--N/A

            \[\leadsto \color{blue}{x \cdot 1 - x \cdot \frac{y}{t}} \]
          4. *-rgt-identityN/A

            \[\leadsto \color{blue}{x} - x \cdot \frac{y}{t} \]
          5. associate-/l*N/A

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

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

            \[\leadsto x - \color{blue}{\frac{x \cdot y}{t}} \]
          8. *-commutativeN/A

            \[\leadsto x - \frac{\color{blue}{y \cdot x}}{t} \]
          9. *-lowering-*.f6489.2

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

          \[\leadsto \color{blue}{x - \frac{y \cdot x}{t}} \]
      7. Recombined 2 regimes into one program.
      8. Add Preprocessing

      Alternative 4: 81.7% accurate, 0.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \mathbf{if}\;t \leq -7.5 \cdot 10^{-69}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 1.6 \cdot 10^{-46}:\\ \;\;\;\;y \cdot \frac{z - x}{t}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
      (FPCore (x y z t)
       :precision binary64
       (let* ((t_1 (fma (/ z t) y x)))
         (if (<= t -7.5e-69) t_1 (if (<= t 1.6e-46) (* y (/ (- z x) t)) t_1))))
      double code(double x, double y, double z, double t) {
      	double t_1 = fma((z / t), y, x);
      	double tmp;
      	if (t <= -7.5e-69) {
      		tmp = t_1;
      	} else if (t <= 1.6e-46) {
      		tmp = y * ((z - x) / t);
      	} else {
      		tmp = t_1;
      	}
      	return tmp;
      }
      
      function code(x, y, z, t)
      	t_1 = fma(Float64(z / t), y, x)
      	tmp = 0.0
      	if (t <= -7.5e-69)
      		tmp = t_1;
      	elseif (t <= 1.6e-46)
      		tmp = Float64(y * Float64(Float64(z - x) / t));
      	else
      		tmp = t_1;
      	end
      	return tmp
      end
      
      code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z / t), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t, -7.5e-69], t$95$1, If[LessEqual[t, 1.6e-46], N[(y * N[(N[(z - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_1 := \mathsf{fma}\left(\frac{z}{t}, y, x\right)\\
      \mathbf{if}\;t \leq -7.5 \cdot 10^{-69}:\\
      \;\;\;\;t\_1\\
      
      \mathbf{elif}\;t \leq 1.6 \cdot 10^{-46}:\\
      \;\;\;\;y \cdot \frac{z - x}{t}\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_1\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if t < -7.5e-69 or 1.6e-46 < t

        1. Initial program 87.0%

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{y}{t}}, z - x, x\right) \]
          7. --lowering--.f6497.6

            \[\leadsto \mathsf{fma}\left(\frac{y}{t}, \color{blue}{z - x}, x\right) \]
        4. Applied egg-rr97.6%

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

          \[\leadsto \mathsf{fma}\left(\frac{y}{t}, \color{blue}{z}, x\right) \]
        6. Step-by-step derivation
          1. Simplified87.6%

            \[\leadsto \mathsf{fma}\left(\frac{y}{t}, \color{blue}{z}, x\right) \]
          2. Step-by-step derivation
            1. associate-*l/N/A

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

              \[\leadsto \color{blue}{y \cdot \frac{z}{t}} + x \]
            3. *-commutativeN/A

              \[\leadsto \color{blue}{\frac{z}{t} \cdot y} + x \]
            4. accelerator-lowering-fma.f64N/A

              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z}{t}, y, x\right)} \]
            5. /-lowering-/.f6489.9

              \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{t}}, y, x\right) \]
          3. Applied egg-rr89.9%

            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z}{t}, y, x\right)} \]

          if -7.5e-69 < t < 1.6e-46

          1. Initial program 98.9%

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

            \[\leadsto \color{blue}{y \cdot \left(\frac{z}{t} - \frac{x}{t}\right)} \]
          4. Step-by-step derivation
            1. div-subN/A

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

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

              \[\leadsto y \cdot \color{blue}{\frac{z - x}{t}} \]
            4. --lowering--.f6479.9

              \[\leadsto y \cdot \frac{\color{blue}{z - x}}{t} \]
          5. Simplified79.9%

            \[\leadsto \color{blue}{y \cdot \frac{z - x}{t}} \]
        7. Recombined 2 regimes into one program.
        8. Add Preprocessing

        Alternative 5: 54.9% accurate, 0.8× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -3.6 \cdot 10^{-63}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 5.5 \cdot 10^{-54}:\\ \;\;\;\;\frac{y}{t} \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
        (FPCore (x y z t)
         :precision binary64
         (if (<= t -3.6e-63) x (if (<= t 5.5e-54) (* (/ y t) z) x)))
        double code(double x, double y, double z, double t) {
        	double tmp;
        	if (t <= -3.6e-63) {
        		tmp = x;
        	} else if (t <= 5.5e-54) {
        		tmp = (y / t) * z;
        	} else {
        		tmp = x;
        	}
        	return tmp;
        }
        
        real(8) function code(x, y, z, t)
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            real(8), intent (in) :: z
            real(8), intent (in) :: t
            real(8) :: tmp
            if (t <= (-3.6d-63)) then
                tmp = x
            else if (t <= 5.5d-54) then
                tmp = (y / t) * z
            else
                tmp = x
            end if
            code = tmp
        end function
        
        public static double code(double x, double y, double z, double t) {
        	double tmp;
        	if (t <= -3.6e-63) {
        		tmp = x;
        	} else if (t <= 5.5e-54) {
        		tmp = (y / t) * z;
        	} else {
        		tmp = x;
        	}
        	return tmp;
        }
        
        def code(x, y, z, t):
        	tmp = 0
        	if t <= -3.6e-63:
        		tmp = x
        	elif t <= 5.5e-54:
        		tmp = (y / t) * z
        	else:
        		tmp = x
        	return tmp
        
        function code(x, y, z, t)
        	tmp = 0.0
        	if (t <= -3.6e-63)
        		tmp = x;
        	elseif (t <= 5.5e-54)
        		tmp = Float64(Float64(y / t) * z);
        	else
        		tmp = x;
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z, t)
        	tmp = 0.0;
        	if (t <= -3.6e-63)
        		tmp = x;
        	elseif (t <= 5.5e-54)
        		tmp = (y / t) * z;
        	else
        		tmp = x;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_, t_] := If[LessEqual[t, -3.6e-63], x, If[LessEqual[t, 5.5e-54], N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision], x]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;t \leq -3.6 \cdot 10^{-63}:\\
        \;\;\;\;x\\
        
        \mathbf{elif}\;t \leq 5.5 \cdot 10^{-54}:\\
        \;\;\;\;\frac{y}{t} \cdot z\\
        
        \mathbf{else}:\\
        \;\;\;\;x\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if t < -3.60000000000000008e-63 or 5.50000000000000046e-54 < t

          1. Initial program 87.2%

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

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

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

            if -3.60000000000000008e-63 < t < 5.50000000000000046e-54

            1. Initial program 98.9%

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

              \[\leadsto \color{blue}{y \cdot \left(\frac{z}{t} - \frac{x}{t}\right)} \]
            4. Step-by-step derivation
              1. div-subN/A

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

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

                \[\leadsto y \cdot \color{blue}{\frac{z - x}{t}} \]
              4. --lowering--.f6479.5

                \[\leadsto y \cdot \frac{\color{blue}{z - x}}{t} \]
            5. Simplified79.5%

              \[\leadsto \color{blue}{y \cdot \frac{z - x}{t}} \]
            6. Taylor expanded in z around inf

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

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

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

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

                  \[\leadsto \color{blue}{\frac{y}{t} \cdot z} \]
                4. /-lowering-/.f6453.5

                  \[\leadsto \color{blue}{\frac{y}{t}} \cdot z \]
              3. Applied egg-rr53.5%

                \[\leadsto \color{blue}{\frac{y}{t} \cdot z} \]
            8. Recombined 2 regimes into one program.
            9. Add Preprocessing

            Alternative 6: 51.5% accurate, 0.8× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -7 \cdot 10^{-28}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.7 \cdot 10^{+15}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
            (FPCore (x y z t)
             :precision binary64
             (if (<= x -7e-28) x (if (<= x 3.7e+15) (* y (/ z t)) x)))
            double code(double x, double y, double z, double t) {
            	double tmp;
            	if (x <= -7e-28) {
            		tmp = x;
            	} else if (x <= 3.7e+15) {
            		tmp = y * (z / t);
            	} else {
            		tmp = x;
            	}
            	return tmp;
            }
            
            real(8) function code(x, y, z, t)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                real(8), intent (in) :: z
                real(8), intent (in) :: t
                real(8) :: tmp
                if (x <= (-7d-28)) then
                    tmp = x
                else if (x <= 3.7d+15) then
                    tmp = y * (z / t)
                else
                    tmp = x
                end if
                code = tmp
            end function
            
            public static double code(double x, double y, double z, double t) {
            	double tmp;
            	if (x <= -7e-28) {
            		tmp = x;
            	} else if (x <= 3.7e+15) {
            		tmp = y * (z / t);
            	} else {
            		tmp = x;
            	}
            	return tmp;
            }
            
            def code(x, y, z, t):
            	tmp = 0
            	if x <= -7e-28:
            		tmp = x
            	elif x <= 3.7e+15:
            		tmp = y * (z / t)
            	else:
            		tmp = x
            	return tmp
            
            function code(x, y, z, t)
            	tmp = 0.0
            	if (x <= -7e-28)
            		tmp = x;
            	elseif (x <= 3.7e+15)
            		tmp = Float64(y * Float64(z / t));
            	else
            		tmp = x;
            	end
            	return tmp
            end
            
            function tmp_2 = code(x, y, z, t)
            	tmp = 0.0;
            	if (x <= -7e-28)
            		tmp = x;
            	elseif (x <= 3.7e+15)
            		tmp = y * (z / t);
            	else
            		tmp = x;
            	end
            	tmp_2 = tmp;
            end
            
            code[x_, y_, z_, t_] := If[LessEqual[x, -7e-28], x, If[LessEqual[x, 3.7e+15], N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision], x]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;x \leq -7 \cdot 10^{-28}:\\
            \;\;\;\;x\\
            
            \mathbf{elif}\;x \leq 3.7 \cdot 10^{+15}:\\
            \;\;\;\;y \cdot \frac{z}{t}\\
            
            \mathbf{else}:\\
            \;\;\;\;x\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if x < -6.9999999999999999e-28 or 3.7e15 < x

              1. Initial program 91.5%

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

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

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

                if -6.9999999999999999e-28 < x < 3.7e15

                1. Initial program 92.2%

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

                  \[\leadsto \color{blue}{y \cdot \left(\frac{z}{t} - \frac{x}{t}\right)} \]
                4. Step-by-step derivation
                  1. div-subN/A

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

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

                    \[\leadsto y \cdot \color{blue}{\frac{z - x}{t}} \]
                  4. --lowering--.f6466.2

                    \[\leadsto y \cdot \frac{\color{blue}{z - x}}{t} \]
                5. Simplified66.2%

                  \[\leadsto \color{blue}{y \cdot \frac{z - x}{t}} \]
                6. Taylor expanded in z around inf

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

                    \[\leadsto y \cdot \frac{\color{blue}{z}}{t} \]
                8. Recombined 2 regimes into one program.
                9. Add Preprocessing

                Alternative 7: 76.5% accurate, 0.9× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -6.3 \cdot 10^{+240}:\\ \;\;\;\;x \cdot \frac{y}{-t}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z, x\right)\\ \end{array} \end{array} \]
                (FPCore (x y z t)
                 :precision binary64
                 (if (<= y -6.3e+240) (* x (/ y (- t))) (fma (/ y t) z x)))
                double code(double x, double y, double z, double t) {
                	double tmp;
                	if (y <= -6.3e+240) {
                		tmp = x * (y / -t);
                	} else {
                		tmp = fma((y / t), z, x);
                	}
                	return tmp;
                }
                
                function code(x, y, z, t)
                	tmp = 0.0
                	if (y <= -6.3e+240)
                		tmp = Float64(x * Float64(y / Float64(-t)));
                	else
                		tmp = fma(Float64(y / t), z, x);
                	end
                	return tmp
                end
                
                code[x_, y_, z_, t_] := If[LessEqual[y, -6.3e+240], N[(x * N[(y / (-t)), $MachinePrecision]), $MachinePrecision], N[(N[(y / t), $MachinePrecision] * z + x), $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;y \leq -6.3 \cdot 10^{+240}:\\
                \;\;\;\;x \cdot \frac{y}{-t}\\
                
                \mathbf{else}:\\
                \;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z, x\right)\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if y < -6.2999999999999997e240

                  1. Initial program 79.8%

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

                    \[\leadsto \color{blue}{y \cdot \left(\frac{z}{t} - \frac{x}{t}\right)} \]
                  4. Step-by-step derivation
                    1. div-subN/A

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

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

                      \[\leadsto y \cdot \color{blue}{\frac{z - x}{t}} \]
                    4. --lowering--.f6497.7

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

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

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

                      \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{x \cdot y}{t}\right)} \]
                    2. associate-/l*N/A

                      \[\leadsto \mathsf{neg}\left(\color{blue}{x \cdot \frac{y}{t}}\right) \]
                    3. distribute-rgt-neg-inN/A

                      \[\leadsto \color{blue}{x \cdot \left(\mathsf{neg}\left(\frac{y}{t}\right)\right)} \]
                    4. mul-1-negN/A

                      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{y}{t}\right)} \]
                    5. *-lowering-*.f64N/A

                      \[\leadsto \color{blue}{x \cdot \left(-1 \cdot \frac{y}{t}\right)} \]
                    6. mul-1-negN/A

                      \[\leadsto x \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{y}{t}\right)\right)} \]
                    7. distribute-neg-frac2N/A

                      \[\leadsto x \cdot \color{blue}{\frac{y}{\mathsf{neg}\left(t\right)}} \]
                    8. /-lowering-/.f64N/A

                      \[\leadsto x \cdot \color{blue}{\frac{y}{\mathsf{neg}\left(t\right)}} \]
                    9. neg-lowering-neg.f6484.4

                      \[\leadsto x \cdot \frac{y}{\color{blue}{-t}} \]
                  8. Simplified84.4%

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

                  if -6.2999999999999997e240 < y

                  1. Initial program 92.6%

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

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

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{y}{t}}, z - x, x\right) \]
                    7. --lowering--.f6497.6

                      \[\leadsto \mathsf{fma}\left(\frac{y}{t}, \color{blue}{z - x}, x\right) \]
                  4. Applied egg-rr97.6%

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

                    \[\leadsto \mathsf{fma}\left(\frac{y}{t}, \color{blue}{z}, x\right) \]
                  6. Step-by-step derivation
                    1. Simplified78.6%

                      \[\leadsto \mathsf{fma}\left(\frac{y}{t}, \color{blue}{z}, x\right) \]
                  7. Recombined 2 regimes into one program.
                  8. Add Preprocessing

                  Alternative 8: 76.9% accurate, 1.3× speedup?

                  \[\begin{array}{l} \\ \mathsf{fma}\left(\frac{y}{t}, z, x\right) \end{array} \]
                  (FPCore (x y z t) :precision binary64 (fma (/ y t) z x))
                  double code(double x, double y, double z, double t) {
                  	return fma((y / t), z, x);
                  }
                  
                  function code(x, y, z, t)
                  	return fma(Float64(y / t), z, x)
                  end
                  
                  code[x_, y_, z_, t_] := N[(N[(y / t), $MachinePrecision] * z + x), $MachinePrecision]
                  
                  \begin{array}{l}
                  
                  \\
                  \mathsf{fma}\left(\frac{y}{t}, z, x\right)
                  \end{array}
                  
                  Derivation
                  1. Initial program 91.9%

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

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

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{y}{t}}, z - x, x\right) \]
                    7. --lowering--.f6497.4

                      \[\leadsto \mathsf{fma}\left(\frac{y}{t}, \color{blue}{z - x}, x\right) \]
                  4. Applied egg-rr97.4%

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

                    \[\leadsto \mathsf{fma}\left(\frac{y}{t}, \color{blue}{z}, x\right) \]
                  6. Step-by-step derivation
                    1. Simplified76.3%

                      \[\leadsto \mathsf{fma}\left(\frac{y}{t}, \color{blue}{z}, x\right) \]
                    2. Add Preprocessing

                    Alternative 9: 39.3% accurate, 23.0× speedup?

                    \[\begin{array}{l} \\ x \end{array} \]
                    (FPCore (x y z t) :precision binary64 x)
                    double code(double x, double y, double z, double t) {
                    	return x;
                    }
                    
                    real(8) function code(x, y, z, t)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        real(8), intent (in) :: z
                        real(8), intent (in) :: t
                        code = x
                    end function
                    
                    public static double code(double x, double y, double z, double t) {
                    	return x;
                    }
                    
                    def code(x, y, z, t):
                    	return x
                    
                    function code(x, y, z, t)
                    	return x
                    end
                    
                    function tmp = code(x, y, z, t)
                    	tmp = x;
                    end
                    
                    code[x_, y_, z_, t_] := x
                    
                    \begin{array}{l}
                    
                    \\
                    x
                    \end{array}
                    
                    Derivation
                    1. Initial program 91.9%

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

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

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

                      Developer Target 1: 90.6% accurate, 0.6× speedup?

                      \[\begin{array}{l} \\ x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right) \end{array} \]
                      (FPCore (x y z t)
                       :precision binary64
                       (- x (+ (* x (/ y t)) (* (- z) (/ y t)))))
                      double code(double x, double y, double z, double t) {
                      	return x - ((x * (y / t)) + (-z * (y / t)));
                      }
                      
                      real(8) function code(x, y, z, t)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          real(8), intent (in) :: z
                          real(8), intent (in) :: t
                          code = x - ((x * (y / t)) + (-z * (y / t)))
                      end function
                      
                      public static double code(double x, double y, double z, double t) {
                      	return x - ((x * (y / t)) + (-z * (y / t)));
                      }
                      
                      def code(x, y, z, t):
                      	return x - ((x * (y / t)) + (-z * (y / t)))
                      
                      function code(x, y, z, t)
                      	return Float64(x - Float64(Float64(x * Float64(y / t)) + Float64(Float64(-z) * Float64(y / t))))
                      end
                      
                      function tmp = code(x, y, z, t)
                      	tmp = x - ((x * (y / t)) + (-z * (y / t)));
                      end
                      
                      code[x_, y_, z_, t_] := N[(x - N[(N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision] + N[((-z) * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                      
                      \begin{array}{l}
                      
                      \\
                      x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right)
                      \end{array}
                      

                      Reproduce

                      ?
                      herbie shell --seed 2024199 
                      (FPCore (x y z t)
                        :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
                        :precision binary64
                      
                        :alt
                        (! :herbie-platform default (- x (+ (* x (/ y t)) (* (- z) (/ y t)))))
                      
                        (+ x (/ (* y (- z x)) t)))