Numeric.Signal.Multichannel:$cget from hsignal-0.2.7.1

Percentage Accurate: 97.5% → 97.5%
Time: 7.3s
Alternatives: 9
Speedup: 1.0×

Specification

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

\\
\frac{x}{y} \cdot \left(z - t\right) + 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: 97.5% accurate, 1.0× speedup?

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

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

Alternative 1: 97.5% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\frac{x}{y}, z - t, t\right) \end{array} \]
(FPCore (x y z t) :precision binary64 (fma (/ x y) (- z t) t))
double code(double x, double y, double z, double t) {
	return fma((x / y), (z - t), t);
}
function code(x, y, z, t)
	return fma(Float64(x / y), Float64(z - t), t)
end
code[x_, y_, z_, t_] := N[(N[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision] + t), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\frac{x}{y}, z - t, t\right)
\end{array}
Derivation
  1. Initial program 99.8%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, z - t, t\right)} \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, z - t, t\right)} \]
  4. Add Preprocessing
  5. Final simplification99.8%

    \[\leadsto \mathsf{fma}\left(\frac{x}{y}, z - t, t\right) \]
  6. Add Preprocessing

Alternative 2: 85.5% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.5 \cdot 10^{+58} \lor \neg \left(t \leq 6 \cdot 10^{+130}\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -3.4999999999999997e58 or 5.9999999999999999e130 < t

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{t + -1 \cdot \frac{t \cdot x}{y}} \]
    4. Step-by-step derivation
      1. mul-1-neg83.6%

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

        \[\leadsto \color{blue}{t - \frac{t \cdot x}{y}} \]
      3. *-rgt-identity83.6%

        \[\leadsto \color{blue}{t \cdot 1} - \frac{t \cdot x}{y} \]
      4. associate-*r/93.3%

        \[\leadsto t \cdot 1 - \color{blue}{t \cdot \frac{x}{y}} \]
      5. distribute-lft-out--93.3%

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

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

    if -3.4999999999999997e58 < t < 5.9999999999999999e130

    1. Initial program 99.7%

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

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + t \]
    4. Step-by-step derivation
      1. associate-*l/86.2%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + t \]
      2. *-commutative86.2%

        \[\leadsto \color{blue}{z \cdot \frac{x}{y}} + t \]
    5. Simplified86.2%

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

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

Alternative 3: 85.5% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.5 \cdot 10^{+58} \lor \neg \left(t \leq 1.25 \cdot 10^{+129}\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -4.4999999999999998e58 or 1.2500000000000001e129 < t

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{t + -1 \cdot \frac{t \cdot x}{y}} \]
    4. Step-by-step derivation
      1. mul-1-neg83.6%

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

        \[\leadsto \color{blue}{t - \frac{t \cdot x}{y}} \]
      3. *-rgt-identity83.6%

        \[\leadsto \color{blue}{t \cdot 1} - \frac{t \cdot x}{y} \]
      4. associate-*r/93.3%

        \[\leadsto t \cdot 1 - \color{blue}{t \cdot \frac{x}{y}} \]
      5. distribute-lft-out--93.3%

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

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

    if -4.4999999999999998e58 < t < 1.2500000000000001e129

    1. Initial program 99.7%

      \[\frac{x}{y} \cdot \left(z - t\right) + t \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative99.7%

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

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

        \[\leadsto \color{blue}{\frac{z - t}{\frac{y}{x}}} + t \]
    4. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\frac{z - t}{\frac{y}{x}}} + t \]
    5. Taylor expanded in z around inf 79.5%

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + t \]
    6. Step-by-step derivation
      1. *-commutative79.5%

        \[\leadsto \frac{\color{blue}{z \cdot x}}{y} + t \]
      2. associate-/l*86.2%

        \[\leadsto \color{blue}{\frac{z}{\frac{y}{x}}} + t \]
    7. Simplified86.2%

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

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

Alternative 4: 85.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -2.9 \cdot 10^{+58}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{elif}\;t \leq 1.35 \cdot 10^{+129}:\\ \;\;\;\;t + \frac{z}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;t - \frac{x}{y} \cdot t\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= t -2.9e+58)
   (* t (- 1.0 (/ x y)))
   (if (<= t 1.35e+129) (+ t (/ z (/ y x))) (- t (* (/ x y) t)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= -2.9e+58) {
		tmp = t * (1.0 - (x / y));
	} else if (t <= 1.35e+129) {
		tmp = t + (z / (y / x));
	} else {
		tmp = t - ((x / y) * t);
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (t <= (-2.9d+58)) then
        tmp = t * (1.0d0 - (x / y))
    else if (t <= 1.35d+129) then
        tmp = t + (z / (y / x))
    else
        tmp = t - ((x / y) * t)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= -2.9e+58) {
		tmp = t * (1.0 - (x / y));
	} else if (t <= 1.35e+129) {
		tmp = t + (z / (y / x));
	} else {
		tmp = t - ((x / y) * t);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if t <= -2.9e+58:
		tmp = t * (1.0 - (x / y))
	elif t <= 1.35e+129:
		tmp = t + (z / (y / x))
	else:
		tmp = t - ((x / y) * t)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (t <= -2.9e+58)
		tmp = Float64(t * Float64(1.0 - Float64(x / y)));
	elseif (t <= 1.35e+129)
		tmp = Float64(t + Float64(z / Float64(y / x)));
	else
		tmp = Float64(t - Float64(Float64(x / y) * t));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (t <= -2.9e+58)
		tmp = t * (1.0 - (x / y));
	elseif (t <= 1.35e+129)
		tmp = t + (z / (y / x));
	else
		tmp = t - ((x / y) * t);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[t, -2.9e+58], N[(t * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.35e+129], N[(t + N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t - N[(N[(x / y), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;t \leq 1.35 \cdot 10^{+129}:\\
\;\;\;\;t + \frac{z}{\frac{y}{x}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < -2.90000000000000002e58

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{t + -1 \cdot \frac{t \cdot x}{y}} \]
    4. Step-by-step derivation
      1. mul-1-neg81.1%

        \[\leadsto t + \color{blue}{\left(-\frac{t \cdot x}{y}\right)} \]
      2. unsub-neg81.1%

        \[\leadsto \color{blue}{t - \frac{t \cdot x}{y}} \]
      3. *-rgt-identity81.1%

        \[\leadsto \color{blue}{t \cdot 1} - \frac{t \cdot x}{y} \]
      4. associate-*r/89.5%

        \[\leadsto t \cdot 1 - \color{blue}{t \cdot \frac{x}{y}} \]
      5. distribute-lft-out--89.6%

        \[\leadsto \color{blue}{t \cdot \left(1 - \frac{x}{y}\right)} \]
    5. Simplified89.6%

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

    if -2.90000000000000002e58 < t < 1.35e129

    1. Initial program 99.7%

      \[\frac{x}{y} \cdot \left(z - t\right) + t \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative99.7%

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

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

        \[\leadsto \color{blue}{\frac{z - t}{\frac{y}{x}}} + t \]
    4. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\frac{z - t}{\frac{y}{x}}} + t \]
    5. Taylor expanded in z around inf 79.5%

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + t \]
    6. Step-by-step derivation
      1. *-commutative79.5%

        \[\leadsto \frac{\color{blue}{z \cdot x}}{y} + t \]
      2. associate-/l*86.2%

        \[\leadsto \color{blue}{\frac{z}{\frac{y}{x}}} + t \]
    7. Simplified86.2%

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

    if 1.35e129 < t

    1. Initial program 100.0%

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

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

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

        \[\leadsto \color{blue}{\frac{z - t}{\frac{y}{x}}} + t \]
    4. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\frac{z - t}{\frac{y}{x}}} + t \]
    5. Taylor expanded in z around 0 87.9%

      \[\leadsto \color{blue}{t + -1 \cdot \frac{t \cdot x}{y}} \]
    6. Step-by-step derivation
      1. mul-1-neg87.9%

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

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

        \[\leadsto t + \color{blue}{\left(-t\right) \cdot \frac{x}{y}} \]
      4. cancel-sign-sub-inv100.0%

        \[\leadsto \color{blue}{t - t \cdot \frac{x}{y}} \]
    7. Simplified100.0%

      \[\leadsto \color{blue}{t - t \cdot \frac{x}{y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification88.7%

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

Alternative 5: 50.7% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{-24}:\\
\;\;\;\;t\\

\mathbf{elif}\;y \leq 5.2 \cdot 10^{+19}:\\
\;\;\;\;t \cdot \frac{x}{-y}\\

\mathbf{else}:\\
\;\;\;\;t\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.99999999999999991e-24 or 5.2e19 < y

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{t} \]

    if -5.99999999999999991e-24 < y < 5.2e19

    1. Initial program 99.8%

      \[\frac{x}{y} \cdot \left(z - t\right) + t \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative99.8%

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

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

        \[\leadsto \color{blue}{\frac{z - t}{\frac{y}{x}}} + t \]
    4. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\frac{z - t}{\frac{y}{x}}} + t \]
    5. Taylor expanded in z around 0 62.5%

      \[\leadsto \color{blue}{t + -1 \cdot \frac{t \cdot x}{y}} \]
    6. Step-by-step derivation
      1. mul-1-neg62.5%

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

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

        \[\leadsto t + \color{blue}{\left(-t\right) \cdot \frac{x}{y}} \]
      4. cancel-sign-sub-inv63.9%

        \[\leadsto \color{blue}{t - t \cdot \frac{x}{y}} \]
    7. Simplified63.9%

      \[\leadsto \color{blue}{t - t \cdot \frac{x}{y}} \]
    8. Taylor expanded in x around inf 50.2%

      \[\leadsto \color{blue}{-1 \cdot \frac{t \cdot x}{y}} \]
    9. Step-by-step derivation
      1. mul-1-neg50.2%

        \[\leadsto \color{blue}{-\frac{t \cdot x}{y}} \]
      2. associate-*r/51.7%

        \[\leadsto -\color{blue}{t \cdot \frac{x}{y}} \]
      3. distribute-rgt-neg-out51.7%

        \[\leadsto \color{blue}{t \cdot \left(-\frac{x}{y}\right)} \]
      4. distribute-neg-frac51.7%

        \[\leadsto t \cdot \color{blue}{\frac{-x}{y}} \]
      5. distribute-neg-frac51.7%

        \[\leadsto t \cdot \color{blue}{\left(-\frac{x}{y}\right)} \]
      6. *-rgt-identity51.7%

        \[\leadsto t \cdot \left(-\color{blue}{\frac{x}{y} \cdot 1}\right) \]
      7. *-commutative51.7%

        \[\leadsto t \cdot \left(-\color{blue}{1 \cdot \frac{x}{y}}\right) \]
      8. metadata-eval51.7%

        \[\leadsto t \cdot \left(-\color{blue}{\frac{-1}{-1}} \cdot \frac{x}{y}\right) \]
      9. times-frac51.7%

        \[\leadsto t \cdot \left(-\color{blue}{\frac{-1 \cdot x}{-1 \cdot y}}\right) \]
      10. neg-mul-151.7%

        \[\leadsto t \cdot \left(-\frac{\color{blue}{-x}}{-1 \cdot y}\right) \]
      11. neg-mul-151.7%

        \[\leadsto t \cdot \left(-\frac{-x}{\color{blue}{-y}}\right) \]
      12. distribute-frac-neg51.7%

        \[\leadsto t \cdot \color{blue}{\frac{-\left(-x\right)}{-y}} \]
      13. remove-double-neg51.7%

        \[\leadsto t \cdot \frac{\color{blue}{x}}{-y} \]
    10. Simplified51.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6 \cdot 10^{-24}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{+19}:\\ \;\;\;\;t \cdot \frac{x}{-y}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 97.5% accurate, 1.0× speedup?

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

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

    \[\frac{x}{y} \cdot \left(z - t\right) + t \]
  2. Add Preprocessing
  3. Final simplification99.8%

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

Alternative 7: 97.5% accurate, 1.0× speedup?

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

\\
t + \frac{z - t}{\frac{y}{x}}
\end{array}
Derivation
  1. Initial program 99.8%

    \[\frac{x}{y} \cdot \left(z - t\right) + t \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. *-commutative99.8%

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

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

      \[\leadsto \color{blue}{\frac{z - t}{\frac{y}{x}}} + t \]
  4. Applied egg-rr99.8%

    \[\leadsto \color{blue}{\frac{z - t}{\frac{y}{x}}} + t \]
  5. Final simplification99.8%

    \[\leadsto t + \frac{z - t}{\frac{y}{x}} \]
  6. Add Preprocessing

Alternative 8: 64.6% accurate, 1.3× speedup?

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

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

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

    \[\leadsto \color{blue}{t + -1 \cdot \frac{t \cdot x}{y}} \]
  4. Step-by-step derivation
    1. mul-1-neg61.9%

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

      \[\leadsto \color{blue}{t - \frac{t \cdot x}{y}} \]
    3. *-rgt-identity61.9%

      \[\leadsto \color{blue}{t \cdot 1} - \frac{t \cdot x}{y} \]
    4. associate-*r/66.4%

      \[\leadsto t \cdot 1 - \color{blue}{t \cdot \frac{x}{y}} \]
    5. distribute-lft-out--66.4%

      \[\leadsto \color{blue}{t \cdot \left(1 - \frac{x}{y}\right)} \]
  5. Simplified66.4%

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

    \[\leadsto t \cdot \left(1 - \frac{x}{y}\right) \]
  7. Add Preprocessing

Alternative 9: 37.5% accurate, 9.0× speedup?

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

\\
t
\end{array}
Derivation
  1. Initial program 99.8%

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

    \[\leadsto \color{blue}{t} \]
  4. Final simplification37.2%

    \[\leadsto t \]
  5. Add Preprocessing

Developer target: 97.2% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_1 := \frac{x}{y} \cdot \left(z - t\right) + t\\
\mathbf{if}\;z < 2.759456554562692 \cdot 10^{-282}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z < 2.326994450874436 \cdot 10^{-110}:\\
\;\;\;\;x \cdot \frac{z - t}{y} + t\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024020 
(FPCore (x y z t)
  :name "Numeric.Signal.Multichannel:$cget from hsignal-0.2.7.1"
  :precision binary64

  :herbie-target
  (if (< z 2.759456554562692e-282) (+ (* (/ x y) (- z t)) t) (if (< z 2.326994450874436e-110) (+ (* x (/ (- z t) y)) t) (+ (* (/ x y) (- z t)) t)))

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