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

Percentage Accurate: 99.9% → 99.9%
Time: 7.1s
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. Final simplification100.0%

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

Alternative 2: 46.5% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := -0.5 \cdot \frac{z}{t}\\ t_2 := \frac{x \cdot 0.5}{t}\\ \mathbf{if}\;y \leq -5 \cdot 10^{+17}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;y \leq -3.7 \cdot 10^{-61}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq -6.8 \cdot 10^{-271}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-230}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{-209}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-107}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 6.8 \cdot 10^{-90}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;y \leq 4.9 \cdot 10^{+117}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{t}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* -0.5 (/ z t))) (t_2 (/ (* x 0.5) t)))
   (if (<= y -5e+17)
     t_2
     (if (<= y -3.7e-61)
       t_1
       (if (<= y -6.8e-271)
         t_2
         (if (<= y 1.4e-230)
           t_1
           (if (<= y 2.5e-209)
             t_2
             (if (<= y 8.5e-107)
               t_1
               (if (<= y 6.8e-90)
                 t_2
                 (if (<= y 4.9e+117) t_1 (* 0.5 (/ y t))))))))))))
double code(double x, double y, double z, double t) {
	double t_1 = -0.5 * (z / t);
	double t_2 = (x * 0.5) / t;
	double tmp;
	if (y <= -5e+17) {
		tmp = t_2;
	} else if (y <= -3.7e-61) {
		tmp = t_1;
	} else if (y <= -6.8e-271) {
		tmp = t_2;
	} else if (y <= 1.4e-230) {
		tmp = t_1;
	} else if (y <= 2.5e-209) {
		tmp = t_2;
	} else if (y <= 8.5e-107) {
		tmp = t_1;
	} else if (y <= 6.8e-90) {
		tmp = t_2;
	} else if (y <= 4.9e+117) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = (-0.5d0) * (z / t)
    t_2 = (x * 0.5d0) / t
    if (y <= (-5d+17)) then
        tmp = t_2
    else if (y <= (-3.7d-61)) then
        tmp = t_1
    else if (y <= (-6.8d-271)) then
        tmp = t_2
    else if (y <= 1.4d-230) then
        tmp = t_1
    else if (y <= 2.5d-209) then
        tmp = t_2
    else if (y <= 8.5d-107) then
        tmp = t_1
    else if (y <= 6.8d-90) then
        tmp = t_2
    else if (y <= 4.9d+117) then
        tmp = t_1
    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 t_1 = -0.5 * (z / t);
	double t_2 = (x * 0.5) / t;
	double tmp;
	if (y <= -5e+17) {
		tmp = t_2;
	} else if (y <= -3.7e-61) {
		tmp = t_1;
	} else if (y <= -6.8e-271) {
		tmp = t_2;
	} else if (y <= 1.4e-230) {
		tmp = t_1;
	} else if (y <= 2.5e-209) {
		tmp = t_2;
	} else if (y <= 8.5e-107) {
		tmp = t_1;
	} else if (y <= 6.8e-90) {
		tmp = t_2;
	} else if (y <= 4.9e+117) {
		tmp = t_1;
	} else {
		tmp = 0.5 * (y / t);
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = -0.5 * (z / t)
	t_2 = (x * 0.5) / t
	tmp = 0
	if y <= -5e+17:
		tmp = t_2
	elif y <= -3.7e-61:
		tmp = t_1
	elif y <= -6.8e-271:
		tmp = t_2
	elif y <= 1.4e-230:
		tmp = t_1
	elif y <= 2.5e-209:
		tmp = t_2
	elif y <= 8.5e-107:
		tmp = t_1
	elif y <= 6.8e-90:
		tmp = t_2
	elif y <= 4.9e+117:
		tmp = t_1
	else:
		tmp = 0.5 * (y / t)
	return tmp
function code(x, y, z, t)
	t_1 = Float64(-0.5 * Float64(z / t))
	t_2 = Float64(Float64(x * 0.5) / t)
	tmp = 0.0
	if (y <= -5e+17)
		tmp = t_2;
	elseif (y <= -3.7e-61)
		tmp = t_1;
	elseif (y <= -6.8e-271)
		tmp = t_2;
	elseif (y <= 1.4e-230)
		tmp = t_1;
	elseif (y <= 2.5e-209)
		tmp = t_2;
	elseif (y <= 8.5e-107)
		tmp = t_1;
	elseif (y <= 6.8e-90)
		tmp = t_2;
	elseif (y <= 4.9e+117)
		tmp = t_1;
	else
		tmp = Float64(0.5 * Float64(y / t));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = -0.5 * (z / t);
	t_2 = (x * 0.5) / t;
	tmp = 0.0;
	if (y <= -5e+17)
		tmp = t_2;
	elseif (y <= -3.7e-61)
		tmp = t_1;
	elseif (y <= -6.8e-271)
		tmp = t_2;
	elseif (y <= 1.4e-230)
		tmp = t_1;
	elseif (y <= 2.5e-209)
		tmp = t_2;
	elseif (y <= 8.5e-107)
		tmp = t_1;
	elseif (y <= 6.8e-90)
		tmp = t_2;
	elseif (y <= 4.9e+117)
		tmp = t_1;
	else
		tmp = 0.5 * (y / t);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(-0.5 * N[(z / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * 0.5), $MachinePrecision] / t), $MachinePrecision]}, If[LessEqual[y, -5e+17], t$95$2, If[LessEqual[y, -3.7e-61], t$95$1, If[LessEqual[y, -6.8e-271], t$95$2, If[LessEqual[y, 1.4e-230], t$95$1, If[LessEqual[y, 2.5e-209], t$95$2, If[LessEqual[y, 8.5e-107], t$95$1, If[LessEqual[y, 6.8e-90], t$95$2, If[LessEqual[y, 4.9e+117], t$95$1, N[(0.5 * N[(y / t), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := -0.5 \cdot \frac{z}{t}\\
t_2 := \frac{x \cdot 0.5}{t}\\
\mathbf{if}\;y \leq -5 \cdot 10^{+17}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;y \leq -3.7 \cdot 10^{-61}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq -6.8 \cdot 10^{-271}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;y \leq 1.4 \cdot 10^{-230}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 2.5 \cdot 10^{-209}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;y \leq 8.5 \cdot 10^{-107}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 6.8 \cdot 10^{-90}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;y \leq 4.9 \cdot 10^{+117}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -5e17 or -3.7e-61 < y < -6.8000000000000001e-271 or 1.4e-230 < y < 2.5000000000000002e-209 or 8.49999999999999956e-107 < y < 6.79999999999999988e-90

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(z - y\right) - x}{\color{blue}{-t \cdot 2}} \]
      13. distribute-rgt-neg-in100.0%

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

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

      \[\leadsto \color{blue}{\frac{\left(z - y\right) - x}{t \cdot -2}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 44.8%

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot x}{t}} \]
    7. Simplified44.8%

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

    if -5e17 < y < -3.7e-61 or -6.8000000000000001e-271 < y < 1.4e-230 or 2.5000000000000002e-209 < y < 8.49999999999999956e-107 or 6.79999999999999988e-90 < y < 4.9000000000000001e117

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(z - y\right) - x}{\color{blue}{-t \cdot 2}} \]
      13. distribute-rgt-neg-in100.0%

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

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

      \[\leadsto \color{blue}{\frac{\left(z - y\right) - x}{t \cdot -2}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 57.9%

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

    if 4.9000000000000001e117 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(z - y\right) - x}{\color{blue}{-t \cdot 2}} \]
      13. distribute-rgt-neg-in100.0%

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

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

      \[\leadsto \color{blue}{\frac{\left(z - y\right) - x}{t \cdot -2}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 88.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{+17}:\\ \;\;\;\;\frac{x \cdot 0.5}{t}\\ \mathbf{elif}\;y \leq -3.7 \cdot 10^{-61}:\\ \;\;\;\;-0.5 \cdot \frac{z}{t}\\ \mathbf{elif}\;y \leq -6.8 \cdot 10^{-271}:\\ \;\;\;\;\frac{x \cdot 0.5}{t}\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-230}:\\ \;\;\;\;-0.5 \cdot \frac{z}{t}\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{-209}:\\ \;\;\;\;\frac{x \cdot 0.5}{t}\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-107}:\\ \;\;\;\;-0.5 \cdot \frac{z}{t}\\ \mathbf{elif}\;y \leq 6.8 \cdot 10^{-90}:\\ \;\;\;\;\frac{x \cdot 0.5}{t}\\ \mathbf{elif}\;y \leq 4.9 \cdot 10^{+117}:\\ \;\;\;\;-0.5 \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 46.4% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := -0.5 \cdot \frac{z}{t}\\ t_2 := \frac{x \cdot 0.5}{t}\\ \mathbf{if}\;y \leq -5.5 \cdot 10^{+17}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;y \leq -9 \cdot 10^{-60}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq -1.12 \cdot 10^{-281}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{-232}:\\ \;\;\;\;\frac{\frac{z}{-2}}{t}\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-205}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;y \leq 10^{-106}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{-90}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{+117}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{t}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* -0.5 (/ z t))) (t_2 (/ (* x 0.5) t)))
   (if (<= y -5.5e+17)
     t_2
     (if (<= y -9e-60)
       t_1
       (if (<= y -1.12e-281)
         t_2
         (if (<= y 8.2e-232)
           (/ (/ z -2.0) t)
           (if (<= y 2e-205)
             t_2
             (if (<= y 1e-106)
               t_1
               (if (<= y 5.4e-90)
                 t_2
                 (if (<= y 2.7e+117) t_1 (* 0.5 (/ y t))))))))))))
double code(double x, double y, double z, double t) {
	double t_1 = -0.5 * (z / t);
	double t_2 = (x * 0.5) / t;
	double tmp;
	if (y <= -5.5e+17) {
		tmp = t_2;
	} else if (y <= -9e-60) {
		tmp = t_1;
	} else if (y <= -1.12e-281) {
		tmp = t_2;
	} else if (y <= 8.2e-232) {
		tmp = (z / -2.0) / t;
	} else if (y <= 2e-205) {
		tmp = t_2;
	} else if (y <= 1e-106) {
		tmp = t_1;
	} else if (y <= 5.4e-90) {
		tmp = t_2;
	} else if (y <= 2.7e+117) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = (-0.5d0) * (z / t)
    t_2 = (x * 0.5d0) / t
    if (y <= (-5.5d+17)) then
        tmp = t_2
    else if (y <= (-9d-60)) then
        tmp = t_1
    else if (y <= (-1.12d-281)) then
        tmp = t_2
    else if (y <= 8.2d-232) then
        tmp = (z / (-2.0d0)) / t
    else if (y <= 2d-205) then
        tmp = t_2
    else if (y <= 1d-106) then
        tmp = t_1
    else if (y <= 5.4d-90) then
        tmp = t_2
    else if (y <= 2.7d+117) then
        tmp = t_1
    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 t_1 = -0.5 * (z / t);
	double t_2 = (x * 0.5) / t;
	double tmp;
	if (y <= -5.5e+17) {
		tmp = t_2;
	} else if (y <= -9e-60) {
		tmp = t_1;
	} else if (y <= -1.12e-281) {
		tmp = t_2;
	} else if (y <= 8.2e-232) {
		tmp = (z / -2.0) / t;
	} else if (y <= 2e-205) {
		tmp = t_2;
	} else if (y <= 1e-106) {
		tmp = t_1;
	} else if (y <= 5.4e-90) {
		tmp = t_2;
	} else if (y <= 2.7e+117) {
		tmp = t_1;
	} else {
		tmp = 0.5 * (y / t);
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = -0.5 * (z / t)
	t_2 = (x * 0.5) / t
	tmp = 0
	if y <= -5.5e+17:
		tmp = t_2
	elif y <= -9e-60:
		tmp = t_1
	elif y <= -1.12e-281:
		tmp = t_2
	elif y <= 8.2e-232:
		tmp = (z / -2.0) / t
	elif y <= 2e-205:
		tmp = t_2
	elif y <= 1e-106:
		tmp = t_1
	elif y <= 5.4e-90:
		tmp = t_2
	elif y <= 2.7e+117:
		tmp = t_1
	else:
		tmp = 0.5 * (y / t)
	return tmp
function code(x, y, z, t)
	t_1 = Float64(-0.5 * Float64(z / t))
	t_2 = Float64(Float64(x * 0.5) / t)
	tmp = 0.0
	if (y <= -5.5e+17)
		tmp = t_2;
	elseif (y <= -9e-60)
		tmp = t_1;
	elseif (y <= -1.12e-281)
		tmp = t_2;
	elseif (y <= 8.2e-232)
		tmp = Float64(Float64(z / -2.0) / t);
	elseif (y <= 2e-205)
		tmp = t_2;
	elseif (y <= 1e-106)
		tmp = t_1;
	elseif (y <= 5.4e-90)
		tmp = t_2;
	elseif (y <= 2.7e+117)
		tmp = t_1;
	else
		tmp = Float64(0.5 * Float64(y / t));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = -0.5 * (z / t);
	t_2 = (x * 0.5) / t;
	tmp = 0.0;
	if (y <= -5.5e+17)
		tmp = t_2;
	elseif (y <= -9e-60)
		tmp = t_1;
	elseif (y <= -1.12e-281)
		tmp = t_2;
	elseif (y <= 8.2e-232)
		tmp = (z / -2.0) / t;
	elseif (y <= 2e-205)
		tmp = t_2;
	elseif (y <= 1e-106)
		tmp = t_1;
	elseif (y <= 5.4e-90)
		tmp = t_2;
	elseif (y <= 2.7e+117)
		tmp = t_1;
	else
		tmp = 0.5 * (y / t);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(-0.5 * N[(z / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * 0.5), $MachinePrecision] / t), $MachinePrecision]}, If[LessEqual[y, -5.5e+17], t$95$2, If[LessEqual[y, -9e-60], t$95$1, If[LessEqual[y, -1.12e-281], t$95$2, If[LessEqual[y, 8.2e-232], N[(N[(z / -2.0), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[y, 2e-205], t$95$2, If[LessEqual[y, 1e-106], t$95$1, If[LessEqual[y, 5.4e-90], t$95$2, If[LessEqual[y, 2.7e+117], t$95$1, N[(0.5 * N[(y / t), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := -0.5 \cdot \frac{z}{t}\\
t_2 := \frac{x \cdot 0.5}{t}\\
\mathbf{if}\;y \leq -5.5 \cdot 10^{+17}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;y \leq -9 \cdot 10^{-60}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq -1.12 \cdot 10^{-281}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;y \leq 8.2 \cdot 10^{-232}:\\
\;\;\;\;\frac{\frac{z}{-2}}{t}\\

\mathbf{elif}\;y \leq 2 \cdot 10^{-205}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;y \leq 10^{-106}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 5.4 \cdot 10^{-90}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;y \leq 2.7 \cdot 10^{+117}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -5.5e17 or -9.00000000000000001e-60 < y < -1.12e-281 or 8.19999999999999945e-232 < y < 2e-205 or 9.99999999999999941e-107 < y < 5.39999999999999993e-90

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(z - y\right) - x}{\color{blue}{-t \cdot 2}} \]
      13. distribute-rgt-neg-in100.0%

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

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

      \[\leadsto \color{blue}{\frac{\left(z - y\right) - x}{t \cdot -2}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 45.4%

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot x}{t}} \]
    7. Simplified45.4%

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

    if -5.5e17 < y < -9.00000000000000001e-60 or 2e-205 < y < 9.99999999999999941e-107 or 5.39999999999999993e-90 < y < 2.7000000000000002e117

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(z - y\right) - x}{\color{blue}{-t \cdot 2}} \]
      13. distribute-rgt-neg-in100.0%

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

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

      \[\leadsto \color{blue}{\frac{\left(z - y\right) - x}{t \cdot -2}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 50.6%

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

    if -1.12e-281 < y < 8.19999999999999945e-232

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(z - y\right) - x}{\color{blue}{-t \cdot 2}} \]
      13. distribute-rgt-neg-in100.0%

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

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

      \[\leadsto \color{blue}{\frac{\left(z - y\right) - x}{t \cdot -2}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 82.1%

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

        \[\leadsto \color{blue}{\frac{1}{-2}} \cdot \frac{z}{t} \]
      2. times-frac82.1%

        \[\leadsto \color{blue}{\frac{1 \cdot z}{-2 \cdot t}} \]
      3. *-un-lft-identity82.1%

        \[\leadsto \frac{\color{blue}{z}}{-2 \cdot t} \]
      4. associate-/r*82.1%

        \[\leadsto \color{blue}{\frac{\frac{z}{-2}}{t}} \]
    7. Applied egg-rr82.1%

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

    if 2.7000000000000002e117 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(z - y\right) - x}{\color{blue}{-t \cdot 2}} \]
      13. distribute-rgt-neg-in100.0%

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

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

      \[\leadsto \color{blue}{\frac{\left(z - y\right) - x}{t \cdot -2}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 88.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.5 \cdot 10^{+17}:\\ \;\;\;\;\frac{x \cdot 0.5}{t}\\ \mathbf{elif}\;y \leq -9 \cdot 10^{-60}:\\ \;\;\;\;-0.5 \cdot \frac{z}{t}\\ \mathbf{elif}\;y \leq -1.12 \cdot 10^{-281}:\\ \;\;\;\;\frac{x \cdot 0.5}{t}\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{-232}:\\ \;\;\;\;\frac{\frac{z}{-2}}{t}\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-205}:\\ \;\;\;\;\frac{x \cdot 0.5}{t}\\ \mathbf{elif}\;y \leq 10^{-106}:\\ \;\;\;\;-0.5 \cdot \frac{z}{t}\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{-90}:\\ \;\;\;\;\frac{x \cdot 0.5}{t}\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{+117}:\\ \;\;\;\;-0.5 \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 46.4% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := -0.5 \cdot \frac{z}{t}\\ t_2 := x \cdot \frac{0.5}{t}\\ \mathbf{if}\;y \leq -9.5 \cdot 10^{+18}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;y \leq -9.4 \cdot 10^{-60}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq -1.8 \cdot 10^{-274}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-106}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{-90}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{+118}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{t}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* -0.5 (/ z t))) (t_2 (* x (/ 0.5 t))))
   (if (<= y -9.5e+18)
     t_2
     (if (<= y -9.4e-60)
       t_1
       (if (<= y -1.8e-274)
         t_2
         (if (<= y 4.2e-106)
           t_1
           (if (<= y 3.5e-90)
             t_2
             (if (<= y 2.1e+118) t_1 (* 0.5 (/ y t))))))))))
double code(double x, double y, double z, double t) {
	double t_1 = -0.5 * (z / t);
	double t_2 = x * (0.5 / t);
	double tmp;
	if (y <= -9.5e+18) {
		tmp = t_2;
	} else if (y <= -9.4e-60) {
		tmp = t_1;
	} else if (y <= -1.8e-274) {
		tmp = t_2;
	} else if (y <= 4.2e-106) {
		tmp = t_1;
	} else if (y <= 3.5e-90) {
		tmp = t_2;
	} else if (y <= 2.1e+118) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = (-0.5d0) * (z / t)
    t_2 = x * (0.5d0 / t)
    if (y <= (-9.5d+18)) then
        tmp = t_2
    else if (y <= (-9.4d-60)) then
        tmp = t_1
    else if (y <= (-1.8d-274)) then
        tmp = t_2
    else if (y <= 4.2d-106) then
        tmp = t_1
    else if (y <= 3.5d-90) then
        tmp = t_2
    else if (y <= 2.1d+118) then
        tmp = t_1
    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 t_1 = -0.5 * (z / t);
	double t_2 = x * (0.5 / t);
	double tmp;
	if (y <= -9.5e+18) {
		tmp = t_2;
	} else if (y <= -9.4e-60) {
		tmp = t_1;
	} else if (y <= -1.8e-274) {
		tmp = t_2;
	} else if (y <= 4.2e-106) {
		tmp = t_1;
	} else if (y <= 3.5e-90) {
		tmp = t_2;
	} else if (y <= 2.1e+118) {
		tmp = t_1;
	} else {
		tmp = 0.5 * (y / t);
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = -0.5 * (z / t)
	t_2 = x * (0.5 / t)
	tmp = 0
	if y <= -9.5e+18:
		tmp = t_2
	elif y <= -9.4e-60:
		tmp = t_1
	elif y <= -1.8e-274:
		tmp = t_2
	elif y <= 4.2e-106:
		tmp = t_1
	elif y <= 3.5e-90:
		tmp = t_2
	elif y <= 2.1e+118:
		tmp = t_1
	else:
		tmp = 0.5 * (y / t)
	return tmp
function code(x, y, z, t)
	t_1 = Float64(-0.5 * Float64(z / t))
	t_2 = Float64(x * Float64(0.5 / t))
	tmp = 0.0
	if (y <= -9.5e+18)
		tmp = t_2;
	elseif (y <= -9.4e-60)
		tmp = t_1;
	elseif (y <= -1.8e-274)
		tmp = t_2;
	elseif (y <= 4.2e-106)
		tmp = t_1;
	elseif (y <= 3.5e-90)
		tmp = t_2;
	elseif (y <= 2.1e+118)
		tmp = t_1;
	else
		tmp = Float64(0.5 * Float64(y / t));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = -0.5 * (z / t);
	t_2 = x * (0.5 / t);
	tmp = 0.0;
	if (y <= -9.5e+18)
		tmp = t_2;
	elseif (y <= -9.4e-60)
		tmp = t_1;
	elseif (y <= -1.8e-274)
		tmp = t_2;
	elseif (y <= 4.2e-106)
		tmp = t_1;
	elseif (y <= 3.5e-90)
		tmp = t_2;
	elseif (y <= 2.1e+118)
		tmp = t_1;
	else
		tmp = 0.5 * (y / t);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(-0.5 * N[(z / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(0.5 / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -9.5e+18], t$95$2, If[LessEqual[y, -9.4e-60], t$95$1, If[LessEqual[y, -1.8e-274], t$95$2, If[LessEqual[y, 4.2e-106], t$95$1, If[LessEqual[y, 3.5e-90], t$95$2, If[LessEqual[y, 2.1e+118], t$95$1, N[(0.5 * N[(y / t), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := -0.5 \cdot \frac{z}{t}\\
t_2 := x \cdot \frac{0.5}{t}\\
\mathbf{if}\;y \leq -9.5 \cdot 10^{+18}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;y \leq -9.4 \cdot 10^{-60}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq -1.8 \cdot 10^{-274}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;y \leq 4.2 \cdot 10^{-106}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 3.5 \cdot 10^{-90}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;y \leq 2.1 \cdot 10^{+118}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -9.5e18 or -9.4e-60 < y < -1.79999999999999991e-274 or 4.20000000000000007e-106 < y < 3.4999999999999999e-90

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(z - y\right) - x}{\color{blue}{-t \cdot 2}} \]
      13. distribute-rgt-neg-in100.0%

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

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

      \[\leadsto \color{blue}{\frac{\left(z - y\right) - x}{t \cdot -2}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 43.6%

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

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

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

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

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

    if -9.5e18 < y < -9.4e-60 or -1.79999999999999991e-274 < y < 4.20000000000000007e-106 or 3.4999999999999999e-90 < y < 2.1e118

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(z - y\right) - x}{\color{blue}{-t \cdot 2}} \]
      13. distribute-rgt-neg-in100.0%

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

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

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

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

    if 2.1e118 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(z - y\right) - x}{\color{blue}{-t \cdot 2}} \]
      13. distribute-rgt-neg-in100.0%

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

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

      \[\leadsto \color{blue}{\frac{\left(z - y\right) - x}{t \cdot -2}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 88.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.5 \cdot 10^{+18}:\\ \;\;\;\;x \cdot \frac{0.5}{t}\\ \mathbf{elif}\;y \leq -9.4 \cdot 10^{-60}:\\ \;\;\;\;-0.5 \cdot \frac{z}{t}\\ \mathbf{elif}\;y \leq -1.8 \cdot 10^{-274}:\\ \;\;\;\;x \cdot \frac{0.5}{t}\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-106}:\\ \;\;\;\;-0.5 \cdot \frac{z}{t}\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{-90}:\\ \;\;\;\;x \cdot \frac{0.5}{t}\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{+118}:\\ \;\;\;\;-0.5 \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y}{t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 75.0% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.2 \cdot 10^{+132} \lor \neg \left(x \leq -2 \cdot 10^{+103}\right) \land x \leq -4.6 \cdot 10^{+58}:\\
\;\;\;\;\frac{x \cdot 0.5}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -8.19999999999999983e132 or -2e103 < x < -4.60000000000000005e58

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(z - y\right) - x}{\color{blue}{-t \cdot 2}} \]
      13. distribute-rgt-neg-in100.0%

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

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

      \[\leadsto \color{blue}{\frac{\left(z - y\right) - x}{t \cdot -2}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 82.9%

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot x}{t}} \]
    7. Simplified82.9%

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

    if -8.19999999999999983e132 < x < -2e103 or -4.60000000000000005e58 < x

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(z - y\right) - x}{\color{blue}{-t \cdot 2}} \]
      13. distribute-rgt-neg-in100.0%

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

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

      \[\leadsto \color{blue}{\frac{\left(z - y\right) - x}{t \cdot -2}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 82.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -8.2 \cdot 10^{+132} \lor \neg \left(x \leq -2 \cdot 10^{+103}\right) \land x \leq -4.6 \cdot 10^{+58}:\\ \;\;\;\;\frac{x \cdot 0.5}{t}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{z - y}{t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 56.2% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.75 \cdot 10^{+19} \lor \neg \left(y \leq 2.8 \cdot 10^{+117}\right):\\
\;\;\;\;0.5 \cdot \frac{y}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.75e19 or 2.79999999999999997e117 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(z - y\right) - x}{\color{blue}{-t \cdot 2}} \]
      13. distribute-rgt-neg-in100.0%

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

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

      \[\leadsto \color{blue}{\frac{\left(z - y\right) - x}{t \cdot -2}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 73.6%

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

    if -1.75e19 < y < 2.79999999999999997e117

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(z - y\right) - x}{\color{blue}{-t \cdot 2}} \]
      13. distribute-rgt-neg-in100.0%

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

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

      \[\leadsto \color{blue}{\frac{\left(z - y\right) - x}{t \cdot -2}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 51.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.75 \cdot 10^{+19} \lor \neg \left(y \leq 2.8 \cdot 10^{+117}\right):\\ \;\;\;\;0.5 \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{z}{t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 68.4% accurate, 0.6× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 x y) < -9.99999999999999983e-171

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(z - y\right) - x}{\color{blue}{-t \cdot 2}} \]
      13. distribute-rgt-neg-in100.0%

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

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

      \[\leadsto \color{blue}{\frac{\left(z - y\right) - x}{t \cdot -2}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 69.0%

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot \left(z - x\right)}{t}} \]
      2. associate-/l*68.8%

        \[\leadsto \color{blue}{\frac{-0.5}{\frac{t}{z - x}}} \]
      3. associate-/r/68.9%

        \[\leadsto \color{blue}{\frac{-0.5}{t} \cdot \left(z - x\right)} \]
    7. Simplified68.9%

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

    if -9.99999999999999983e-171 < (+.f64 x y)

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(z - y\right) - x}{\color{blue}{-t \cdot 2}} \]
      13. distribute-rgt-neg-in100.0%

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

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

      \[\leadsto \color{blue}{\frac{\left(z - y\right) - x}{t \cdot -2}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 76.3%

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

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

Alternative 8: 78.1% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(z - y\right) - x}{\color{blue}{-t \cdot 2}} \]
      13. distribute-rgt-neg-in100.0%

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

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

      \[\leadsto \color{blue}{\frac{\left(z - y\right) - x}{t \cdot -2}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 87.3%

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

    if -2.8999999999999998e51 < x

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(z - y\right) - x}{\color{blue}{-t \cdot 2}} \]
      13. distribute-rgt-neg-in100.0%

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

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

      \[\leadsto \color{blue}{\frac{\left(z - y\right) - x}{t \cdot -2}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 82.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.9 \cdot 10^{+51}:\\ \;\;\;\;0.5 \cdot \frac{x + y}{t}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{z - y}{t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 37.7% 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 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\left(z - y\right) - x}{\color{blue}{-t \cdot 2}} \]
    13. distribute-rgt-neg-in100.0%

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

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

    \[\leadsto \color{blue}{\frac{\left(z - y\right) - x}{t \cdot -2}} \]
  4. Add Preprocessing
  5. Taylor expanded in z around inf 39.8%

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

    \[\leadsto -0.5 \cdot \frac{z}{t} \]
  7. Add Preprocessing

Reproduce

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