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

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

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

Alternative 2: 46.4% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.3 \cdot 10^{-19}:\\
\;\;\;\;0.5 \cdot \frac{x}{t}\\

\mathbf{elif}\;x \leq -3.7 \cdot 10^{-88} \lor \neg \left(x \leq -1.85 \cdot 10^{-292}\right) \land \left(x \leq 2.2 \cdot 10^{-144} \lor \neg \left(x \leq 7.5 \cdot 10^{-98}\right)\right):\\
\;\;\;\;y \cdot \frac{0.5}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -6.30000000000000018e-19

    1. Initial program 100.0%

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

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

    if -6.30000000000000018e-19 < x < -3.6999999999999997e-88 or -1.84999999999999998e-292 < x < 2.20000000000000006e-144 or 7.5000000000000006e-98 < x

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{x}{t} + 0.5 \cdot \frac{y - z}{t}} \]
    3. Step-by-step derivation
      1. div-sub97.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{0.5}{t} \cdot y} \]
      3. *-commutative45.2%

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

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

    if -3.6999999999999997e-88 < x < -1.84999999999999998e-292 or 2.20000000000000006e-144 < x < 7.5000000000000006e-98

    1. Initial program 100.0%

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

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

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

        \[\leadsto \color{blue}{\frac{-0.5}{\frac{t}{z}}} \]
    4. Simplified56.5%

      \[\leadsto \color{blue}{\frac{-0.5}{\frac{t}{z}}} \]
    5. Step-by-step derivation
      1. associate-/r/57.1%

        \[\leadsto \color{blue}{\frac{-0.5}{t} \cdot z} \]
    6. Applied egg-rr57.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.3 \cdot 10^{-19}:\\ \;\;\;\;0.5 \cdot \frac{x}{t}\\ \mathbf{elif}\;x \leq -3.7 \cdot 10^{-88} \lor \neg \left(x \leq -1.85 \cdot 10^{-292}\right) \land \left(x \leq 2.2 \cdot 10^{-144} \lor \neg \left(x \leq 7.5 \cdot 10^{-98}\right)\right):\\ \;\;\;\;y \cdot \frac{0.5}{t}\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{-0.5}{t}\\ \end{array} \]

Alternative 3: 46.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.9 \cdot 10^{-20}:\\ \;\;\;\;0.5 \cdot \frac{x}{t}\\ \mathbf{elif}\;x \leq -3.7 \cdot 10^{-88} \lor \neg \left(x \leq -2.1 \cdot 10^{-287}\right) \land \left(x \leq 1.8 \cdot 10^{-147} \lor \neg \left(x \leq 7 \cdot 10^{-101}\right)\right):\\ \;\;\;\;y \cdot \frac{0.5}{t}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{z}{t}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= x -2.9e-20)
   (* 0.5 (/ x t))
   (if (or (<= x -3.7e-88)
           (and (not (<= x -2.1e-287))
                (or (<= x 1.8e-147) (not (<= x 7e-101)))))
     (* y (/ 0.5 t))
     (* -0.5 (/ z t)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (x <= -2.9e-20) {
		tmp = 0.5 * (x / t);
	} else if ((x <= -3.7e-88) || (!(x <= -2.1e-287) && ((x <= 1.8e-147) || !(x <= 7e-101)))) {
		tmp = y * (0.5 / 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.9d-20)) then
        tmp = 0.5d0 * (x / t)
    else if ((x <= (-3.7d-88)) .or. (.not. (x <= (-2.1d-287))) .and. (x <= 1.8d-147) .or. (.not. (x <= 7d-101))) then
        tmp = y * (0.5d0 / 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.9e-20) {
		tmp = 0.5 * (x / t);
	} else if ((x <= -3.7e-88) || (!(x <= -2.1e-287) && ((x <= 1.8e-147) || !(x <= 7e-101)))) {
		tmp = y * (0.5 / t);
	} else {
		tmp = -0.5 * (z / t);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if x <= -2.9e-20:
		tmp = 0.5 * (x / t)
	elif (x <= -3.7e-88) or (not (x <= -2.1e-287) and ((x <= 1.8e-147) or not (x <= 7e-101))):
		tmp = y * (0.5 / t)
	else:
		tmp = -0.5 * (z / t)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (x <= -2.9e-20)
		tmp = Float64(0.5 * Float64(x / t));
	elseif ((x <= -3.7e-88) || (!(x <= -2.1e-287) && ((x <= 1.8e-147) || !(x <= 7e-101))))
		tmp = Float64(y * Float64(0.5 / 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.9e-20)
		tmp = 0.5 * (x / t);
	elseif ((x <= -3.7e-88) || (~((x <= -2.1e-287)) && ((x <= 1.8e-147) || ~((x <= 7e-101)))))
		tmp = y * (0.5 / t);
	else
		tmp = -0.5 * (z / t);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[x, -2.9e-20], N[(0.5 * N[(x / t), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, -3.7e-88], And[N[Not[LessEqual[x, -2.1e-287]], $MachinePrecision], Or[LessEqual[x, 1.8e-147], N[Not[LessEqual[x, 7e-101]], $MachinePrecision]]]], N[(y * N[(0.5 / t), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(z / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -3.7 \cdot 10^{-88} \lor \neg \left(x \leq -2.1 \cdot 10^{-287}\right) \land \left(x \leq 1.8 \cdot 10^{-147} \lor \neg \left(x \leq 7 \cdot 10^{-101}\right)\right):\\
\;\;\;\;y \cdot \frac{0.5}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.9e-20

    1. Initial program 100.0%

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

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

    if -2.9e-20 < x < -3.6999999999999997e-88 or -2.0999999999999999e-287 < x < 1.80000000000000006e-147 or 6.99999999999999989e-101 < x

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{x}{t} + 0.5 \cdot \frac{y - z}{t}} \]
    3. Step-by-step derivation
      1. div-sub97.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{0.5}{t} \cdot y} \]
      3. *-commutative44.8%

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

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

    if -3.6999999999999997e-88 < x < -2.0999999999999999e-287 or 1.80000000000000006e-147 < x < 6.99999999999999989e-101

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{z}{t}} \]
    3. Step-by-step derivation
      1. *-commutative56.5%

        \[\leadsto \color{blue}{\frac{z}{t} \cdot -0.5} \]
    4. Simplified56.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.9 \cdot 10^{-20}:\\ \;\;\;\;0.5 \cdot \frac{x}{t}\\ \mathbf{elif}\;x \leq -3.7 \cdot 10^{-88} \lor \neg \left(x \leq -2.1 \cdot 10^{-287}\right) \land \left(x \leq 1.8 \cdot 10^{-147} \lor \neg \left(x \leq 7 \cdot 10^{-101}\right)\right):\\ \;\;\;\;y \cdot \frac{0.5}{t}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{z}{t}\\ \end{array} \]

Alternative 4: 46.5% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;x \leq -1.55 \cdot 10^{-87} \lor \neg \left(x \leq -1.06 \cdot 10^{-281}\right) \land \left(x \leq 10^{-143} \lor \neg \left(x \leq 2.3 \cdot 10^{-104}\right)\right):\\
\;\;\;\;\frac{y \cdot 0.5}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.40000000000000001e-19

    1. Initial program 100.0%

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

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

    if -1.40000000000000001e-19 < x < -1.54999999999999999e-87 or -1.06e-281 < x < 9.9999999999999995e-144 or 2.2999999999999999e-104 < x

    1. Initial program 100.0%

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

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

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

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

    if -1.54999999999999999e-87 < x < -1.06e-281 or 9.9999999999999995e-144 < x < 2.2999999999999999e-104

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{z}{t}} \]
    3. Step-by-step derivation
      1. *-commutative58.5%

        \[\leadsto \color{blue}{\frac{z}{t} \cdot -0.5} \]
    4. Simplified58.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.4 \cdot 10^{-19}:\\ \;\;\;\;0.5 \cdot \frac{x}{t}\\ \mathbf{elif}\;x \leq -1.55 \cdot 10^{-87} \lor \neg \left(x \leq -1.06 \cdot 10^{-281}\right) \land \left(x \leq 10^{-143} \lor \neg \left(x \leq 2.3 \cdot 10^{-104}\right)\right):\\ \;\;\;\;\frac{y \cdot 0.5}{t}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{z}{t}\\ \end{array} \]

Alternative 5: 46.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{y \cdot 0.5}{t}\\ \mathbf{if}\;x \leq -1.02 \cdot 10^{-21}:\\ \;\;\;\;0.5 \cdot \frac{x}{t}\\ \mathbf{elif}\;x \leq -9.6 \cdot 10^{-88}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -4.4 \cdot 10^{-289}:\\ \;\;\;\;\frac{z \cdot -0.5}{t}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-141} \lor \neg \left(x \leq 1.75 \cdot 10^{-99}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{z}{t}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (/ (* y 0.5) t)))
   (if (<= x -1.02e-21)
     (* 0.5 (/ x t))
     (if (<= x -9.6e-88)
       t_1
       (if (<= x -4.4e-289)
         (/ (* z -0.5) t)
         (if (or (<= x 1.4e-141) (not (<= x 1.75e-99)))
           t_1
           (* -0.5 (/ z t))))))))
double code(double x, double y, double z, double t) {
	double t_1 = (y * 0.5) / t;
	double tmp;
	if (x <= -1.02e-21) {
		tmp = 0.5 * (x / t);
	} else if (x <= -9.6e-88) {
		tmp = t_1;
	} else if (x <= -4.4e-289) {
		tmp = (z * -0.5) / t;
	} else if ((x <= 1.4e-141) || !(x <= 1.75e-99)) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_1 = (y * 0.5d0) / t
    if (x <= (-1.02d-21)) then
        tmp = 0.5d0 * (x / t)
    else if (x <= (-9.6d-88)) then
        tmp = t_1
    else if (x <= (-4.4d-289)) then
        tmp = (z * (-0.5d0)) / t
    else if ((x <= 1.4d-141) .or. (.not. (x <= 1.75d-99))) then
        tmp = t_1
    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 t_1 = (y * 0.5) / t;
	double tmp;
	if (x <= -1.02e-21) {
		tmp = 0.5 * (x / t);
	} else if (x <= -9.6e-88) {
		tmp = t_1;
	} else if (x <= -4.4e-289) {
		tmp = (z * -0.5) / t;
	} else if ((x <= 1.4e-141) || !(x <= 1.75e-99)) {
		tmp = t_1;
	} else {
		tmp = -0.5 * (z / t);
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = (y * 0.5) / t
	tmp = 0
	if x <= -1.02e-21:
		tmp = 0.5 * (x / t)
	elif x <= -9.6e-88:
		tmp = t_1
	elif x <= -4.4e-289:
		tmp = (z * -0.5) / t
	elif (x <= 1.4e-141) or not (x <= 1.75e-99):
		tmp = t_1
	else:
		tmp = -0.5 * (z / t)
	return tmp
function code(x, y, z, t)
	t_1 = Float64(Float64(y * 0.5) / t)
	tmp = 0.0
	if (x <= -1.02e-21)
		tmp = Float64(0.5 * Float64(x / t));
	elseif (x <= -9.6e-88)
		tmp = t_1;
	elseif (x <= -4.4e-289)
		tmp = Float64(Float64(z * -0.5) / t);
	elseif ((x <= 1.4e-141) || !(x <= 1.75e-99))
		tmp = t_1;
	else
		tmp = Float64(-0.5 * Float64(z / t));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = (y * 0.5) / t;
	tmp = 0.0;
	if (x <= -1.02e-21)
		tmp = 0.5 * (x / t);
	elseif (x <= -9.6e-88)
		tmp = t_1;
	elseif (x <= -4.4e-289)
		tmp = (z * -0.5) / t;
	elseif ((x <= 1.4e-141) || ~((x <= 1.75e-99)))
		tmp = t_1;
	else
		tmp = -0.5 * (z / t);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y * 0.5), $MachinePrecision] / t), $MachinePrecision]}, If[LessEqual[x, -1.02e-21], N[(0.5 * N[(x / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -9.6e-88], t$95$1, If[LessEqual[x, -4.4e-289], N[(N[(z * -0.5), $MachinePrecision] / t), $MachinePrecision], If[Or[LessEqual[x, 1.4e-141], N[Not[LessEqual[x, 1.75e-99]], $MachinePrecision]], t$95$1, N[(-0.5 * N[(z / t), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{y \cdot 0.5}{t}\\
\mathbf{if}\;x \leq -1.02 \cdot 10^{-21}:\\
\;\;\;\;0.5 \cdot \frac{x}{t}\\

\mathbf{elif}\;x \leq -9.6 \cdot 10^{-88}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -4.4 \cdot 10^{-289}:\\
\;\;\;\;\frac{z \cdot -0.5}{t}\\

\mathbf{elif}\;x \leq 1.4 \cdot 10^{-141} \lor \neg \left(x \leq 1.75 \cdot 10^{-99}\right):\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -1.02000000000000004e-21

    1. Initial program 100.0%

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

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

    if -1.02000000000000004e-21 < x < -9.5999999999999998e-88 or -4.4e-289 < x < 1.40000000000000006e-141 or 1.7499999999999999e-99 < x

    1. Initial program 100.0%

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

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

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

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

    if -9.5999999999999998e-88 < x < -4.4e-289

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{z}{t}} \]
    3. Step-by-step derivation
      1. *-commutative54.0%

        \[\leadsto \color{blue}{\frac{z}{t} \cdot -0.5} \]
    4. Simplified54.0%

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

        \[\leadsto \color{blue}{\frac{z \cdot -0.5}{t}} \]
    6. Applied egg-rr54.1%

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

    if 1.40000000000000006e-141 < x < 1.7499999999999999e-99

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{z}{t}} \]
    3. Step-by-step derivation
      1. *-commutative80.4%

        \[\leadsto \color{blue}{\frac{z}{t} \cdot -0.5} \]
    4. Simplified80.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.02 \cdot 10^{-21}:\\ \;\;\;\;0.5 \cdot \frac{x}{t}\\ \mathbf{elif}\;x \leq -9.6 \cdot 10^{-88}:\\ \;\;\;\;\frac{y \cdot 0.5}{t}\\ \mathbf{elif}\;x \leq -4.4 \cdot 10^{-289}:\\ \;\;\;\;\frac{z \cdot -0.5}{t}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-141} \lor \neg \left(x \leq 1.75 \cdot 10^{-99}\right):\\ \;\;\;\;\frac{y \cdot 0.5}{t}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{z}{t}\\ \end{array} \]

Alternative 6: 75.5% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;y \leq 1.25 \cdot 10^{+121}:\\
\;\;\;\;y \cdot \frac{0.5}{t}\\

\mathbf{elif}\;y \leq 7 \cdot 10^{+145}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 1.6200000000000001e86 or 1.25000000000000002e121 < y < 7.0000000000000002e145

    1. Initial program 100.0%

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

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

    if 1.6200000000000001e86 < y < 1.25000000000000002e121

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{x}{t} + 0.5 \cdot \frac{y - z}{t}} \]
    3. Step-by-step derivation
      1. div-sub83.3%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{0.5}{t} \cdot y} \]
      3. *-commutative83.7%

        \[\leadsto \color{blue}{y \cdot \frac{0.5}{t}} \]
    7. Simplified83.7%

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

    if 7.0000000000000002e145 < y

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot y}{t}} \]
    4. Simplified78.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.62 \cdot 10^{+86}:\\ \;\;\;\;0.5 \cdot \frac{x - z}{t}\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{+121}:\\ \;\;\;\;y \cdot \frac{0.5}{t}\\ \mathbf{elif}\;y \leq 7 \cdot 10^{+145}:\\ \;\;\;\;0.5 \cdot \frac{x - z}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot 0.5}{t}\\ \end{array} \]

Alternative 7: 78.2% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\left(x + y\right) \cdot \frac{0.5}{t}\\


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

    1. Initial program 100.0%

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

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

    if 1.00000000000000006e84 < y

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\left(y + x\right)} \cdot \frac{0.5}{t} \]
    4. Simplified85.8%

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

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

Alternative 8: 77.2% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\left(y - z\right) \cdot \frac{0.5}{t}\\


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

    1. Initial program 100.0%

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

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

    if -2.0000000000000001e-27 < x

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\frac{0.5 \cdot \left(y - z\right)}{t}} \]
      2. *-commutative78.9%

        \[\leadsto \frac{\color{blue}{\left(y - z\right) \cdot 0.5}}{t} \]
      3. associate-*r/78.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-27}:\\ \;\;\;\;0.5 \cdot \frac{x - z}{t}\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{0.5}{t}\\ \end{array} \]

Alternative 9: 46.2% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.45 \cdot 10^{-19}:\\
\;\;\;\;0.5 \cdot \frac{x}{t}\\

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


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

    1. Initial program 100.0%

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

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

    if -2.44999999999999996e-19 < x

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{x}{t} + 0.5 \cdot \frac{y - z}{t}} \]
    3. Step-by-step derivation
      1. div-sub97.9%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{0.5}{t} \cdot y} \]
      3. *-commutative45.9%

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

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

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

Alternative 10: 37.9% accurate, 1.8× speedup?

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

\\
0.5 \cdot \frac{x}{t}
\end{array}
Derivation
  1. Initial program 100.0%

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

    \[\leadsto \color{blue}{0.5 \cdot \frac{x}{t}} \]
  3. Final simplification37.8%

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

Reproduce

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