Linear.Projection:inverseInfinitePerspective from linear-1.19.1.3

Percentage Accurate: 93.5% → 97.7%
Time: 23.2s
Alternatives: 9
Speedup: 1.3×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 93.5% accurate, 1.0× speedup?

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

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

Alternative 1: 97.7% accurate, 0.7× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\ \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;t \leq 10^{+16}:\\ \;\;\;\;y\_m \cdot \left(\left(x - z\right) \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - z\right) \cdot \left(y\_m \cdot t\right)\\ \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z t)
 :precision binary64
 (* y_s (if (<= t 1e+16) (* y_m (* (- x z) t)) (* (- x z) (* y_m t)))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t);
double code(double y_s, double x, double y_m, double z, double t) {
	double tmp;
	if (t <= 1e+16) {
		tmp = y_m * ((x - z) * t);
	} else {
		tmp = (x - z) * (y_m * t);
	}
	return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
real(8) function code(y_s, x, y_m, z, t)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (t <= 1d+16) then
        tmp = y_m * ((x - z) * t)
    else
        tmp = (x - z) * (y_m * t)
    end if
    code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t;
public static double code(double y_s, double x, double y_m, double z, double t) {
	double tmp;
	if (t <= 1e+16) {
		tmp = y_m * ((x - z) * t);
	} else {
		tmp = (x - z) * (y_m * t);
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x, y_m, z, t] = sort([x, y_m, z, t])
def code(y_s, x, y_m, z, t):
	tmp = 0
	if t <= 1e+16:
		tmp = y_m * ((x - z) * t)
	else:
		tmp = (x - z) * (y_m * t)
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
x, y_m, z, t = sort([x, y_m, z, t])
function code(y_s, x, y_m, z, t)
	tmp = 0.0
	if (t <= 1e+16)
		tmp = Float64(y_m * Float64(Float64(x - z) * t));
	else
		tmp = Float64(Float64(x - z) * Float64(y_m * t));
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t = num2cell(sort([x, y_m, z, t])){:}
function tmp_2 = code(y_s, x, y_m, z, t)
	tmp = 0.0;
	if (t <= 1e+16)
		tmp = y_m * ((x - z) * t);
	else
		tmp = (x - z) * (y_m * t);
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_, t_] := N[(y$95$s * If[LessEqual[t, 1e+16], N[(y$95$m * N[(N[(x - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], N[(N[(x - z), $MachinePrecision] * N[(y$95$m * t), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;t \leq 10^{+16}:\\
\;\;\;\;y\_m \cdot \left(\left(x - z\right) \cdot t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 1e16

    1. Initial program 94.0%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Step-by-step derivation
      1. distribute-rgt-out--94.5%

        \[\leadsto \color{blue}{\left(y \cdot \left(x - z\right)\right)} \cdot t \]
      2. associate-*l*93.5%

        \[\leadsto \color{blue}{y \cdot \left(\left(x - z\right) \cdot t\right)} \]
      3. *-commutative93.5%

        \[\leadsto y \cdot \color{blue}{\left(t \cdot \left(x - z\right)\right)} \]
    3. Simplified93.5%

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

    if 1e16 < t

    1. Initial program 99.8%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Step-by-step derivation
      1. *-commutative99.8%

        \[\leadsto \color{blue}{t \cdot \left(x \cdot y - z \cdot y\right)} \]
      2. distribute-rgt-out--99.8%

        \[\leadsto t \cdot \color{blue}{\left(y \cdot \left(x - z\right)\right)} \]
      3. associate-*r*98.1%

        \[\leadsto \color{blue}{\left(t \cdot y\right) \cdot \left(x - z\right)} \]
      4. *-commutative98.1%

        \[\leadsto \color{blue}{\left(y \cdot t\right)} \cdot \left(x - z\right) \]
    3. Simplified98.1%

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

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

Alternative 2: 90.0% accurate, 0.5× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\ \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq -3.4 \cdot 10^{+181} \lor \neg \left(z \leq 1.5 \cdot 10^{+171}\right):\\ \;\;\;\;t \cdot \left(y\_m \cdot \left(-z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y\_m \cdot \left(\left(x - z\right) \cdot t\right)\\ \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z t)
 :precision binary64
 (*
  y_s
  (if (or (<= z -3.4e+181) (not (<= z 1.5e+171)))
    (* t (* y_m (- z)))
    (* y_m (* (- x z) t)))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t);
double code(double y_s, double x, double y_m, double z, double t) {
	double tmp;
	if ((z <= -3.4e+181) || !(z <= 1.5e+171)) {
		tmp = t * (y_m * -z);
	} else {
		tmp = y_m * ((x - z) * t);
	}
	return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
real(8) function code(y_s, x, y_m, z, t)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((z <= (-3.4d+181)) .or. (.not. (z <= 1.5d+171))) then
        tmp = t * (y_m * -z)
    else
        tmp = y_m * ((x - z) * t)
    end if
    code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t;
public static double code(double y_s, double x, double y_m, double z, double t) {
	double tmp;
	if ((z <= -3.4e+181) || !(z <= 1.5e+171)) {
		tmp = t * (y_m * -z);
	} else {
		tmp = y_m * ((x - z) * t);
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x, y_m, z, t] = sort([x, y_m, z, t])
def code(y_s, x, y_m, z, t):
	tmp = 0
	if (z <= -3.4e+181) or not (z <= 1.5e+171):
		tmp = t * (y_m * -z)
	else:
		tmp = y_m * ((x - z) * t)
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
x, y_m, z, t = sort([x, y_m, z, t])
function code(y_s, x, y_m, z, t)
	tmp = 0.0
	if ((z <= -3.4e+181) || !(z <= 1.5e+171))
		tmp = Float64(t * Float64(y_m * Float64(-z)));
	else
		tmp = Float64(y_m * Float64(Float64(x - z) * t));
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t = num2cell(sort([x, y_m, z, t])){:}
function tmp_2 = code(y_s, x, y_m, z, t)
	tmp = 0.0;
	if ((z <= -3.4e+181) || ~((z <= 1.5e+171)))
		tmp = t * (y_m * -z);
	else
		tmp = y_m * ((x - z) * t);
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_, t_] := N[(y$95$s * If[Or[LessEqual[z, -3.4e+181], N[Not[LessEqual[z, 1.5e+171]], $MachinePrecision]], N[(t * N[(y$95$m * (-z)), $MachinePrecision]), $MachinePrecision], N[(y$95$m * N[(N[(x - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -3.4 \cdot 10^{+181} \lor \neg \left(z \leq 1.5 \cdot 10^{+171}\right):\\
\;\;\;\;t \cdot \left(y\_m \cdot \left(-z\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.40000000000000031e181 or 1.5e171 < z

    1. Initial program 91.5%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Step-by-step derivation
      1. distribute-rgt-out--91.6%

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

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

      \[\leadsto \left(y \cdot \color{blue}{\left(-1 \cdot z\right)}\right) \cdot t \]
    6. Step-by-step derivation
      1. neg-mul-188.3%

        \[\leadsto \left(y \cdot \color{blue}{\left(-z\right)}\right) \cdot t \]
    7. Simplified88.3%

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

    if -3.40000000000000031e181 < z < 1.5e171

    1. Initial program 96.4%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Step-by-step derivation
      1. distribute-rgt-out--96.9%

        \[\leadsto \color{blue}{\left(y \cdot \left(x - z\right)\right)} \cdot t \]
      2. associate-*l*93.6%

        \[\leadsto \color{blue}{y \cdot \left(\left(x - z\right) \cdot t\right)} \]
      3. *-commutative93.6%

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

      \[\leadsto \color{blue}{y \cdot \left(t \cdot \left(x - z\right)\right)} \]
    4. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Final simplification92.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.4 \cdot 10^{+181} \lor \neg \left(z \leq 1.5 \cdot 10^{+171}\right):\\ \;\;\;\;t \cdot \left(y \cdot \left(-z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(\left(x - z\right) \cdot t\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 74.9% accurate, 0.6× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\ \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq -1.4 \cdot 10^{-74} \lor \neg \left(z \leq 5.8 \cdot 10^{+29}\right):\\ \;\;\;\;t \cdot \left(y\_m \cdot \left(-z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y\_m \cdot t\right)\\ \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z t)
 :precision binary64
 (*
  y_s
  (if (or (<= z -1.4e-74) (not (<= z 5.8e+29)))
    (* t (* y_m (- z)))
    (* x (* y_m t)))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t);
double code(double y_s, double x, double y_m, double z, double t) {
	double tmp;
	if ((z <= -1.4e-74) || !(z <= 5.8e+29)) {
		tmp = t * (y_m * -z);
	} else {
		tmp = x * (y_m * t);
	}
	return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
real(8) function code(y_s, x, y_m, z, t)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((z <= (-1.4d-74)) .or. (.not. (z <= 5.8d+29))) then
        tmp = t * (y_m * -z)
    else
        tmp = x * (y_m * t)
    end if
    code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t;
public static double code(double y_s, double x, double y_m, double z, double t) {
	double tmp;
	if ((z <= -1.4e-74) || !(z <= 5.8e+29)) {
		tmp = t * (y_m * -z);
	} else {
		tmp = x * (y_m * t);
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x, y_m, z, t] = sort([x, y_m, z, t])
def code(y_s, x, y_m, z, t):
	tmp = 0
	if (z <= -1.4e-74) or not (z <= 5.8e+29):
		tmp = t * (y_m * -z)
	else:
		tmp = x * (y_m * t)
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
x, y_m, z, t = sort([x, y_m, z, t])
function code(y_s, x, y_m, z, t)
	tmp = 0.0
	if ((z <= -1.4e-74) || !(z <= 5.8e+29))
		tmp = Float64(t * Float64(y_m * Float64(-z)));
	else
		tmp = Float64(x * Float64(y_m * t));
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t = num2cell(sort([x, y_m, z, t])){:}
function tmp_2 = code(y_s, x, y_m, z, t)
	tmp = 0.0;
	if ((z <= -1.4e-74) || ~((z <= 5.8e+29)))
		tmp = t * (y_m * -z);
	else
		tmp = x * (y_m * t);
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_, t_] := N[(y$95$s * If[Or[LessEqual[z, -1.4e-74], N[Not[LessEqual[z, 5.8e+29]], $MachinePrecision]], N[(t * N[(y$95$m * (-z)), $MachinePrecision]), $MachinePrecision], N[(x * N[(y$95$m * t), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -1.4 \cdot 10^{-74} \lor \neg \left(z \leq 5.8 \cdot 10^{+29}\right):\\
\;\;\;\;t \cdot \left(y\_m \cdot \left(-z\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot \left(y\_m \cdot t\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.39999999999999994e-74 or 5.7999999999999999e29 < z

    1. Initial program 93.8%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Step-by-step derivation
      1. distribute-rgt-out--94.6%

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

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

      \[\leadsto \left(y \cdot \color{blue}{\left(-1 \cdot z\right)}\right) \cdot t \]
    6. Step-by-step derivation
      1. neg-mul-178.7%

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

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

    if -1.39999999999999994e-74 < z < 5.7999999999999999e29

    1. Initial program 97.2%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Step-by-step derivation
      1. *-commutative97.2%

        \[\leadsto \color{blue}{t \cdot \left(x \cdot y - z \cdot y\right)} \]
      2. distribute-rgt-out--97.2%

        \[\leadsto t \cdot \color{blue}{\left(y \cdot \left(x - z\right)\right)} \]
      3. associate-*r*95.3%

        \[\leadsto \color{blue}{\left(t \cdot y\right) \cdot \left(x - z\right)} \]
      4. *-commutative95.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.4 \cdot 10^{-74} \lor \neg \left(z \leq 5.8 \cdot 10^{+29}\right):\\ \;\;\;\;t \cdot \left(y \cdot \left(-z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 76.5% accurate, 0.6× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\ \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;x \leq -2.6 \cdot 10^{+37} \lor \neg \left(x \leq 6.7 \cdot 10^{-16}\right):\\ \;\;\;\;t \cdot \left(y\_m \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y\_m \cdot t\right) \cdot \left(-z\right)\\ \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z t)
 :precision binary64
 (*
  y_s
  (if (or (<= x -2.6e+37) (not (<= x 6.7e-16)))
    (* t (* y_m x))
    (* (* y_m t) (- z)))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t);
double code(double y_s, double x, double y_m, double z, double t) {
	double tmp;
	if ((x <= -2.6e+37) || !(x <= 6.7e-16)) {
		tmp = t * (y_m * x);
	} else {
		tmp = (y_m * t) * -z;
	}
	return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
real(8) function code(y_s, x, y_m, z, t)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((x <= (-2.6d+37)) .or. (.not. (x <= 6.7d-16))) then
        tmp = t * (y_m * x)
    else
        tmp = (y_m * t) * -z
    end if
    code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t;
public static double code(double y_s, double x, double y_m, double z, double t) {
	double tmp;
	if ((x <= -2.6e+37) || !(x <= 6.7e-16)) {
		tmp = t * (y_m * x);
	} else {
		tmp = (y_m * t) * -z;
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x, y_m, z, t] = sort([x, y_m, z, t])
def code(y_s, x, y_m, z, t):
	tmp = 0
	if (x <= -2.6e+37) or not (x <= 6.7e-16):
		tmp = t * (y_m * x)
	else:
		tmp = (y_m * t) * -z
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
x, y_m, z, t = sort([x, y_m, z, t])
function code(y_s, x, y_m, z, t)
	tmp = 0.0
	if ((x <= -2.6e+37) || !(x <= 6.7e-16))
		tmp = Float64(t * Float64(y_m * x));
	else
		tmp = Float64(Float64(y_m * t) * Float64(-z));
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t = num2cell(sort([x, y_m, z, t])){:}
function tmp_2 = code(y_s, x, y_m, z, t)
	tmp = 0.0;
	if ((x <= -2.6e+37) || ~((x <= 6.7e-16)))
		tmp = t * (y_m * x);
	else
		tmp = (y_m * t) * -z;
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_, t_] := N[(y$95$s * If[Or[LessEqual[x, -2.6e+37], N[Not[LessEqual[x, 6.7e-16]], $MachinePrecision]], N[(t * N[(y$95$m * x), $MachinePrecision]), $MachinePrecision], N[(N[(y$95$m * t), $MachinePrecision] * (-z)), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq -2.6 \cdot 10^{+37} \lor \neg \left(x \leq 6.7 \cdot 10^{-16}\right):\\
\;\;\;\;t \cdot \left(y\_m \cdot x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.5999999999999999e37 or 6.7000000000000004e-16 < x

    1. Initial program 92.2%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Step-by-step derivation
      1. distribute-rgt-out--93.2%

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

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

      \[\leadsto \left(y \cdot \color{blue}{x}\right) \cdot t \]

    if -2.5999999999999999e37 < x < 6.7000000000000004e-16

    1. Initial program 97.7%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Step-by-step derivation
      1. *-commutative97.7%

        \[\leadsto \color{blue}{t \cdot \left(x \cdot y - z \cdot y\right)} \]
      2. distribute-rgt-out--97.7%

        \[\leadsto t \cdot \color{blue}{\left(y \cdot \left(x - z\right)\right)} \]
      3. associate-*r*93.5%

        \[\leadsto \color{blue}{\left(t \cdot y\right) \cdot \left(x - z\right)} \]
      4. *-commutative93.5%

        \[\leadsto \color{blue}{\left(y \cdot t\right)} \cdot \left(x - z\right) \]
    3. Simplified93.5%

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

      \[\leadsto \left(y \cdot t\right) \cdot \color{blue}{\left(-1 \cdot z\right)} \]
    6. Step-by-step derivation
      1. neg-mul-180.9%

        \[\leadsto \left(y \cdot \color{blue}{\left(-z\right)}\right) \cdot t \]
    7. Simplified79.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.6 \cdot 10^{+37} \lor \neg \left(x \leq 6.7 \cdot 10^{-16}\right):\\ \;\;\;\;t \cdot \left(y \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot t\right) \cdot \left(-z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 75.3% accurate, 0.6× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\ \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;x \leq -4.6 \cdot 10^{-29} \lor \neg \left(x \leq 2.45 \cdot 10^{-14}\right):\\ \;\;\;\;t \cdot \left(y\_m \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;y\_m \cdot \left(z \cdot \left(-t\right)\right)\\ \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z t)
 :precision binary64
 (*
  y_s
  (if (or (<= x -4.6e-29) (not (<= x 2.45e-14)))
    (* t (* y_m x))
    (* y_m (* z (- t))))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t);
double code(double y_s, double x, double y_m, double z, double t) {
	double tmp;
	if ((x <= -4.6e-29) || !(x <= 2.45e-14)) {
		tmp = t * (y_m * x);
	} else {
		tmp = y_m * (z * -t);
	}
	return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
real(8) function code(y_s, x, y_m, z, t)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((x <= (-4.6d-29)) .or. (.not. (x <= 2.45d-14))) then
        tmp = t * (y_m * x)
    else
        tmp = y_m * (z * -t)
    end if
    code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t;
public static double code(double y_s, double x, double y_m, double z, double t) {
	double tmp;
	if ((x <= -4.6e-29) || !(x <= 2.45e-14)) {
		tmp = t * (y_m * x);
	} else {
		tmp = y_m * (z * -t);
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x, y_m, z, t] = sort([x, y_m, z, t])
def code(y_s, x, y_m, z, t):
	tmp = 0
	if (x <= -4.6e-29) or not (x <= 2.45e-14):
		tmp = t * (y_m * x)
	else:
		tmp = y_m * (z * -t)
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
x, y_m, z, t = sort([x, y_m, z, t])
function code(y_s, x, y_m, z, t)
	tmp = 0.0
	if ((x <= -4.6e-29) || !(x <= 2.45e-14))
		tmp = Float64(t * Float64(y_m * x));
	else
		tmp = Float64(y_m * Float64(z * Float64(-t)));
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t = num2cell(sort([x, y_m, z, t])){:}
function tmp_2 = code(y_s, x, y_m, z, t)
	tmp = 0.0;
	if ((x <= -4.6e-29) || ~((x <= 2.45e-14)))
		tmp = t * (y_m * x);
	else
		tmp = y_m * (z * -t);
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_, t_] := N[(y$95$s * If[Or[LessEqual[x, -4.6e-29], N[Not[LessEqual[x, 2.45e-14]], $MachinePrecision]], N[(t * N[(y$95$m * x), $MachinePrecision]), $MachinePrecision], N[(y$95$m * N[(z * (-t)), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq -4.6 \cdot 10^{-29} \lor \neg \left(x \leq 2.45 \cdot 10^{-14}\right):\\
\;\;\;\;t \cdot \left(y\_m \cdot x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4.59999999999999982e-29 or 2.44999999999999997e-14 < x

    1. Initial program 93.3%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Step-by-step derivation
      1. distribute-rgt-out--94.2%

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

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

      \[\leadsto \left(y \cdot \color{blue}{x}\right) \cdot t \]

    if -4.59999999999999982e-29 < x < 2.44999999999999997e-14

    1. Initial program 97.4%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Step-by-step derivation
      1. distribute-rgt-out--97.4%

        \[\leadsto \color{blue}{\left(y \cdot \left(x - z\right)\right)} \cdot t \]
      2. associate-*l*92.6%

        \[\leadsto \color{blue}{y \cdot \left(\left(x - z\right) \cdot t\right)} \]
      3. *-commutative92.6%

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

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

      \[\leadsto y \cdot \color{blue}{\left(-1 \cdot \left(t \cdot z\right)\right)} \]
    6. Step-by-step derivation
      1. mul-1-neg81.0%

        \[\leadsto y \cdot \color{blue}{\left(-t \cdot z\right)} \]
      2. *-commutative81.0%

        \[\leadsto y \cdot \left(-\color{blue}{z \cdot t}\right) \]
      3. distribute-rgt-neg-in81.0%

        \[\leadsto y \cdot \color{blue}{\left(z \cdot \left(-t\right)\right)} \]
    7. Simplified81.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.6 \cdot 10^{-29} \lor \neg \left(x \leq 2.45 \cdot 10^{-14}\right):\\ \;\;\;\;t \cdot \left(y \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z \cdot \left(-t\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 55.8% accurate, 0.9× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\ \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;t \leq 2.4 \cdot 10^{+186}:\\ \;\;\;\;t \cdot \left(y\_m \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y\_m \cdot t\right)\\ \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z t)
 :precision binary64
 (* y_s (if (<= t 2.4e+186) (* t (* y_m x)) (* x (* y_m t)))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t);
double code(double y_s, double x, double y_m, double z, double t) {
	double tmp;
	if (t <= 2.4e+186) {
		tmp = t * (y_m * x);
	} else {
		tmp = x * (y_m * t);
	}
	return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
real(8) function code(y_s, x, y_m, z, t)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (t <= 2.4d+186) then
        tmp = t * (y_m * x)
    else
        tmp = x * (y_m * t)
    end if
    code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t;
public static double code(double y_s, double x, double y_m, double z, double t) {
	double tmp;
	if (t <= 2.4e+186) {
		tmp = t * (y_m * x);
	} else {
		tmp = x * (y_m * t);
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x, y_m, z, t] = sort([x, y_m, z, t])
def code(y_s, x, y_m, z, t):
	tmp = 0
	if t <= 2.4e+186:
		tmp = t * (y_m * x)
	else:
		tmp = x * (y_m * t)
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
x, y_m, z, t = sort([x, y_m, z, t])
function code(y_s, x, y_m, z, t)
	tmp = 0.0
	if (t <= 2.4e+186)
		tmp = Float64(t * Float64(y_m * x));
	else
		tmp = Float64(x * Float64(y_m * t));
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t = num2cell(sort([x, y_m, z, t])){:}
function tmp_2 = code(y_s, x, y_m, z, t)
	tmp = 0.0;
	if (t <= 2.4e+186)
		tmp = t * (y_m * x);
	else
		tmp = x * (y_m * t);
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_, t_] := N[(y$95$s * If[LessEqual[t, 2.4e+186], N[(t * N[(y$95$m * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(y$95$m * t), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;t \leq 2.4 \cdot 10^{+186}:\\
\;\;\;\;t \cdot \left(y\_m \cdot x\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot \left(y\_m \cdot t\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 2.39999999999999995e186

    1. Initial program 94.7%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Step-by-step derivation
      1. distribute-rgt-out--95.2%

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

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

      \[\leadsto \left(y \cdot \color{blue}{x}\right) \cdot t \]

    if 2.39999999999999995e186 < t

    1. Initial program 99.8%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Step-by-step derivation
      1. *-commutative99.8%

        \[\leadsto \color{blue}{t \cdot \left(x \cdot y - z \cdot y\right)} \]
      2. distribute-rgt-out--99.8%

        \[\leadsto t \cdot \color{blue}{\left(y \cdot \left(x - z\right)\right)} \]
      3. associate-*r*99.9%

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

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

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

      \[\leadsto \left(y \cdot t\right) \cdot \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification54.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq 2.4 \cdot 10^{+186}:\\ \;\;\;\;t \cdot \left(y \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 57.6% accurate, 0.9× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\ \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;t \leq 100000000000:\\ \;\;\;\;y\_m \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y\_m \cdot t\right)\\ \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z t)
 :precision binary64
 (* y_s (if (<= t 100000000000.0) (* y_m (* x t)) (* x (* y_m t)))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t);
double code(double y_s, double x, double y_m, double z, double t) {
	double tmp;
	if (t <= 100000000000.0) {
		tmp = y_m * (x * t);
	} else {
		tmp = x * (y_m * t);
	}
	return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
real(8) function code(y_s, x, y_m, z, t)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (t <= 100000000000.0d0) then
        tmp = y_m * (x * t)
    else
        tmp = x * (y_m * t)
    end if
    code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t;
public static double code(double y_s, double x, double y_m, double z, double t) {
	double tmp;
	if (t <= 100000000000.0) {
		tmp = y_m * (x * t);
	} else {
		tmp = x * (y_m * t);
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x, y_m, z, t] = sort([x, y_m, z, t])
def code(y_s, x, y_m, z, t):
	tmp = 0
	if t <= 100000000000.0:
		tmp = y_m * (x * t)
	else:
		tmp = x * (y_m * t)
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
x, y_m, z, t = sort([x, y_m, z, t])
function code(y_s, x, y_m, z, t)
	tmp = 0.0
	if (t <= 100000000000.0)
		tmp = Float64(y_m * Float64(x * t));
	else
		tmp = Float64(x * Float64(y_m * t));
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t = num2cell(sort([x, y_m, z, t])){:}
function tmp_2 = code(y_s, x, y_m, z, t)
	tmp = 0.0;
	if (t <= 100000000000.0)
		tmp = y_m * (x * t);
	else
		tmp = x * (y_m * t);
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_, t_] := N[(y$95$s * If[LessEqual[t, 100000000000.0], N[(y$95$m * N[(x * t), $MachinePrecision]), $MachinePrecision], N[(x * N[(y$95$m * t), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;t \leq 100000000000:\\
\;\;\;\;y\_m \cdot \left(x \cdot t\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot \left(y\_m \cdot t\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 1e11

    1. Initial program 93.9%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Step-by-step derivation
      1. distribute-rgt-out--94.5%

        \[\leadsto \color{blue}{\left(y \cdot \left(x - z\right)\right)} \cdot t \]
      2. associate-*l*93.5%

        \[\leadsto \color{blue}{y \cdot \left(\left(x - z\right) \cdot t\right)} \]
      3. *-commutative93.5%

        \[\leadsto y \cdot \color{blue}{\left(t \cdot \left(x - z\right)\right)} \]
    3. Simplified93.5%

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

      \[\leadsto y \cdot \color{blue}{\left(t \cdot x\right)} \]

    if 1e11 < t

    1. Initial program 99.8%

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Step-by-step derivation
      1. *-commutative99.8%

        \[\leadsto \color{blue}{t \cdot \left(x \cdot y - z \cdot y\right)} \]
      2. distribute-rgt-out--99.8%

        \[\leadsto t \cdot \color{blue}{\left(y \cdot \left(x - z\right)\right)} \]
      3. associate-*r*98.1%

        \[\leadsto \color{blue}{\left(t \cdot y\right) \cdot \left(x - z\right)} \]
      4. *-commutative98.1%

        \[\leadsto \color{blue}{\left(y \cdot t\right)} \cdot \left(x - z\right) \]
    3. Simplified98.1%

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

      \[\leadsto \left(y \cdot t\right) \cdot \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification55.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq 100000000000:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot t\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 94.5% accurate, 1.3× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\ \\ y\_s \cdot \left(\left(y\_m \cdot \left(x - z\right)\right) \cdot t\right) \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z t) :precision binary64 (* y_s (* (* y_m (- x z)) t)))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t);
double code(double y_s, double x, double y_m, double z, double t) {
	return y_s * ((y_m * (x - z)) * t);
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
real(8) function code(y_s, x, y_m, z, t)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = y_s * ((y_m * (x - z)) * t)
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t;
public static double code(double y_s, double x, double y_m, double z, double t) {
	return y_s * ((y_m * (x - z)) * t);
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x, y_m, z, t] = sort([x, y_m, z, t])
def code(y_s, x, y_m, z, t):
	return y_s * ((y_m * (x - z)) * t)
y\_m = abs(y)
y\_s = copysign(1.0, y)
x, y_m, z, t = sort([x, y_m, z, t])
function code(y_s, x, y_m, z, t)
	return Float64(y_s * Float64(Float64(y_m * Float64(x - z)) * t))
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t = num2cell(sort([x, y_m, z, t])){:}
function tmp = code(y_s, x, y_m, z, t)
	tmp = y_s * ((y_m * (x - z)) * t);
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_, t_] := N[(y$95$s * N[(N[(y$95$m * N[(x - z), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\
\\
y\_s \cdot \left(\left(y\_m \cdot \left(x - z\right)\right) \cdot t\right)
\end{array}
Derivation
  1. Initial program 95.3%

    \[\left(x \cdot y - z \cdot y\right) \cdot t \]
  2. Step-by-step derivation
    1. distribute-rgt-out--95.7%

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

    \[\leadsto \color{blue}{\left(y \cdot \left(x - z\right)\right) \cdot t} \]
  4. Add Preprocessing
  5. Add Preprocessing

Alternative 9: 52.5% accurate, 1.8× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ [x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\ \\ y\_s \cdot \left(y\_m \cdot \left(x \cdot t\right)\right) \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z t) :precision binary64 (* y_s (* y_m (* x t))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z && z < t);
double code(double y_s, double x, double y_m, double z, double t) {
	return y_s * (y_m * (x * t));
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
real(8) function code(y_s, x, y_m, z, t)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = y_s * (y_m * (x * t))
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z && z < t;
public static double code(double y_s, double x, double y_m, double z, double t) {
	return y_s * (y_m * (x * t));
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
[x, y_m, z, t] = sort([x, y_m, z, t])
def code(y_s, x, y_m, z, t):
	return y_s * (y_m * (x * t))
y\_m = abs(y)
y\_s = copysign(1.0, y)
x, y_m, z, t = sort([x, y_m, z, t])
function code(y_s, x, y_m, z, t)
	return Float64(y_s * Float64(y_m * Float64(x * t)))
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z, t = num2cell(sort([x, y_m, z, t])){:}
function tmp = code(y_s, x, y_m, z, t)
	tmp = y_s * (y_m * (x * t));
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_, t_] := N[(y$95$s * N[(y$95$m * N[(x * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z, t] = \mathsf{sort}([x, y_m, z, t])\\
\\
y\_s \cdot \left(y\_m \cdot \left(x \cdot t\right)\right)
\end{array}
Derivation
  1. Initial program 95.3%

    \[\left(x \cdot y - z \cdot y\right) \cdot t \]
  2. Step-by-step derivation
    1. distribute-rgt-out--95.7%

      \[\leadsto \color{blue}{\left(y \cdot \left(x - z\right)\right)} \cdot t \]
    2. associate-*l*90.9%

      \[\leadsto \color{blue}{y \cdot \left(\left(x - z\right) \cdot t\right)} \]
    3. *-commutative90.9%

      \[\leadsto y \cdot \color{blue}{\left(t \cdot \left(x - z\right)\right)} \]
  3. Simplified90.9%

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

    \[\leadsto y \cdot \color{blue}{\left(t \cdot x\right)} \]
  6. Final simplification53.4%

    \[\leadsto y \cdot \left(x \cdot t\right) \]
  7. Add Preprocessing

Developer Target 1: 96.3% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t < -9.231879582886777 \cdot 10^{-80}:\\
\;\;\;\;\left(y \cdot t\right) \cdot \left(x - z\right)\\

\mathbf{elif}\;t < 2.543067051564877 \cdot 10^{+83}:\\
\;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024143 
(FPCore (x y z t)
  :name "Linear.Projection:inverseInfinitePerspective from linear-1.19.1.3"
  :precision binary64

  :alt
  (! :herbie-platform default (if (< t -9231879582886777/100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* (* y t) (- x z)) (if (< t 254306705156487700000000000000000000000000000000000000000000000000000000000000000000) (* y (* t (- x z))) (* (* y (- x z)) t))))

  (* (- (* x y) (* z y)) t))