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

Percentage Accurate: 100.0% → 99.7%
Time: 6.1s
Alternatives: 9
Speedup: N/A×

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: 100.0% 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.7% accurate, 1.0× speedup?

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

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

    \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
  2. Step-by-step derivation
    1. sub-neg99.6%

      \[\leadsto \frac{\color{blue}{\left(x + y\right) + \left(-z\right)}}{t \cdot 2} \]
    2. +-commutative99.6%

      \[\leadsto \frac{\color{blue}{\left(-z\right) + \left(x + y\right)}}{t \cdot 2} \]
    3. neg-sub099.6%

      \[\leadsto \frac{\color{blue}{\left(0 - z\right)} + \left(x + y\right)}{t \cdot 2} \]
    4. associate-+l-99.6%

      \[\leadsto \frac{\color{blue}{0 - \left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
    5. sub0-neg99.6%

      \[\leadsto \frac{\color{blue}{-\left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
    6. neg-mul-199.6%

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{-1}{2}}{t}} \cdot \left(z - \left(x + y\right)\right) \]
    10. metadata-eval99.7%

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

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

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

Alternative 2: 81.6% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.4 \cdot 10^{+171} \lor \neg \left(z \leq 2.15 \cdot 10^{+120}\right):\\
\;\;\;\;-0.5 \cdot \frac{z}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.4000000000000001e171 or 2.1500000000000001e120 < z

    1. Initial program 98.9%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Step-by-step derivation
      1. sub-neg98.9%

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

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

        \[\leadsto \frac{\color{blue}{\left(0 - z\right)} + \left(x + y\right)}{t \cdot 2} \]
      4. associate-+l-98.9%

        \[\leadsto \frac{\color{blue}{0 - \left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      5. sub0-neg98.9%

        \[\leadsto \frac{\color{blue}{-\left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      6. neg-mul-198.9%

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

        \[\leadsto \color{blue}{\frac{-1}{t \cdot 2} \cdot \left(z - \left(x + y\right)\right)} \]
      8. *-commutative98.6%

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

        \[\leadsto \color{blue}{\frac{\frac{-1}{2}}{t}} \cdot \left(z - \left(x + y\right)\right) \]
      10. metadata-eval99.7%

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

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

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

    if -3.4000000000000001e171 < z < 2.1500000000000001e120

    1. Initial program 100.0%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\left(0 - z\right)} + \left(x + y\right)}{t \cdot 2} \]
      4. associate-+l-100.0%

        \[\leadsto \frac{\color{blue}{0 - \left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      5. sub0-neg100.0%

        \[\leadsto \frac{\color{blue}{-\left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      6. neg-mul-1100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{t \cdot 2} \cdot \left(z - \left(x + y\right)\right)} \]
      8. *-commutative99.6%

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

        \[\leadsto \color{blue}{\frac{\frac{-1}{2}}{t}} \cdot \left(z - \left(x + y\right)\right) \]
      10. metadata-eval99.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.4 \cdot 10^{+171} \lor \neg \left(z \leq 2.15 \cdot 10^{+120}\right):\\ \;\;\;\;-0.5 \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x + y}{t}\\ \end{array} \]

Alternative 3: 47.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{-164}:\\
\;\;\;\;0.5 \cdot \frac{x}{t}\\

\mathbf{elif}\;y \leq 1.9 \cdot 10^{+52}:\\
\;\;\;\;-0.5 \cdot \frac{z}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.4000000000000001e-164

    1. Initial program 99.0%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Step-by-step derivation
      1. sub-neg99.0%

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

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

        \[\leadsto \frac{\color{blue}{\left(0 - z\right)} + \left(x + y\right)}{t \cdot 2} \]
      4. associate-+l-99.0%

        \[\leadsto \frac{\color{blue}{0 - \left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      5. sub0-neg99.0%

        \[\leadsto \frac{\color{blue}{-\left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      6. neg-mul-199.0%

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

        \[\leadsto \color{blue}{\frac{-1}{t \cdot 2} \cdot \left(z - \left(x + y\right)\right)} \]
      8. *-commutative98.7%

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

        \[\leadsto \color{blue}{\frac{\frac{-1}{2}}{t}} \cdot \left(z - \left(x + y\right)\right) \]
      10. metadata-eval99.6%

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

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

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

    if -1.4000000000000001e-164 < y < 1.9e52

    1. Initial program 100.0%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\left(0 - z\right)} + \left(x + y\right)}{t \cdot 2} \]
      4. associate-+l-100.0%

        \[\leadsto \frac{\color{blue}{0 - \left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      5. sub0-neg100.0%

        \[\leadsto \frac{\color{blue}{-\left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      6. neg-mul-1100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{t \cdot 2} \cdot \left(z - \left(x + y\right)\right)} \]
      8. *-commutative99.6%

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

        \[\leadsto \color{blue}{\frac{\frac{-1}{2}}{t}} \cdot \left(z - \left(x + y\right)\right) \]
      10. metadata-eval99.6%

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

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

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

    if 1.9e52 < y

    1. Initial program 100.0%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\left(0 - z\right)} + \left(x + y\right)}{t \cdot 2} \]
      4. associate-+l-100.0%

        \[\leadsto \frac{\color{blue}{0 - \left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      5. sub0-neg100.0%

        \[\leadsto \frac{\color{blue}{-\left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      6. neg-mul-1100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{t \cdot 2} \cdot \left(z - \left(x + y\right)\right)} \]
      8. *-commutative99.8%

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

        \[\leadsto \color{blue}{\frac{\frac{-1}{2}}{t}} \cdot \left(z - \left(x + y\right)\right) \]
      10. metadata-eval99.8%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{y}{t}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification49.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.4 \cdot 10^{-164}:\\ \;\;\;\;0.5 \cdot \frac{x}{t}\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{+52}:\\ \;\;\;\;-0.5 \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{t}\\ \end{array} \]

Alternative 4: 47.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.1 \cdot 10^{-151}:\\
\;\;\;\;x \cdot \frac{0.5}{t}\\

\mathbf{elif}\;y \leq 1.9 \cdot 10^{+52}:\\
\;\;\;\;-0.5 \cdot \frac{z}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.0999999999999999e-151

    1. Initial program 99.0%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Step-by-step derivation
      1. sub-neg99.0%

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

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

        \[\leadsto \frac{\color{blue}{\left(0 - z\right)} + \left(x + y\right)}{t \cdot 2} \]
      4. associate-+l-99.0%

        \[\leadsto \frac{\color{blue}{0 - \left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      5. sub0-neg99.0%

        \[\leadsto \frac{\color{blue}{-\left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      6. neg-mul-199.0%

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

        \[\leadsto \color{blue}{\frac{-1}{t \cdot 2} \cdot \left(z - \left(x + y\right)\right)} \]
      8. *-commutative98.7%

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

        \[\leadsto \color{blue}{\frac{\frac{-1}{2}}{t}} \cdot \left(z - \left(x + y\right)\right) \]
      10. metadata-eval99.6%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{x}{t}} \]
    5. Step-by-step derivation
      1. *-commutative38.0%

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

        \[\leadsto \color{blue}{\frac{x \cdot 0.5}{t}} \]
      3. associate-*r/38.6%

        \[\leadsto \color{blue}{x \cdot \frac{0.5}{t}} \]
    6. Simplified38.6%

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

    if -2.0999999999999999e-151 < y < 1.9e52

    1. Initial program 100.0%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\left(0 - z\right)} + \left(x + y\right)}{t \cdot 2} \]
      4. associate-+l-100.0%

        \[\leadsto \frac{\color{blue}{0 - \left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      5. sub0-neg100.0%

        \[\leadsto \frac{\color{blue}{-\left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      6. neg-mul-1100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{t \cdot 2} \cdot \left(z - \left(x + y\right)\right)} \]
      8. *-commutative99.6%

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

        \[\leadsto \color{blue}{\frac{\frac{-1}{2}}{t}} \cdot \left(z - \left(x + y\right)\right) \]
      10. metadata-eval99.6%

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

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

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

    if 1.9e52 < y

    1. Initial program 100.0%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\left(0 - z\right)} + \left(x + y\right)}{t \cdot 2} \]
      4. associate-+l-100.0%

        \[\leadsto \frac{\color{blue}{0 - \left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      5. sub0-neg100.0%

        \[\leadsto \frac{\color{blue}{-\left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      6. neg-mul-1100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{t \cdot 2} \cdot \left(z - \left(x + y\right)\right)} \]
      8. *-commutative99.8%

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

        \[\leadsto \color{blue}{\frac{\frac{-1}{2}}{t}} \cdot \left(z - \left(x + y\right)\right) \]
      10. metadata-eval99.8%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{y}{t}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification50.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.1 \cdot 10^{-151}:\\ \;\;\;\;x \cdot \frac{0.5}{t}\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{+52}:\\ \;\;\;\;-0.5 \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{t}\\ \end{array} \]

Alternative 5: 47.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.85 \cdot 10^{-157}:\\
\;\;\;\;\frac{x \cdot 0.5}{t}\\

\mathbf{elif}\;y \leq 1.15 \cdot 10^{+52}:\\
\;\;\;\;-0.5 \cdot \frac{z}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.84999999999999999e-157

    1. Initial program 99.0%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Step-by-step derivation
      1. sub-neg99.0%

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

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

        \[\leadsto \frac{\color{blue}{\left(0 - z\right)} + \left(x + y\right)}{t \cdot 2} \]
      4. associate-+l-99.0%

        \[\leadsto \frac{\color{blue}{0 - \left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      5. sub0-neg99.0%

        \[\leadsto \frac{\color{blue}{-\left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      6. neg-mul-199.0%

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

        \[\leadsto \color{blue}{\frac{-1}{t \cdot 2} \cdot \left(z - \left(x + y\right)\right)} \]
      8. *-commutative98.7%

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

        \[\leadsto \color{blue}{\frac{\frac{-1}{2}}{t}} \cdot \left(z - \left(x + y\right)\right) \]
      10. metadata-eval99.6%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{x}{t}} \]
    5. Step-by-step derivation
      1. associate-*r/38.4%

        \[\leadsto \color{blue}{\frac{0.5 \cdot x}{t}} \]
    6. Applied egg-rr38.4%

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

    if -2.84999999999999999e-157 < y < 1.15e52

    1. Initial program 100.0%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\left(0 - z\right)} + \left(x + y\right)}{t \cdot 2} \]
      4. associate-+l-100.0%

        \[\leadsto \frac{\color{blue}{0 - \left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      5. sub0-neg100.0%

        \[\leadsto \frac{\color{blue}{-\left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      6. neg-mul-1100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{t \cdot 2} \cdot \left(z - \left(x + y\right)\right)} \]
      8. *-commutative99.6%

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

        \[\leadsto \color{blue}{\frac{\frac{-1}{2}}{t}} \cdot \left(z - \left(x + y\right)\right) \]
      10. metadata-eval99.6%

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

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

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

    if 1.15e52 < y

    1. Initial program 100.0%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\left(0 - z\right)} + \left(x + y\right)}{t \cdot 2} \]
      4. associate-+l-100.0%

        \[\leadsto \frac{\color{blue}{0 - \left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      5. sub0-neg100.0%

        \[\leadsto \frac{\color{blue}{-\left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      6. neg-mul-1100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{t \cdot 2} \cdot \left(z - \left(x + y\right)\right)} \]
      8. *-commutative99.8%

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

        \[\leadsto \color{blue}{\frac{\frac{-1}{2}}{t}} \cdot \left(z - \left(x + y\right)\right) \]
      10. metadata-eval99.8%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{y}{t}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification50.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.85 \cdot 10^{-157}:\\ \;\;\;\;\frac{x \cdot 0.5}{t}\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{+52}:\\ \;\;\;\;-0.5 \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{t}\\ \end{array} \]

Alternative 6: 78.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.65 \cdot 10^{+52}:\\
\;\;\;\;0.5 \cdot \frac{x - z}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.65e52

    1. Initial program 99.5%

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

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

    if 1.65e52 < y

    1. Initial program 100.0%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\left(0 - z\right)} + \left(x + y\right)}{t \cdot 2} \]
      4. associate-+l-100.0%

        \[\leadsto \frac{\color{blue}{0 - \left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      5. sub0-neg100.0%

        \[\leadsto \frac{\color{blue}{-\left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      6. neg-mul-1100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{t \cdot 2} \cdot \left(z - \left(x + y\right)\right)} \]
      8. *-commutative99.8%

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

        \[\leadsto \color{blue}{\frac{\frac{-1}{2}}{t}} \cdot \left(z - \left(x + y\right)\right) \]
      10. metadata-eval99.8%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{y + x}{t}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification80.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.65 \cdot 10^{+52}:\\ \;\;\;\;0.5 \cdot \frac{x - z}{t}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x + y}{t}\\ \end{array} \]

Alternative 7: 77.4% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{-60}:\\
\;\;\;\;0.5 \cdot \frac{x - z}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.7e-60

    1. Initial program 100.0%

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

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

    if -2.7e-60 < x

    1. Initial program 99.4%

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{y - z}{t}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification79.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{-60}:\\ \;\;\;\;0.5 \cdot \frac{x - z}{t}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y - z}{t}\\ \end{array} \]

Alternative 8: 46.2% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.6 \cdot 10^{+139}:\\
\;\;\;\;0.5 \cdot \frac{x}{t}\\

\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{z}{t}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.60000000000000022e139

    1. Initial program 99.9%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Step-by-step derivation
      1. sub-neg99.9%

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

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

        \[\leadsto \frac{\color{blue}{\left(0 - z\right)} + \left(x + y\right)}{t \cdot 2} \]
      4. associate-+l-99.9%

        \[\leadsto \frac{\color{blue}{0 - \left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      5. sub0-neg99.9%

        \[\leadsto \frac{\color{blue}{-\left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      6. neg-mul-199.9%

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

        \[\leadsto \color{blue}{\frac{-1}{t \cdot 2} \cdot \left(z - \left(x + y\right)\right)} \]
      8. *-commutative99.6%

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

        \[\leadsto \color{blue}{\frac{\frac{-1}{2}}{t}} \cdot \left(z - \left(x + y\right)\right) \]
      10. metadata-eval99.6%

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

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

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

    if -2.60000000000000022e139 < x

    1. Initial program 99.5%

      \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
    2. Step-by-step derivation
      1. sub-neg99.5%

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

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

        \[\leadsto \frac{\color{blue}{\left(0 - z\right)} + \left(x + y\right)}{t \cdot 2} \]
      4. associate-+l-99.5%

        \[\leadsto \frac{\color{blue}{0 - \left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      5. sub0-neg99.5%

        \[\leadsto \frac{\color{blue}{-\left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
      6. neg-mul-199.5%

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

        \[\leadsto \color{blue}{\frac{-1}{t \cdot 2} \cdot \left(z - \left(x + y\right)\right)} \]
      8. *-commutative99.2%

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

        \[\leadsto \color{blue}{\frac{\frac{-1}{2}}{t}} \cdot \left(z - \left(x + y\right)\right) \]
      10. metadata-eval99.7%

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

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{z}{t}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification52.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.6 \cdot 10^{+139}:\\ \;\;\;\;0.5 \cdot \frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{z}{t}\\ \end{array} \]

Alternative 9: 37.9% accurate, 1.8× speedup?

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

\\
-0.5 \cdot \frac{z}{t}
\end{array}
Derivation
  1. Initial program 99.6%

    \[\frac{\left(x + y\right) - z}{t \cdot 2} \]
  2. Step-by-step derivation
    1. sub-neg99.6%

      \[\leadsto \frac{\color{blue}{\left(x + y\right) + \left(-z\right)}}{t \cdot 2} \]
    2. +-commutative99.6%

      \[\leadsto \frac{\color{blue}{\left(-z\right) + \left(x + y\right)}}{t \cdot 2} \]
    3. neg-sub099.6%

      \[\leadsto \frac{\color{blue}{\left(0 - z\right)} + \left(x + y\right)}{t \cdot 2} \]
    4. associate-+l-99.6%

      \[\leadsto \frac{\color{blue}{0 - \left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
    5. sub0-neg99.6%

      \[\leadsto \frac{\color{blue}{-\left(z - \left(x + y\right)\right)}}{t \cdot 2} \]
    6. neg-mul-199.6%

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{-1}{2}}{t}} \cdot \left(z - \left(x + y\right)\right) \]
    10. metadata-eval99.7%

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

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

    \[\leadsto \color{blue}{-0.5 \cdot \frac{z}{t}} \]
  5. Final simplification39.2%

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

Reproduce

?
herbie shell --seed 2023196 
(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)))