Linear.Projection:inverseInfinitePerspective from linear-1.19.1.3

Percentage Accurate: 90.6% → 97.2%
Time: 12.4s
Alternatives: 7
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 7 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: 90.6% 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.2% accurate, 1.0× speedup?

\[\begin{array}{l} [y, t] = \mathsf{sort}([y, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -4 \cdot 10^{-5}:\\ \;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\ \end{array} \end{array} \]
NOTE: y and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= y -4e-5) (* (- x z) (* y t)) (* t (* y (- x z)))))
assert(y < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= -4e-5) {
		tmp = (x - z) * (y * t);
	} else {
		tmp = t * (y * (x - z));
	}
	return tmp;
}
NOTE: y and t should be sorted in increasing order before calling this function.
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 <= (-4d-5)) then
        tmp = (x - z) * (y * t)
    else
        tmp = t * (y * (x - z))
    end if
    code = tmp
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= -4e-5) {
		tmp = (x - z) * (y * t);
	} else {
		tmp = t * (y * (x - z));
	}
	return tmp;
}
[y, t] = sort([y, t])
def code(x, y, z, t):
	tmp = 0
	if y <= -4e-5:
		tmp = (x - z) * (y * t)
	else:
		tmp = t * (y * (x - z))
	return tmp
y, t = sort([y, t])
function code(x, y, z, t)
	tmp = 0.0
	if (y <= -4e-5)
		tmp = Float64(Float64(x - z) * Float64(y * t));
	else
		tmp = Float64(t * Float64(y * Float64(x - z)));
	end
	return tmp
end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (y <= -4e-5)
		tmp = (x - z) * (y * t);
	else
		tmp = t * (y * (x - z));
	end
	tmp_2 = tmp;
end
NOTE: y and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[y, -4e-5], N[(N[(x - z), $MachinePrecision] * N[(y * t), $MachinePrecision]), $MachinePrecision], N[(t * N[(y * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{-5}:\\
\;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.00000000000000033e-5

    1. Initial program 76.2%

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

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

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

      \[\leadsto \color{blue}{y \cdot \left(\left(x - z\right) \cdot t\right)} \]
    4. Step-by-step derivation
      1. expm1-log1p-u44.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y \cdot \left(\left(x - z\right) \cdot t\right)\right)\right)} \]
    5. Applied egg-rr44.7%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y \cdot \left(\left(x - z\right) \cdot t\right)\right)\right)} \]
    6. Step-by-step derivation
      1. expm1-log1p-u99.7%

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

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

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

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

    if -4.00000000000000033e-5 < y

    1. Initial program 93.5%

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

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

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

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

Alternative 2: 72.9% accurate, 0.9× speedup?

\[\begin{array}{l} [y, t] = \mathsf{sort}([y, t])\\ \\ \begin{array}{l} \mathbf{if}\;z \leq -3.7 \cdot 10^{-7} \lor \neg \left(z \leq 9.5 \cdot 10^{-56}\right):\\ \;\;\;\;z \cdot \left(y \cdot \left(-t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \end{array} \end{array} \]
NOTE: y and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (or (<= z -3.7e-7) (not (<= z 9.5e-56))) (* z (* y (- t))) (* y (* x t))))
assert(y < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -3.7e-7) || !(z <= 9.5e-56)) {
		tmp = z * (y * -t);
	} else {
		tmp = y * (x * t);
	}
	return tmp;
}
NOTE: y and t should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((z <= (-3.7d-7)) .or. (.not. (z <= 9.5d-56))) then
        tmp = z * (y * -t)
    else
        tmp = y * (x * t)
    end if
    code = tmp
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -3.7e-7) || !(z <= 9.5e-56)) {
		tmp = z * (y * -t);
	} else {
		tmp = y * (x * t);
	}
	return tmp;
}
[y, t] = sort([y, t])
def code(x, y, z, t):
	tmp = 0
	if (z <= -3.7e-7) or not (z <= 9.5e-56):
		tmp = z * (y * -t)
	else:
		tmp = y * (x * t)
	return tmp
y, t = sort([y, t])
function code(x, y, z, t)
	tmp = 0.0
	if ((z <= -3.7e-7) || !(z <= 9.5e-56))
		tmp = Float64(z * Float64(y * Float64(-t)));
	else
		tmp = Float64(y * Float64(x * t));
	end
	return tmp
end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((z <= -3.7e-7) || ~((z <= 9.5e-56)))
		tmp = z * (y * -t);
	else
		tmp = y * (x * t);
	end
	tmp_2 = tmp;
end
NOTE: y and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -3.7e-7], N[Not[LessEqual[z, 9.5e-56]], $MachinePrecision]], N[(z * N[(y * (-t)), $MachinePrecision]), $MachinePrecision], N[(y * N[(x * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.7 \cdot 10^{-7} \lor \neg \left(z \leq 9.5 \cdot 10^{-56}\right):\\
\;\;\;\;z \cdot \left(y \cdot \left(-t\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.70000000000000004e-7 or 9.4999999999999991e-56 < z

    1. Initial program 88.8%

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

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

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

      \[\leadsto \color{blue}{y \cdot \left(\left(x - z\right) \cdot t\right)} \]
    4. Step-by-step derivation
      1. add-cube-cbrt88.9%

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

        \[\leadsto y \cdot \color{blue}{{\left(\sqrt[3]{\left(x - z\right) \cdot t}\right)}^{3}} \]
    5. Applied egg-rr88.9%

      \[\leadsto y \cdot \color{blue}{{\left(\sqrt[3]{\left(x - z\right) \cdot t}\right)}^{3}} \]
    6. Taylor expanded in x around 0 72.7%

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

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

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

        \[\leadsto -\color{blue}{\left(t \cdot y\right)} \cdot z \]
      4. distribute-rgt-neg-in70.9%

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

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

    if -3.70000000000000004e-7 < z < 9.4999999999999991e-56

    1. Initial program 89.9%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.7 \cdot 10^{-7} \lor \neg \left(z \leq 9.5 \cdot 10^{-56}\right):\\ \;\;\;\;z \cdot \left(y \cdot \left(-t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \end{array} \]

Alternative 3: 72.8% accurate, 0.9× speedup?

\[\begin{array}{l} [y, t] = \mathsf{sort}([y, t])\\ \\ \begin{array}{l} \mathbf{if}\;z \leq -1.1 \cdot 10^{-7}:\\ \;\;\;\;y \cdot \left(z \cdot \left(-t\right)\right)\\ \mathbf{elif}\;z \leq 8.6 \cdot 10^{-56}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-t\right)\right)\\ \end{array} \end{array} \]
NOTE: y and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= z -1.1e-7)
   (* y (* z (- t)))
   (if (<= z 8.6e-56) (* y (* x t)) (* z (* y (- t))))))
assert(y < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -1.1e-7) {
		tmp = y * (z * -t);
	} else if (z <= 8.6e-56) {
		tmp = y * (x * t);
	} else {
		tmp = z * (y * -t);
	}
	return tmp;
}
NOTE: y and t should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (z <= (-1.1d-7)) then
        tmp = y * (z * -t)
    else if (z <= 8.6d-56) then
        tmp = y * (x * t)
    else
        tmp = z * (y * -t)
    end if
    code = tmp
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -1.1e-7) {
		tmp = y * (z * -t);
	} else if (z <= 8.6e-56) {
		tmp = y * (x * t);
	} else {
		tmp = z * (y * -t);
	}
	return tmp;
}
[y, t] = sort([y, t])
def code(x, y, z, t):
	tmp = 0
	if z <= -1.1e-7:
		tmp = y * (z * -t)
	elif z <= 8.6e-56:
		tmp = y * (x * t)
	else:
		tmp = z * (y * -t)
	return tmp
y, t = sort([y, t])
function code(x, y, z, t)
	tmp = 0.0
	if (z <= -1.1e-7)
		tmp = Float64(y * Float64(z * Float64(-t)));
	elseif (z <= 8.6e-56)
		tmp = Float64(y * Float64(x * t));
	else
		tmp = Float64(z * Float64(y * Float64(-t)));
	end
	return tmp
end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (z <= -1.1e-7)
		tmp = y * (z * -t);
	elseif (z <= 8.6e-56)
		tmp = y * (x * t);
	else
		tmp = z * (y * -t);
	end
	tmp_2 = tmp;
end
NOTE: y and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[z, -1.1e-7], N[(y * N[(z * (-t)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 8.6e-56], N[(y * N[(x * t), $MachinePrecision]), $MachinePrecision], N[(z * N[(y * (-t)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1 \cdot 10^{-7}:\\
\;\;\;\;y \cdot \left(z \cdot \left(-t\right)\right)\\

\mathbf{elif}\;z \leq 8.6 \cdot 10^{-56}:\\
\;\;\;\;y \cdot \left(x \cdot t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.1000000000000001e-7

    1. Initial program 93.7%

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

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

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

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

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

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

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

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

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

    if -1.1000000000000001e-7 < z < 8.6000000000000002e-56

    1. Initial program 89.9%

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

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

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

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

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

    if 8.6000000000000002e-56 < z

    1. Initial program 84.3%

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

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

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

      \[\leadsto \color{blue}{y \cdot \left(\left(x - z\right) \cdot t\right)} \]
    4. Step-by-step derivation
      1. add-cube-cbrt90.3%

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

        \[\leadsto y \cdot \color{blue}{{\left(\sqrt[3]{\left(x - z\right) \cdot t}\right)}^{3}} \]
    5. Applied egg-rr90.4%

      \[\leadsto y \cdot \color{blue}{{\left(\sqrt[3]{\left(x - z\right) \cdot t}\right)}^{3}} \]
    6. Taylor expanded in x around 0 72.4%

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

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

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

        \[\leadsto -\color{blue}{\left(t \cdot y\right)} \cdot z \]
      4. distribute-rgt-neg-in72.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.1 \cdot 10^{-7}:\\ \;\;\;\;y \cdot \left(z \cdot \left(-t\right)\right)\\ \mathbf{elif}\;z \leq 8.6 \cdot 10^{-56}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-t\right)\right)\\ \end{array} \]

Alternative 4: 73.1% accurate, 0.9× speedup?

\[\begin{array}{l} [y, t] = \mathsf{sort}([y, t])\\ \\ \begin{array}{l} \mathbf{if}\;z \leq -7.7 \cdot 10^{-7}:\\ \;\;\;\;t \cdot \left(y \cdot \left(-z\right)\right)\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{-56}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-t\right)\right)\\ \end{array} \end{array} \]
NOTE: y and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= z -7.7e-7)
   (* t (* y (- z)))
   (if (<= z 9.5e-56) (* y (* x t)) (* z (* y (- t))))))
assert(y < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -7.7e-7) {
		tmp = t * (y * -z);
	} else if (z <= 9.5e-56) {
		tmp = y * (x * t);
	} else {
		tmp = z * (y * -t);
	}
	return tmp;
}
NOTE: y and t should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (z <= (-7.7d-7)) then
        tmp = t * (y * -z)
    else if (z <= 9.5d-56) then
        tmp = y * (x * t)
    else
        tmp = z * (y * -t)
    end if
    code = tmp
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -7.7e-7) {
		tmp = t * (y * -z);
	} else if (z <= 9.5e-56) {
		tmp = y * (x * t);
	} else {
		tmp = z * (y * -t);
	}
	return tmp;
}
[y, t] = sort([y, t])
def code(x, y, z, t):
	tmp = 0
	if z <= -7.7e-7:
		tmp = t * (y * -z)
	elif z <= 9.5e-56:
		tmp = y * (x * t)
	else:
		tmp = z * (y * -t)
	return tmp
y, t = sort([y, t])
function code(x, y, z, t)
	tmp = 0.0
	if (z <= -7.7e-7)
		tmp = Float64(t * Float64(y * Float64(-z)));
	elseif (z <= 9.5e-56)
		tmp = Float64(y * Float64(x * t));
	else
		tmp = Float64(z * Float64(y * Float64(-t)));
	end
	return tmp
end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (z <= -7.7e-7)
		tmp = t * (y * -z);
	elseif (z <= 9.5e-56)
		tmp = y * (x * t);
	else
		tmp = z * (y * -t);
	end
	tmp_2 = tmp;
end
NOTE: y and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[z, -7.7e-7], N[(t * N[(y * (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 9.5e-56], N[(y * N[(x * t), $MachinePrecision]), $MachinePrecision], N[(z * N[(y * (-t)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.7 \cdot 10^{-7}:\\
\;\;\;\;t \cdot \left(y \cdot \left(-z\right)\right)\\

\mathbf{elif}\;z \leq 9.5 \cdot 10^{-56}:\\
\;\;\;\;y \cdot \left(x \cdot t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -7.7000000000000004e-7

    1. Initial program 93.7%

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

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

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

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

        \[\leadsto \color{blue}{\left(-y \cdot z\right)} \cdot t \]
      2. distribute-rgt-neg-out78.5%

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

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

    if -7.7000000000000004e-7 < z < 9.4999999999999991e-56

    1. Initial program 89.9%

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

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

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

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

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

    if 9.4999999999999991e-56 < z

    1. Initial program 84.3%

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

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

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

      \[\leadsto \color{blue}{y \cdot \left(\left(x - z\right) \cdot t\right)} \]
    4. Step-by-step derivation
      1. add-cube-cbrt90.3%

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

        \[\leadsto y \cdot \color{blue}{{\left(\sqrt[3]{\left(x - z\right) \cdot t}\right)}^{3}} \]
    5. Applied egg-rr90.4%

      \[\leadsto y \cdot \color{blue}{{\left(\sqrt[3]{\left(x - z\right) \cdot t}\right)}^{3}} \]
    6. Taylor expanded in x around 0 72.4%

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

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

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

        \[\leadsto -\color{blue}{\left(t \cdot y\right)} \cdot z \]
      4. distribute-rgt-neg-in72.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.7 \cdot 10^{-7}:\\ \;\;\;\;t \cdot \left(y \cdot \left(-z\right)\right)\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{-56}:\\ \;\;\;\;y \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-t\right)\right)\\ \end{array} \]

Alternative 5: 96.1% accurate, 1.0× speedup?

\[\begin{array}{l} [y, t] = \mathsf{sort}([y, t])\\ \\ \begin{array}{l} \mathbf{if}\;t \leq 1.95 \cdot 10^{+96}:\\ \;\;\;\;y \cdot \left(\left(x - z\right) \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\ \end{array} \end{array} \]
NOTE: y and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= t 1.95e+96) (* y (* (- x z) t)) (* t (* y (- x z)))))
assert(y < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= 1.95e+96) {
		tmp = y * ((x - z) * t);
	} else {
		tmp = t * (y * (x - z));
	}
	return tmp;
}
NOTE: y and t should be sorted in increasing order before calling this function.
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 <= 1.95d+96) then
        tmp = y * ((x - z) * t)
    else
        tmp = t * (y * (x - z))
    end if
    code = tmp
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= 1.95e+96) {
		tmp = y * ((x - z) * t);
	} else {
		tmp = t * (y * (x - z));
	}
	return tmp;
}
[y, t] = sort([y, t])
def code(x, y, z, t):
	tmp = 0
	if t <= 1.95e+96:
		tmp = y * ((x - z) * t)
	else:
		tmp = t * (y * (x - z))
	return tmp
y, t = sort([y, t])
function code(x, y, z, t)
	tmp = 0.0
	if (t <= 1.95e+96)
		tmp = Float64(y * Float64(Float64(x - z) * t));
	else
		tmp = Float64(t * Float64(y * Float64(x - z)));
	end
	return tmp
end
y, t = num2cell(sort([y, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (t <= 1.95e+96)
		tmp = y * ((x - z) * t);
	else
		tmp = t * (y * (x - z));
	end
	tmp_2 = tmp;
end
NOTE: y and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[t, 1.95e+96], N[(y * N[(N[(x - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], N[(t * N[(y * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq 1.95 \cdot 10^{+96}:\\
\;\;\;\;y \cdot \left(\left(x - z\right) \cdot t\right)\\

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


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

    1. Initial program 88.4%

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

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

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

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

    if 1.95e96 < t

    1. Initial program 94.9%

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

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

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

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

Alternative 6: 91.8% accurate, 1.3× speedup?

\[\begin{array}{l} [y, t] = \mathsf{sort}([y, t])\\ \\ y \cdot \left(\left(x - z\right) \cdot t\right) \end{array} \]
NOTE: y and t should be sorted in increasing order before calling this function.
(FPCore (x y z t) :precision binary64 (* y (* (- x z) t)))
assert(y < t);
double code(double x, double y, double z, double t) {
	return y * ((x - z) * t);
}
NOTE: y and t should be sorted in increasing order before calling this function.
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 = y * ((x - z) * t)
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
	return y * ((x - z) * t);
}
[y, t] = sort([y, t])
def code(x, y, z, t):
	return y * ((x - z) * t)
y, t = sort([y, t])
function code(x, y, z, t)
	return Float64(y * Float64(Float64(x - z) * t))
end
y, t = num2cell(sort([y, t])){:}
function tmp = code(x, y, z, t)
	tmp = y * ((x - z) * t);
end
NOTE: y and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := N[(y * N[(N[(x - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
y \cdot \left(\left(x - z\right) \cdot t\right)
\end{array}
Derivation
  1. Initial program 89.3%

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

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

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

    \[\leadsto \color{blue}{y \cdot \left(\left(x - z\right) \cdot t\right)} \]
  4. Final simplification91.0%

    \[\leadsto y \cdot \left(\left(x - z\right) \cdot t\right) \]

Alternative 7: 53.1% accurate, 1.8× speedup?

\[\begin{array}{l} [y, t] = \mathsf{sort}([y, t])\\ \\ y \cdot \left(x \cdot t\right) \end{array} \]
NOTE: y and t should be sorted in increasing order before calling this function.
(FPCore (x y z t) :precision binary64 (* y (* x t)))
assert(y < t);
double code(double x, double y, double z, double t) {
	return y * (x * t);
}
NOTE: y and t should be sorted in increasing order before calling this function.
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 = y * (x * t)
end function
assert y < t;
public static double code(double x, double y, double z, double t) {
	return y * (x * t);
}
[y, t] = sort([y, t])
def code(x, y, z, t):
	return y * (x * t)
y, t = sort([y, t])
function code(x, y, z, t)
	return Float64(y * Float64(x * t))
end
y, t = num2cell(sort([y, t])){:}
function tmp = code(x, y, z, t)
	tmp = y * (x * t);
end
NOTE: y and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := N[(y * N[(x * t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[y, t] = \mathsf{sort}([y, t])\\
\\
y \cdot \left(x \cdot t\right)
\end{array}
Derivation
  1. Initial program 89.3%

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

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

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

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

    \[\leadsto \color{blue}{y \cdot \left(t \cdot x\right)} \]
  5. Final simplification57.7%

    \[\leadsto y \cdot \left(x \cdot t\right) \]

Developer target: 96.0% accurate, 0.8× 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 2023278 
(FPCore (x y z t)
  :name "Linear.Projection:inverseInfinitePerspective from linear-1.19.1.3"
  :precision binary64

  :herbie-target
  (if (< t -9.231879582886777e-80) (* (* y t) (- x z)) (if (< t 2.543067051564877e+83) (* y (* t (- x z))) (* (* y (- x z)) t)))

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