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

Percentage Accurate: 96.9% → 96.9%
Time: 8.1s
Alternatives: 7
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 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: 96.9% 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: 96.9% accurate, 1.0× speedup?

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{t}{\frac{z - y}{x - y}}} \]
    4. sub-neg97.2%

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

      \[\leadsto \frac{t}{\frac{z - y}{\color{blue}{\left(-y\right) + x}}} \]
    6. neg-sub097.2%

      \[\leadsto \frac{t}{\frac{z - y}{\color{blue}{\left(0 - y\right)} + x}} \]
    7. associate-+l-97.2%

      \[\leadsto \frac{t}{\frac{z - y}{\color{blue}{0 - \left(y - x\right)}}} \]
    8. sub0-neg97.2%

      \[\leadsto \frac{t}{\frac{z - y}{\color{blue}{-\left(y - x\right)}}} \]
    9. neg-mul-197.2%

      \[\leadsto \frac{t}{\frac{z - y}{\color{blue}{-1 \cdot \left(y - x\right)}}} \]
    10. associate-/r*97.2%

      \[\leadsto \frac{t}{\color{blue}{\frac{\frac{z - y}{-1}}{y - x}}} \]
  3. Simplified97.2%

    \[\leadsto \color{blue}{\frac{t}{\frac{y - z}{y - x}}} \]
  4. Final simplification97.2%

    \[\leadsto \frac{t}{\frac{y - z}{y - x}} \]

Alternative 2: 69.7% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := t \cdot \frac{y - x}{y}\\ t_2 := \left(x - y\right) \cdot \frac{t}{z}\\ \mathbf{if}\;z \leq -4.7 \cdot 10^{+49}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-152}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-104}:\\ \;\;\;\;\frac{t \cdot x}{z}\\ \mathbf{elif}\;z \leq 1.14 \cdot 10^{+61}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* t (/ (- y x) y))) (t_2 (* (- x y) (/ t z))))
   (if (<= z -4.7e+49)
     t_2
     (if (<= z 2.4e-152)
       t_1
       (if (<= z 4e-104) (/ (* t x) z) (if (<= z 1.14e+61) t_1 t_2))))))
double code(double x, double y, double z, double t) {
	double t_1 = t * ((y - x) / y);
	double t_2 = (x - y) * (t / z);
	double tmp;
	if (z <= -4.7e+49) {
		tmp = t_2;
	} else if (z <= 2.4e-152) {
		tmp = t_1;
	} else if (z <= 4e-104) {
		tmp = (t * x) / z;
	} else if (z <= 1.14e+61) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	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) :: t_2
    real(8) :: tmp
    t_1 = t * ((y - x) / y)
    t_2 = (x - y) * (t / z)
    if (z <= (-4.7d+49)) then
        tmp = t_2
    else if (z <= 2.4d-152) then
        tmp = t_1
    else if (z <= 4d-104) then
        tmp = (t * x) / z
    else if (z <= 1.14d+61) then
        tmp = t_1
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = t * ((y - x) / y);
	double t_2 = (x - y) * (t / z);
	double tmp;
	if (z <= -4.7e+49) {
		tmp = t_2;
	} else if (z <= 2.4e-152) {
		tmp = t_1;
	} else if (z <= 4e-104) {
		tmp = (t * x) / z;
	} else if (z <= 1.14e+61) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = t * ((y - x) / y)
	t_2 = (x - y) * (t / z)
	tmp = 0
	if z <= -4.7e+49:
		tmp = t_2
	elif z <= 2.4e-152:
		tmp = t_1
	elif z <= 4e-104:
		tmp = (t * x) / z
	elif z <= 1.14e+61:
		tmp = t_1
	else:
		tmp = t_2
	return tmp
function code(x, y, z, t)
	t_1 = Float64(t * Float64(Float64(y - x) / y))
	t_2 = Float64(Float64(x - y) * Float64(t / z))
	tmp = 0.0
	if (z <= -4.7e+49)
		tmp = t_2;
	elseif (z <= 2.4e-152)
		tmp = t_1;
	elseif (z <= 4e-104)
		tmp = Float64(Float64(t * x) / z);
	elseif (z <= 1.14e+61)
		tmp = t_1;
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = t * ((y - x) / y);
	t_2 = (x - y) * (t / z);
	tmp = 0.0;
	if (z <= -4.7e+49)
		tmp = t_2;
	elseif (z <= 2.4e-152)
		tmp = t_1;
	elseif (z <= 4e-104)
		tmp = (t * x) / z;
	elseif (z <= 1.14e+61)
		tmp = t_1;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t * N[(N[(y - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x - y), $MachinePrecision] * N[(t / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.7e+49], t$95$2, If[LessEqual[z, 2.4e-152], t$95$1, If[LessEqual[z, 4e-104], N[(N[(t * x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 1.14e+61], t$95$1, t$95$2]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := t \cdot \frac{y - x}{y}\\
t_2 := \left(x - y\right) \cdot \frac{t}{z}\\
\mathbf{if}\;z \leq -4.7 \cdot 10^{+49}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;z \leq 2.4 \cdot 10^{-152}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 4 \cdot 10^{-104}:\\
\;\;\;\;\frac{t \cdot x}{z}\\

\mathbf{elif}\;z \leq 1.14 \cdot 10^{+61}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -4.6999999999999997e49 or 1.13999999999999996e61 < z

    1. Initial program 97.0%

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

      \[\leadsto \color{blue}{\frac{t \cdot \left(x - y\right)}{z}} \]
    3. Step-by-step derivation
      1. associate-/l*79.1%

        \[\leadsto \color{blue}{\frac{t}{\frac{z}{x - y}}} \]
      2. associate-/r/77.1%

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

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

    if -4.6999999999999997e49 < z < 2.4e-152 or 3.99999999999999971e-104 < z < 1.13999999999999996e61

    1. Initial program 99.2%

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

      \[\leadsto \color{blue}{\left(-1 \cdot \frac{x - y}{y}\right)} \cdot t \]
    3. Step-by-step derivation
      1. associate-*r/83.5%

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

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

        \[\leadsto \frac{\color{blue}{0 - \left(x - y\right)}}{y} \cdot t \]
      4. associate--r-83.5%

        \[\leadsto \frac{\color{blue}{\left(0 - x\right) + y}}{y} \cdot t \]
      5. neg-sub083.5%

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

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{y} \cdot t \]
      7. sub-neg83.5%

        \[\leadsto \frac{\color{blue}{y - x}}{y} \cdot t \]
    4. Simplified83.5%

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

    if 2.4e-152 < z < 3.99999999999999971e-104

    1. Initial program 73.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.7 \cdot 10^{+49}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z}\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-152}:\\ \;\;\;\;t \cdot \frac{y - x}{y}\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-104}:\\ \;\;\;\;\frac{t \cdot x}{z}\\ \mathbf{elif}\;z \leq 1.14 \cdot 10^{+61}:\\ \;\;\;\;t \cdot \frac{y - x}{y}\\ \mathbf{else}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z}\\ \end{array} \]

Alternative 3: 72.2% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := t \cdot \frac{y - x}{y}\\ t_2 := \frac{t}{\frac{z}{x - y}}\\ \mathbf{if}\;z \leq -4.6 \cdot 10^{+38}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-152}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-104}:\\ \;\;\;\;\frac{t \cdot x}{z}\\ \mathbf{elif}\;z \leq 1.14 \cdot 10^{+61}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* t (/ (- y x) y))) (t_2 (/ t (/ z (- x y)))))
   (if (<= z -4.6e+38)
     t_2
     (if (<= z 2.4e-152)
       t_1
       (if (<= z 4e-104) (/ (* t x) z) (if (<= z 1.14e+61) t_1 t_2))))))
double code(double x, double y, double z, double t) {
	double t_1 = t * ((y - x) / y);
	double t_2 = t / (z / (x - y));
	double tmp;
	if (z <= -4.6e+38) {
		tmp = t_2;
	} else if (z <= 2.4e-152) {
		tmp = t_1;
	} else if (z <= 4e-104) {
		tmp = (t * x) / z;
	} else if (z <= 1.14e+61) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	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) :: t_2
    real(8) :: tmp
    t_1 = t * ((y - x) / y)
    t_2 = t / (z / (x - y))
    if (z <= (-4.6d+38)) then
        tmp = t_2
    else if (z <= 2.4d-152) then
        tmp = t_1
    else if (z <= 4d-104) then
        tmp = (t * x) / z
    else if (z <= 1.14d+61) then
        tmp = t_1
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = t * ((y - x) / y);
	double t_2 = t / (z / (x - y));
	double tmp;
	if (z <= -4.6e+38) {
		tmp = t_2;
	} else if (z <= 2.4e-152) {
		tmp = t_1;
	} else if (z <= 4e-104) {
		tmp = (t * x) / z;
	} else if (z <= 1.14e+61) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = t * ((y - x) / y)
	t_2 = t / (z / (x - y))
	tmp = 0
	if z <= -4.6e+38:
		tmp = t_2
	elif z <= 2.4e-152:
		tmp = t_1
	elif z <= 4e-104:
		tmp = (t * x) / z
	elif z <= 1.14e+61:
		tmp = t_1
	else:
		tmp = t_2
	return tmp
function code(x, y, z, t)
	t_1 = Float64(t * Float64(Float64(y - x) / y))
	t_2 = Float64(t / Float64(z / Float64(x - y)))
	tmp = 0.0
	if (z <= -4.6e+38)
		tmp = t_2;
	elseif (z <= 2.4e-152)
		tmp = t_1;
	elseif (z <= 4e-104)
		tmp = Float64(Float64(t * x) / z);
	elseif (z <= 1.14e+61)
		tmp = t_1;
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = t * ((y - x) / y);
	t_2 = t / (z / (x - y));
	tmp = 0.0;
	if (z <= -4.6e+38)
		tmp = t_2;
	elseif (z <= 2.4e-152)
		tmp = t_1;
	elseif (z <= 4e-104)
		tmp = (t * x) / z;
	elseif (z <= 1.14e+61)
		tmp = t_1;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t * N[(N[(y - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t / N[(z / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.6e+38], t$95$2, If[LessEqual[z, 2.4e-152], t$95$1, If[LessEqual[z, 4e-104], N[(N[(t * x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 1.14e+61], t$95$1, t$95$2]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := t \cdot \frac{y - x}{y}\\
t_2 := \frac{t}{\frac{z}{x - y}}\\
\mathbf{if}\;z \leq -4.6 \cdot 10^{+38}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;z \leq 2.4 \cdot 10^{-152}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 4 \cdot 10^{-104}:\\
\;\;\;\;\frac{t \cdot x}{z}\\

\mathbf{elif}\;z \leq 1.14 \cdot 10^{+61}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -4.6000000000000002e38 or 1.13999999999999996e61 < z

    1. Initial program 97.1%

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

      \[\leadsto \color{blue}{\frac{t \cdot \left(x - y\right)}{z}} \]
    3. Step-by-step derivation
      1. associate-/l*78.6%

        \[\leadsto \color{blue}{\frac{t}{\frac{z}{x - y}}} \]
    4. Simplified78.6%

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

    if -4.6000000000000002e38 < z < 2.4e-152 or 3.99999999999999971e-104 < z < 1.13999999999999996e61

    1. Initial program 99.2%

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

      \[\leadsto \color{blue}{\left(-1 \cdot \frac{x - y}{y}\right)} \cdot t \]
    3. Step-by-step derivation
      1. associate-*r/83.9%

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

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

        \[\leadsto \frac{\color{blue}{0 - \left(x - y\right)}}{y} \cdot t \]
      4. associate--r-83.9%

        \[\leadsto \frac{\color{blue}{\left(0 - x\right) + y}}{y} \cdot t \]
      5. neg-sub083.9%

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

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{y} \cdot t \]
      7. sub-neg83.9%

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

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

    if 2.4e-152 < z < 3.99999999999999971e-104

    1. Initial program 73.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.6 \cdot 10^{+38}:\\ \;\;\;\;\frac{t}{\frac{z}{x - y}}\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-152}:\\ \;\;\;\;t \cdot \frac{y - x}{y}\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-104}:\\ \;\;\;\;\frac{t \cdot x}{z}\\ \mathbf{elif}\;z \leq 1.14 \cdot 10^{+61}:\\ \;\;\;\;t \cdot \frac{y - x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{\frac{z}{x - y}}\\ \end{array} \]

Alternative 4: 67.0% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+62}:\\
\;\;\;\;t\\

\mathbf{elif}\;y \leq 7 \cdot 10^{+45}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{t}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.7e62 or 7.00000000000000046e45 < y

    1. Initial program 99.8%

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

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

    if -2.7e62 < y < 7.00000000000000046e45

    1. Initial program 95.4%

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

      \[\leadsto \color{blue}{\frac{t \cdot \left(x - y\right)}{z}} \]
    3. Step-by-step derivation
      1. associate-/l*68.6%

        \[\leadsto \color{blue}{\frac{t}{\frac{z}{x - y}}} \]
      2. associate-/r/69.5%

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

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

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

Alternative 5: 60.3% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;y \leq 7 \cdot 10^{-34}:\\
\;\;\;\;x \cdot \frac{t}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.45e-20 or 7e-34 < y

    1. Initial program 99.8%

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

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

    if -1.45e-20 < y < 7e-34

    1. Initial program 94.0%

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

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

        \[\leadsto \color{blue}{\frac{t}{\frac{z}{x}}} \]
      2. associate-/r/69.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.45 \cdot 10^{-20}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 7 \cdot 10^{-34}:\\ \;\;\;\;x \cdot \frac{t}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]

Alternative 6: 96.9% accurate, 1.0× speedup?

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

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

    \[\frac{x - y}{z - y} \cdot t \]
  2. Final simplification97.2%

    \[\leadsto t \cdot \frac{x - y}{z - y} \]

Alternative 7: 35.8% 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 97.2%

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

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

    \[\leadsto t \]

Developer target: 96.9% 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 2023279 
(FPCore (x y z t)
  :name "Numeric.Signal.Multichannel:$cput from hsignal-0.2.7.1"
  :precision binary64

  :herbie-target
  (/ t (/ (- z y) (- x y)))

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