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

Percentage Accurate: 97.1% → 97.1%
Time: 7.8s
Alternatives: 8
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \frac{x - y}{z - y} \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}

\\
\frac{x - y}{z - y} \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 8 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.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x - y}{z - y} \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}

\\
\frac{x - y}{z - y} \cdot t
\end{array}

Alternative 1: 97.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x - y}{z - y} \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}

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

    \[\frac{x - y}{z - y} \cdot t \]
  2. Add Preprocessing
  3. Final simplification98.7%

    \[\leadsto \frac{x - y}{z - y} \cdot t \]
  4. Add Preprocessing

Alternative 2: 90.1% accurate, 0.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.2000000000000003e211 or 4.9e129 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \cdot t \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 93.6%

      \[\leadsto \color{blue}{\left(-1 \cdot \frac{x - y}{y}\right)} \cdot t \]
    4. Step-by-step derivation
      1. mul-1-neg93.6%

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

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

      \[\leadsto \color{blue}{t + -1 \cdot \frac{t \cdot x}{y}} \]
    7. Step-by-step derivation
      1. *-rgt-identity77.9%

        \[\leadsto \color{blue}{t \cdot 1} + -1 \cdot \frac{t \cdot x}{y} \]
      2. mul-1-neg77.9%

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

        \[\leadsto t \cdot 1 + \left(-\color{blue}{t \cdot \frac{x}{y}}\right) \]
      4. distribute-rgt-neg-in93.6%

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

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

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

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

    if -6.2000000000000003e211 < y < 4.9e129

    1. Initial program 98.2%

      \[\frac{x - y}{z - y} \cdot t \]
    2. Step-by-step derivation
      1. associate-*l/88.1%

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

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

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

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

Alternative 3: 70.8% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.3 \cdot 10^{-83} \lor \neg \left(y \leq 0.00032\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.2999999999999999e-83 or 3.20000000000000026e-4 < y

    1. Initial program 99.9%

      \[\frac{x - y}{z - y} \cdot t \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 81.2%

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

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

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

      \[\leadsto \color{blue}{t + -1 \cdot \frac{t \cdot x}{y}} \]
    7. Step-by-step derivation
      1. *-rgt-identity71.1%

        \[\leadsto \color{blue}{t \cdot 1} + -1 \cdot \frac{t \cdot x}{y} \]
      2. mul-1-neg71.1%

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

        \[\leadsto t \cdot 1 + \left(-\color{blue}{t \cdot \frac{x}{y}}\right) \]
      4. distribute-rgt-neg-in81.1%

        \[\leadsto t \cdot 1 + \color{blue}{t \cdot \left(-\frac{x}{y}\right)} \]
      5. distribute-lft-in81.2%

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

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

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

    if -3.2999999999999999e-83 < y < 3.20000000000000026e-4

    1. Initial program 97.1%

      \[\frac{x - y}{z - y} \cdot t \]
    2. Step-by-step derivation
      1. associate-*l/92.6%

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

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

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

      \[\leadsto \color{blue}{\frac{t \cdot x}{z}} \]
    6. Step-by-step derivation
      1. *-commutative60.9%

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

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

      \[\leadsto \color{blue}{x \cdot \frac{t}{z}} \]
    8. Taylor expanded in x around 0 60.9%

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

        \[\leadsto \color{blue}{t \cdot \frac{x}{z}} \]
    10. Simplified65.0%

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

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

Alternative 4: 73.2% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.95 \cdot 10^{-83} \lor \neg \left(y \leq 380\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.95e-83 or 380 < y

    1. Initial program 99.9%

      \[\frac{x - y}{z - y} \cdot t \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 82.2%

      \[\leadsto \color{blue}{\left(-1 \cdot \frac{x - y}{y}\right)} \cdot t \]
    4. Step-by-step derivation
      1. mul-1-neg82.2%

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

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

      \[\leadsto \color{blue}{t + -1 \cdot \frac{t \cdot x}{y}} \]
    7. Step-by-step derivation
      1. *-rgt-identity72.1%

        \[\leadsto \color{blue}{t \cdot 1} + -1 \cdot \frac{t \cdot x}{y} \]
      2. mul-1-neg72.1%

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

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

        \[\leadsto t \cdot 1 + \color{blue}{t \cdot \left(-\frac{x}{y}\right)} \]
      5. distribute-lft-in82.2%

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

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

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

    if -1.95e-83 < y < 380

    1. Initial program 97.1%

      \[\frac{x - y}{z - y} \cdot t \]
    2. Step-by-step derivation
      1. associate-*l/92.7%

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

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

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

      \[\leadsto \color{blue}{\frac{t \cdot \left(x - y\right)}{z}} \]
    6. Step-by-step derivation
      1. *-commutative74.9%

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

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

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

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

Alternative 5: 76.7% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{-8} \lor \neg \left(y \leq 4 \cdot 10^{+38}\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.70000000000000002e-8 or 3.99999999999999991e38 < y

    1. Initial program 99.9%

      \[\frac{x - y}{z - y} \cdot t \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 86.4%

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

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

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

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

        \[\leadsto \color{blue}{t \cdot 1} + -1 \cdot \frac{t \cdot x}{y} \]
      2. mul-1-neg74.6%

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

        \[\leadsto t \cdot 1 + \left(-\color{blue}{t \cdot \frac{x}{y}}\right) \]
      4. distribute-rgt-neg-in86.4%

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

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

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

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

    if -2.70000000000000002e-8 < y < 3.99999999999999991e38

    1. Initial program 97.5%

      \[\frac{x - y}{z - y} \cdot t \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 74.3%

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

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

Alternative 6: 73.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.45 \cdot 10^{-83} \lor \neg \left(y \leq 26\right):\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{x - y}{z}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= y -2.45e-83) (not (<= y 26.0)))
   (* t (- 1.0 (/ x y)))
   (* t (/ (- x y) z))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y <= -2.45e-83) || !(y <= 26.0)) {
		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 ((y <= (-2.45d-83)) .or. (.not. (y <= 26.0d0))) 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 ((y <= -2.45e-83) || !(y <= 26.0)) {
		tmp = t * (1.0 - (x / y));
	} else {
		tmp = t * ((x - y) / z);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (y <= -2.45e-83) or not (y <= 26.0):
		tmp = t * (1.0 - (x / y))
	else:
		tmp = t * ((x - y) / z)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((y <= -2.45e-83) || !(y <= 26.0))
		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 ((y <= -2.45e-83) || ~((y <= 26.0)))
		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[y, -2.45e-83], N[Not[LessEqual[y, 26.0]], $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}\;y \leq -2.45 \cdot 10^{-83} \lor \neg \left(y \leq 26\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.45e-83 or 26 < y

    1. Initial program 99.9%

      \[\frac{x - y}{z - y} \cdot t \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 82.2%

      \[\leadsto \color{blue}{\left(-1 \cdot \frac{x - y}{y}\right)} \cdot t \]
    4. Step-by-step derivation
      1. mul-1-neg82.2%

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

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

      \[\leadsto \color{blue}{t + -1 \cdot \frac{t \cdot x}{y}} \]
    7. Step-by-step derivation
      1. *-rgt-identity72.1%

        \[\leadsto \color{blue}{t \cdot 1} + -1 \cdot \frac{t \cdot x}{y} \]
      2. mul-1-neg72.1%

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

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

        \[\leadsto t \cdot 1 + \color{blue}{t \cdot \left(-\frac{x}{y}\right)} \]
      5. distribute-lft-in82.2%

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

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

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

    if -2.45e-83 < y < 26

    1. Initial program 97.1%

      \[\frac{x - y}{z - y} \cdot t \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 78.1%

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

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

Alternative 7: 62.6% accurate, 0.6× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.79999999999999997e-7 or 1.02e40 < y

    1. Initial program 99.9%

      \[\frac{x - y}{z - y} \cdot t \]
    2. Step-by-step derivation
      1. associate-*l/64.5%

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

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

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

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

    if -1.79999999999999997e-7 < y < 1.02e40

    1. Initial program 97.5%

      \[\frac{x - y}{z - y} \cdot t \]
    2. Step-by-step derivation
      1. associate-*l/93.7%

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \frac{t}{z}} \]
    8. Taylor expanded in x around 0 55.6%

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

        \[\leadsto \color{blue}{t \cdot \frac{x}{z}} \]
    10. Simplified59.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.8 \cdot 10^{-7}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 1.02 \cdot 10^{+40}:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 35.0% 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 98.7%

    \[\frac{x - y}{z - y} \cdot t \]
  2. Step-by-step derivation
    1. associate-*l/79.5%

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

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

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

    \[\leadsto \color{blue}{t} \]
  6. Final simplification40.3%

    \[\leadsto t \]
  7. Add Preprocessing

Developer target: 97.1% accurate, 1.0× speedup?

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

\\
\frac{t}{\frac{z - y}{x - y}}
\end{array}

Reproduce

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

  :alt
  (/ t (/ (- z y) (- x y)))

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