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

Percentage Accurate: 99.9% → 99.9%
Time: 5.7s
Alternatives: 9
Speedup: 1.0×

Specification

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

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

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

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

Alternative 1: 99.9% accurate, 1.0× speedup?

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

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

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

Alternative 2: 37.4% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{\left(x + y\right) - z}{t \cdot 2} \leq -2 \cdot 10^{-268}:\\
\;\;\;\;x \cdot \frac{0.5}{t}\\

\mathbf{else}:\\
\;\;\;\;\frac{y}{t} \cdot 0.5\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 (+.f64 x y) z) (*.f64 t #s(literal 2 binary64))) < -1.99999999999999992e-268

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{x}{t}} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\frac{x}{t} \cdot \frac{1}{2}} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{x}{t} \cdot \frac{1}{2}} \]
      3. lower-/.f6436.8

        \[\leadsto \color{blue}{\frac{x}{t}} \cdot 0.5 \]
    5. Applied rewrites36.8%

      \[\leadsto \color{blue}{\frac{x}{t} \cdot 0.5} \]
    6. Step-by-step derivation
      1. Applied rewrites36.6%

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

      if -1.99999999999999992e-268 < (/.f64 (-.f64 (+.f64 x y) z) (*.f64 t #s(literal 2 binary64)))

      1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{x + y}{t}} \]
      4. Step-by-step derivation
        1. div-add-revN/A

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

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

          \[\leadsto \color{blue}{\left(\frac{x}{t} + \frac{y}{t}\right) \cdot \frac{1}{2}} \]
        4. div-add-revN/A

          \[\leadsto \color{blue}{\frac{x + y}{t}} \cdot \frac{1}{2} \]
        5. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{x + y}{t}} \cdot \frac{1}{2} \]
        6. +-commutativeN/A

          \[\leadsto \frac{\color{blue}{y + x}}{t} \cdot \frac{1}{2} \]
        7. lower-+.f6473.0

          \[\leadsto \frac{\color{blue}{y + x}}{t} \cdot 0.5 \]
      5. Applied rewrites73.0%

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

        \[\leadsto \frac{y}{t} \cdot \frac{1}{2} \]
      7. Step-by-step derivation
        1. Applied rewrites41.7%

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

      Alternative 3: 51.5% accurate, 0.7× speedup?

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

        1. Initial program 100.0%

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

          \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{x}{t}} \]
        4. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \color{blue}{\frac{x}{t} \cdot \frac{1}{2}} \]
          2. lower-*.f64N/A

            \[\leadsto \color{blue}{\frac{x}{t} \cdot \frac{1}{2}} \]
          3. lower-/.f6443.7

            \[\leadsto \color{blue}{\frac{x}{t}} \cdot 0.5 \]
        5. Applied rewrites43.7%

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

        if -1e47 < (+.f64 x y) < 1e17

        1. Initial program 100.0%

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

          \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{z}{t}} \]
        4. Step-by-step derivation
          1. *-lft-identityN/A

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

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

            \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \frac{1}{t}\right) \cdot z} \]
          4. metadata-evalN/A

            \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot \frac{1}{t}\right) \cdot z \]
          5. lower-*.f64N/A

            \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \frac{1}{t}\right) \cdot z} \]
          6. metadata-evalN/A

            \[\leadsto \left(\color{blue}{\frac{-1}{2}} \cdot \frac{1}{t}\right) \cdot z \]
          7. associate-*r/N/A

            \[\leadsto \color{blue}{\frac{\frac{-1}{2} \cdot 1}{t}} \cdot z \]
          8. metadata-evalN/A

            \[\leadsto \frac{\color{blue}{\frac{-1}{2}}}{t} \cdot z \]
          9. lower-/.f6465.3

            \[\leadsto \color{blue}{\frac{-0.5}{t}} \cdot z \]
        5. Applied rewrites65.3%

          \[\leadsto \color{blue}{\frac{-0.5}{t} \cdot z} \]
        6. Step-by-step derivation
          1. Applied rewrites65.4%

            \[\leadsto \frac{-0.5 \cdot z}{\color{blue}{t}} \]

          if 1e17 < (+.f64 x y)

          1. Initial program 100.0%

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

            \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{x + y}{t}} \]
          4. Step-by-step derivation
            1. div-add-revN/A

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

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

              \[\leadsto \color{blue}{\left(\frac{x}{t} + \frac{y}{t}\right) \cdot \frac{1}{2}} \]
            4. div-add-revN/A

              \[\leadsto \color{blue}{\frac{x + y}{t}} \cdot \frac{1}{2} \]
            5. lower-/.f64N/A

              \[\leadsto \color{blue}{\frac{x + y}{t}} \cdot \frac{1}{2} \]
            6. +-commutativeN/A

              \[\leadsto \frac{\color{blue}{y + x}}{t} \cdot \frac{1}{2} \]
            7. lower-+.f6488.2

              \[\leadsto \frac{\color{blue}{y + x}}{t} \cdot 0.5 \]
          5. Applied rewrites88.2%

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

            \[\leadsto \frac{y}{t} \cdot \frac{1}{2} \]
          7. Step-by-step derivation
            1. Applied rewrites47.8%

              \[\leadsto \frac{y}{t} \cdot 0.5 \]
          8. Recombined 3 regimes into one program.
          9. Add Preprocessing

          Alternative 4: 51.4% accurate, 0.7× speedup?

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

            1. Initial program 100.0%

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

              \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{x}{t}} \]
            4. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \color{blue}{\frac{x}{t} \cdot \frac{1}{2}} \]
              2. lower-*.f64N/A

                \[\leadsto \color{blue}{\frac{x}{t} \cdot \frac{1}{2}} \]
              3. lower-/.f6443.7

                \[\leadsto \color{blue}{\frac{x}{t}} \cdot 0.5 \]
            5. Applied rewrites43.7%

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

            if -1e47 < (+.f64 x y) < 1e17

            1. Initial program 100.0%

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

              \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{z}{t}} \]
            4. Step-by-step derivation
              1. *-lft-identityN/A

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

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

                \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \frac{1}{t}\right) \cdot z} \]
              4. metadata-evalN/A

                \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot \frac{1}{t}\right) \cdot z \]
              5. lower-*.f64N/A

                \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \frac{1}{t}\right) \cdot z} \]
              6. metadata-evalN/A

                \[\leadsto \left(\color{blue}{\frac{-1}{2}} \cdot \frac{1}{t}\right) \cdot z \]
              7. associate-*r/N/A

                \[\leadsto \color{blue}{\frac{\frac{-1}{2} \cdot 1}{t}} \cdot z \]
              8. metadata-evalN/A

                \[\leadsto \frac{\color{blue}{\frac{-1}{2}}}{t} \cdot z \]
              9. lower-/.f6465.3

                \[\leadsto \color{blue}{\frac{-0.5}{t}} \cdot z \]
            5. Applied rewrites65.3%

              \[\leadsto \color{blue}{\frac{-0.5}{t} \cdot z} \]

            if 1e17 < (+.f64 x y)

            1. Initial program 100.0%

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

              \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{x + y}{t}} \]
            4. Step-by-step derivation
              1. div-add-revN/A

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

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

                \[\leadsto \color{blue}{\left(\frac{x}{t} + \frac{y}{t}\right) \cdot \frac{1}{2}} \]
              4. div-add-revN/A

                \[\leadsto \color{blue}{\frac{x + y}{t}} \cdot \frac{1}{2} \]
              5. lower-/.f64N/A

                \[\leadsto \color{blue}{\frac{x + y}{t}} \cdot \frac{1}{2} \]
              6. +-commutativeN/A

                \[\leadsto \frac{\color{blue}{y + x}}{t} \cdot \frac{1}{2} \]
              7. lower-+.f6488.2

                \[\leadsto \frac{\color{blue}{y + x}}{t} \cdot 0.5 \]
            5. Applied rewrites88.2%

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

              \[\leadsto \frac{y}{t} \cdot \frac{1}{2} \]
            7. Step-by-step derivation
              1. Applied rewrites47.8%

                \[\leadsto \frac{y}{t} \cdot 0.5 \]
            8. Recombined 3 regimes into one program.
            9. Add Preprocessing

            Alternative 5: 51.4% accurate, 0.7× speedup?

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

              1. Initial program 100.0%

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

                \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{x}{t}} \]
              4. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto \color{blue}{\frac{x}{t} \cdot \frac{1}{2}} \]
                2. lower-*.f64N/A

                  \[\leadsto \color{blue}{\frac{x}{t} \cdot \frac{1}{2}} \]
                3. lower-/.f6443.7

                  \[\leadsto \color{blue}{\frac{x}{t}} \cdot 0.5 \]
              5. Applied rewrites43.7%

                \[\leadsto \color{blue}{\frac{x}{t} \cdot 0.5} \]
              6. Step-by-step derivation
                1. Applied rewrites43.5%

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

                if -1e47 < (+.f64 x y) < 1e17

                1. Initial program 100.0%

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

                  \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{z}{t}} \]
                4. Step-by-step derivation
                  1. *-lft-identityN/A

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

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

                    \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \frac{1}{t}\right) \cdot z} \]
                  4. metadata-evalN/A

                    \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot \frac{1}{t}\right) \cdot z \]
                  5. lower-*.f64N/A

                    \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \frac{1}{t}\right) \cdot z} \]
                  6. metadata-evalN/A

                    \[\leadsto \left(\color{blue}{\frac{-1}{2}} \cdot \frac{1}{t}\right) \cdot z \]
                  7. associate-*r/N/A

                    \[\leadsto \color{blue}{\frac{\frac{-1}{2} \cdot 1}{t}} \cdot z \]
                  8. metadata-evalN/A

                    \[\leadsto \frac{\color{blue}{\frac{-1}{2}}}{t} \cdot z \]
                  9. lower-/.f6465.3

                    \[\leadsto \color{blue}{\frac{-0.5}{t}} \cdot z \]
                5. Applied rewrites65.3%

                  \[\leadsto \color{blue}{\frac{-0.5}{t} \cdot z} \]

                if 1e17 < (+.f64 x y)

                1. Initial program 100.0%

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

                  \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{x + y}{t}} \]
                4. Step-by-step derivation
                  1. div-add-revN/A

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

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

                    \[\leadsto \color{blue}{\left(\frac{x}{t} + \frac{y}{t}\right) \cdot \frac{1}{2}} \]
                  4. div-add-revN/A

                    \[\leadsto \color{blue}{\frac{x + y}{t}} \cdot \frac{1}{2} \]
                  5. lower-/.f64N/A

                    \[\leadsto \color{blue}{\frac{x + y}{t}} \cdot \frac{1}{2} \]
                  6. +-commutativeN/A

                    \[\leadsto \frac{\color{blue}{y + x}}{t} \cdot \frac{1}{2} \]
                  7. lower-+.f6488.2

                    \[\leadsto \frac{\color{blue}{y + x}}{t} \cdot 0.5 \]
                5. Applied rewrites88.2%

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

                  \[\leadsto \frac{y}{t} \cdot \frac{1}{2} \]
                7. Step-by-step derivation
                  1. Applied rewrites47.8%

                    \[\leadsto \frac{y}{t} \cdot 0.5 \]
                8. Recombined 3 regimes into one program.
                9. Add Preprocessing

                Alternative 6: 82.6% accurate, 0.8× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2.05 \cdot 10^{+144} \lor \neg \left(z \leq 2.7 \cdot 10^{+122}\right):\\ \;\;\;\;\frac{-0.5 \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y}{t + t}\\ \end{array} \end{array} \]
                (FPCore (x y z t)
                 :precision binary64
                 (if (or (<= z -2.05e+144) (not (<= z 2.7e+122)))
                   (/ (* -0.5 z) t)
                   (/ (+ x y) (+ t t))))
                double code(double x, double y, double z, double t) {
                	double tmp;
                	if ((z <= -2.05e+144) || !(z <= 2.7e+122)) {
                		tmp = (-0.5 * z) / t;
                	} else {
                		tmp = (x + y) / (t + t);
                	}
                	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 ((z <= (-2.05d+144)) .or. (.not. (z <= 2.7d+122))) then
                        tmp = ((-0.5d0) * z) / t
                    else
                        tmp = (x + y) / (t + t)
                    end if
                    code = tmp
                end function
                
                public static double code(double x, double y, double z, double t) {
                	double tmp;
                	if ((z <= -2.05e+144) || !(z <= 2.7e+122)) {
                		tmp = (-0.5 * z) / t;
                	} else {
                		tmp = (x + y) / (t + t);
                	}
                	return tmp;
                }
                
                def code(x, y, z, t):
                	tmp = 0
                	if (z <= -2.05e+144) or not (z <= 2.7e+122):
                		tmp = (-0.5 * z) / t
                	else:
                		tmp = (x + y) / (t + t)
                	return tmp
                
                function code(x, y, z, t)
                	tmp = 0.0
                	if ((z <= -2.05e+144) || !(z <= 2.7e+122))
                		tmp = Float64(Float64(-0.5 * z) / t);
                	else
                		tmp = Float64(Float64(x + y) / Float64(t + t));
                	end
                	return tmp
                end
                
                function tmp_2 = code(x, y, z, t)
                	tmp = 0.0;
                	if ((z <= -2.05e+144) || ~((z <= 2.7e+122)))
                		tmp = (-0.5 * z) / t;
                	else
                		tmp = (x + y) / (t + t);
                	end
                	tmp_2 = tmp;
                end
                
                code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2.05e+144], N[Not[LessEqual[z, 2.7e+122]], $MachinePrecision]], N[(N[(-0.5 * z), $MachinePrecision] / t), $MachinePrecision], N[(N[(x + y), $MachinePrecision] / N[(t + t), $MachinePrecision]), $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;z \leq -2.05 \cdot 10^{+144} \lor \neg \left(z \leq 2.7 \cdot 10^{+122}\right):\\
                \;\;\;\;\frac{-0.5 \cdot z}{t}\\
                
                \mathbf{else}:\\
                \;\;\;\;\frac{x + y}{t + t}\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if z < -2.05000000000000001e144 or 2.6999999999999998e122 < z

                  1. Initial program 100.0%

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

                    \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{z}{t}} \]
                  4. Step-by-step derivation
                    1. *-lft-identityN/A

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

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

                      \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \frac{1}{t}\right) \cdot z} \]
                    4. metadata-evalN/A

                      \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot \frac{1}{t}\right) \cdot z \]
                    5. lower-*.f64N/A

                      \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \frac{1}{t}\right) \cdot z} \]
                    6. metadata-evalN/A

                      \[\leadsto \left(\color{blue}{\frac{-1}{2}} \cdot \frac{1}{t}\right) \cdot z \]
                    7. associate-*r/N/A

                      \[\leadsto \color{blue}{\frac{\frac{-1}{2} \cdot 1}{t}} \cdot z \]
                    8. metadata-evalN/A

                      \[\leadsto \frac{\color{blue}{\frac{-1}{2}}}{t} \cdot z \]
                    9. lower-/.f6486.0

                      \[\leadsto \color{blue}{\frac{-0.5}{t}} \cdot z \]
                  5. Applied rewrites86.0%

                    \[\leadsto \color{blue}{\frac{-0.5}{t} \cdot z} \]
                  6. Step-by-step derivation
                    1. Applied rewrites86.2%

                      \[\leadsto \frac{-0.5 \cdot z}{\color{blue}{t}} \]

                    if -2.05000000000000001e144 < z < 2.6999999999999998e122

                    1. Initial program 100.0%

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

                      \[\leadsto \frac{\color{blue}{x - z}}{t \cdot 2} \]
                    4. Step-by-step derivation
                      1. lower--.f6459.2

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

                      \[\leadsto \frac{\color{blue}{x - z}}{t \cdot 2} \]
                    6. Step-by-step derivation
                      1. lift-*.f64N/A

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

                        \[\leadsto \frac{x - z}{\color{blue}{2 \cdot t}} \]
                      3. count-2-revN/A

                        \[\leadsto \frac{x - z}{\color{blue}{t + t}} \]
                      4. lower-+.f6459.2

                        \[\leadsto \frac{x - z}{\color{blue}{t + t}} \]
                    7. Applied rewrites59.2%

                      \[\leadsto \frac{x - z}{\color{blue}{t + t}} \]
                    8. Taylor expanded in z around 0

                      \[\leadsto \frac{\color{blue}{x + y}}{t + t} \]
                    9. Step-by-step derivation
                      1. lower-+.f6487.3

                        \[\leadsto \frac{\color{blue}{x + y}}{t + t} \]
                    10. Applied rewrites87.3%

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

                    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.05 \cdot 10^{+144} \lor \neg \left(z \leq 2.7 \cdot 10^{+122}\right):\\ \;\;\;\;\frac{-0.5 \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y}{t + t}\\ \end{array} \]
                  9. Add Preprocessing

                  Alternative 7: 69.9% accurate, 0.9× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x + y \leq -1.2 \cdot 10^{-146}:\\ \;\;\;\;\frac{x - z}{t + t}\\ \mathbf{else}:\\ \;\;\;\;\frac{y - z}{t + t}\\ \end{array} \end{array} \]
                  (FPCore (x y z t)
                   :precision binary64
                   (if (<= (+ x y) -1.2e-146) (/ (- x z) (+ t t)) (/ (- y z) (+ t t))))
                  double code(double x, double y, double z, double t) {
                  	double tmp;
                  	if ((x + y) <= -1.2e-146) {
                  		tmp = (x - z) / (t + t);
                  	} else {
                  		tmp = (y - z) / (t + t);
                  	}
                  	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 + y) <= (-1.2d-146)) then
                          tmp = (x - z) / (t + t)
                      else
                          tmp = (y - z) / (t + t)
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double x, double y, double z, double t) {
                  	double tmp;
                  	if ((x + y) <= -1.2e-146) {
                  		tmp = (x - z) / (t + t);
                  	} else {
                  		tmp = (y - z) / (t + t);
                  	}
                  	return tmp;
                  }
                  
                  def code(x, y, z, t):
                  	tmp = 0
                  	if (x + y) <= -1.2e-146:
                  		tmp = (x - z) / (t + t)
                  	else:
                  		tmp = (y - z) / (t + t)
                  	return tmp
                  
                  function code(x, y, z, t)
                  	tmp = 0.0
                  	if (Float64(x + y) <= -1.2e-146)
                  		tmp = Float64(Float64(x - z) / Float64(t + t));
                  	else
                  		tmp = Float64(Float64(y - z) / Float64(t + t));
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(x, y, z, t)
                  	tmp = 0.0;
                  	if ((x + y) <= -1.2e-146)
                  		tmp = (x - z) / (t + t);
                  	else
                  		tmp = (y - z) / (t + t);
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[x_, y_, z_, t_] := If[LessEqual[N[(x + y), $MachinePrecision], -1.2e-146], N[(N[(x - z), $MachinePrecision] / N[(t + t), $MachinePrecision]), $MachinePrecision], N[(N[(y - z), $MachinePrecision] / N[(t + t), $MachinePrecision]), $MachinePrecision]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;x + y \leq -1.2 \cdot 10^{-146}:\\
                  \;\;\;\;\frac{x - z}{t + t}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\frac{y - z}{t + t}\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if (+.f64 x y) < -1.2000000000000001e-146

                    1. Initial program 100.0%

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

                      \[\leadsto \frac{\color{blue}{x - z}}{t \cdot 2} \]
                    4. Step-by-step derivation
                      1. lower--.f6466.2

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

                      \[\leadsto \frac{\color{blue}{x - z}}{t \cdot 2} \]
                    6. Step-by-step derivation
                      1. lift-*.f64N/A

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

                        \[\leadsto \frac{x - z}{\color{blue}{2 \cdot t}} \]
                      3. count-2-revN/A

                        \[\leadsto \frac{x - z}{\color{blue}{t + t}} \]
                      4. lower-+.f6466.2

                        \[\leadsto \frac{x - z}{\color{blue}{t + t}} \]
                    7. Applied rewrites66.2%

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

                    if -1.2000000000000001e-146 < (+.f64 x y)

                    1. Initial program 100.0%

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

                      \[\leadsto \frac{\color{blue}{y - z}}{t \cdot 2} \]
                    4. Step-by-step derivation
                      1. lower--.f6470.5

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

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

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

                        \[\leadsto \frac{y - z}{\color{blue}{2 \cdot t}} \]
                      3. count-2-revN/A

                        \[\leadsto \frac{y - z}{\color{blue}{t + t}} \]
                      4. lower-+.f6470.5

                        \[\leadsto \frac{y - z}{\color{blue}{t + t}} \]
                    7. Applied rewrites70.5%

                      \[\leadsto \frac{y - z}{\color{blue}{t + t}} \]
                  3. Recombined 2 regimes into one program.
                  4. Add Preprocessing

                  Alternative 8: 75.7% accurate, 0.9× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x + y \leq 10^{+17}:\\ \;\;\;\;\frac{x - z}{t + t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y}{t + t}\\ \end{array} \end{array} \]
                  (FPCore (x y z t)
                   :precision binary64
                   (if (<= (+ x y) 1e+17) (/ (- x z) (+ t t)) (/ (+ x y) (+ t t))))
                  double code(double x, double y, double z, double t) {
                  	double tmp;
                  	if ((x + y) <= 1e+17) {
                  		tmp = (x - z) / (t + t);
                  	} else {
                  		tmp = (x + y) / (t + t);
                  	}
                  	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 + y) <= 1d+17) then
                          tmp = (x - z) / (t + t)
                      else
                          tmp = (x + y) / (t + t)
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double x, double y, double z, double t) {
                  	double tmp;
                  	if ((x + y) <= 1e+17) {
                  		tmp = (x - z) / (t + t);
                  	} else {
                  		tmp = (x + y) / (t + t);
                  	}
                  	return tmp;
                  }
                  
                  def code(x, y, z, t):
                  	tmp = 0
                  	if (x + y) <= 1e+17:
                  		tmp = (x - z) / (t + t)
                  	else:
                  		tmp = (x + y) / (t + t)
                  	return tmp
                  
                  function code(x, y, z, t)
                  	tmp = 0.0
                  	if (Float64(x + y) <= 1e+17)
                  		tmp = Float64(Float64(x - z) / Float64(t + t));
                  	else
                  		tmp = Float64(Float64(x + y) / Float64(t + t));
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(x, y, z, t)
                  	tmp = 0.0;
                  	if ((x + y) <= 1e+17)
                  		tmp = (x - z) / (t + t);
                  	else
                  		tmp = (x + y) / (t + t);
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[x_, y_, z_, t_] := If[LessEqual[N[(x + y), $MachinePrecision], 1e+17], N[(N[(x - z), $MachinePrecision] / N[(t + t), $MachinePrecision]), $MachinePrecision], N[(N[(x + y), $MachinePrecision] / N[(t + t), $MachinePrecision]), $MachinePrecision]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;x + y \leq 10^{+17}:\\
                  \;\;\;\;\frac{x - z}{t + t}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\frac{x + y}{t + t}\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if (+.f64 x y) < 1e17

                    1. Initial program 100.0%

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

                      \[\leadsto \frac{\color{blue}{x - z}}{t \cdot 2} \]
                    4. Step-by-step derivation
                      1. lower--.f6470.4

                        \[\leadsto \frac{\color{blue}{x - z}}{t \cdot 2} \]
                    5. Applied rewrites70.4%

                      \[\leadsto \frac{\color{blue}{x - z}}{t \cdot 2} \]
                    6. Step-by-step derivation
                      1. lift-*.f64N/A

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

                        \[\leadsto \frac{x - z}{\color{blue}{2 \cdot t}} \]
                      3. count-2-revN/A

                        \[\leadsto \frac{x - z}{\color{blue}{t + t}} \]
                      4. lower-+.f6470.4

                        \[\leadsto \frac{x - z}{\color{blue}{t + t}} \]
                    7. Applied rewrites70.4%

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

                    if 1e17 < (+.f64 x y)

                    1. Initial program 100.0%

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

                      \[\leadsto \frac{\color{blue}{x - z}}{t \cdot 2} \]
                    4. Step-by-step derivation
                      1. lower--.f6460.7

                        \[\leadsto \frac{\color{blue}{x - z}}{t \cdot 2} \]
                    5. Applied rewrites60.7%

                      \[\leadsto \frac{\color{blue}{x - z}}{t \cdot 2} \]
                    6. Step-by-step derivation
                      1. lift-*.f64N/A

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

                        \[\leadsto \frac{x - z}{\color{blue}{2 \cdot t}} \]
                      3. count-2-revN/A

                        \[\leadsto \frac{x - z}{\color{blue}{t + t}} \]
                      4. lower-+.f6460.7

                        \[\leadsto \frac{x - z}{\color{blue}{t + t}} \]
                    7. Applied rewrites60.7%

                      \[\leadsto \frac{x - z}{\color{blue}{t + t}} \]
                    8. Taylor expanded in z around 0

                      \[\leadsto \frac{\color{blue}{x + y}}{t + t} \]
                    9. Step-by-step derivation
                      1. lower-+.f6488.2

                        \[\leadsto \frac{\color{blue}{x + y}}{t + t} \]
                    10. Applied rewrites88.2%

                      \[\leadsto \frac{\color{blue}{x + y}}{t + t} \]
                  3. Recombined 2 regimes into one program.
                  4. Add Preprocessing

                  Alternative 9: 37.7% accurate, 1.4× speedup?

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

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

                    \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{x}{t}} \]
                  4. Step-by-step derivation
                    1. *-commutativeN/A

                      \[\leadsto \color{blue}{\frac{x}{t} \cdot \frac{1}{2}} \]
                    2. lower-*.f64N/A

                      \[\leadsto \color{blue}{\frac{x}{t} \cdot \frac{1}{2}} \]
                    3. lower-/.f6437.7

                      \[\leadsto \color{blue}{\frac{x}{t}} \cdot 0.5 \]
                  5. Applied rewrites37.7%

                    \[\leadsto \color{blue}{\frac{x}{t} \cdot 0.5} \]
                  6. Step-by-step derivation
                    1. Applied rewrites37.6%

                      \[\leadsto x \cdot \color{blue}{\frac{0.5}{t}} \]
                    2. Add Preprocessing

                    Reproduce

                    ?
                    herbie shell --seed 2024320 
                    (FPCore (x y z t)
                      :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, B"
                      :precision binary64
                      (/ (- (+ x y) z) (* t 2.0)))