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

Percentage Accurate: 97.7% → 94.4%
Time: 6.6s
Alternatives: 8
Speedup: 1.1×

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 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.7% 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: 94.4% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_1 := \frac{x}{y} \cdot \left(z - t\right)\\
\mathbf{if}\;\frac{x}{y} \leq -5 \cdot 10^{-30}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;\frac{x}{y} \leq 50:\\
\;\;\;\;t + \frac{x \cdot z}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 x y) < -4.99999999999999972e-30 or 50 < (/.f64 x y)

    1. Initial program 96.8%

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{z}{y} - \frac{t}{y}\right)} \]
    4. Step-by-step derivation
      1. div-subN/A

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

        \[\leadsto \color{blue}{\frac{x \cdot \left(z - t\right)}{y}} \]
      3. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot \left(z - t\right)}{y}} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot \left(z - t\right)}}{y} \]
      5. lower--.f6492.0

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(z - t\right)}{y}} \]
    6. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(z - t\right)} \]
      3. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{x}{y}} \cdot \left(z - t\right) \]
      4. lower-*.f6495.2

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

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

    if -4.99999999999999972e-30 < (/.f64 x y) < 50

    1. Initial program 96.3%

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

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + t \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + t \]
      2. lower-*.f6498.5

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

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

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

Alternative 2: 95.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{x}{y} \cdot \left(z - t\right)\\ \mathbf{if}\;\frac{x}{y} \leq -5 \cdot 10^{+31}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\frac{x}{y} \leq 5 \cdot 10^{-18}:\\ \;\;\;\;\mathsf{fma}\left(z, \frac{x}{y}, t\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* (/ x y) (- z t))))
   (if (<= (/ x y) -5e+31) t_1 (if (<= (/ x y) 5e-18) (fma z (/ x y) t) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = (x / y) * (z - t);
	double tmp;
	if ((x / y) <= -5e+31) {
		tmp = t_1;
	} else if ((x / y) <= 5e-18) {
		tmp = fma(z, (x / y), t);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t)
	t_1 = Float64(Float64(x / y) * Float64(z - t))
	tmp = 0.0
	if (Float64(x / y) <= -5e+31)
		tmp = t_1;
	elseif (Float64(x / y) <= 5e-18)
		tmp = fma(z, Float64(x / y), t);
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x / y), $MachinePrecision], -5e+31], t$95$1, If[LessEqual[N[(x / y), $MachinePrecision], 5e-18], N[(z * N[(x / y), $MachinePrecision] + t), $MachinePrecision], t$95$1]]]
\begin{array}{l}

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

\mathbf{elif}\;\frac{x}{y} \leq 5 \cdot 10^{-18}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{x}{y}, t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 x y) < -5.00000000000000027e31 or 5.00000000000000036e-18 < (/.f64 x y)

    1. Initial program 96.6%

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{z}{y} - \frac{t}{y}\right)} \]
    4. Step-by-step derivation
      1. div-subN/A

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

        \[\leadsto \color{blue}{\frac{x \cdot \left(z - t\right)}{y}} \]
      3. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot \left(z - t\right)}{y}} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot \left(z - t\right)}}{y} \]
      5. lower--.f6494.7

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(z - t\right)}{y}} \]
    6. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(z - t\right)} \]
      3. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{x}{y}} \cdot \left(z - t\right) \]
      4. lower-*.f6496.4

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

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

    if -5.00000000000000027e31 < (/.f64 x y) < 5.00000000000000036e-18

    1. Initial program 96.4%

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

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + t \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + t \]
      2. lower-*.f6496.8

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

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + t \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot z}}{y} + t \]
      2. div-invN/A

        \[\leadsto \color{blue}{\left(x \cdot z\right) \cdot \frac{1}{y}} + t \]
      3. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(x \cdot z\right)} \cdot \frac{1}{y} + t \]
      4. *-commutativeN/A

        \[\leadsto \color{blue}{\left(z \cdot x\right)} \cdot \frac{1}{y} + t \]
      5. associate-*l*N/A

        \[\leadsto \color{blue}{z \cdot \left(x \cdot \frac{1}{y}\right)} + t \]
      6. div-invN/A

        \[\leadsto z \cdot \color{blue}{\frac{x}{y}} + t \]
      7. lift-/.f64N/A

        \[\leadsto z \cdot \color{blue}{\frac{x}{y}} + t \]
      8. lower-fma.f6496.0

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, \frac{x}{y}, t\right)} \]
    7. Applied egg-rr96.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, \frac{x}{y}, t\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 76.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := -\frac{x}{y} \cdot t\\ \mathbf{if}\;\frac{x}{y} \leq -5 \cdot 10^{+60}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\frac{x}{y} \leq 10^{+26}:\\ \;\;\;\;\mathsf{fma}\left(z, \frac{x}{y}, t\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (* (/ x y) t))))
   (if (<= (/ x y) -5e+60) t_1 (if (<= (/ x y) 1e+26) (fma z (/ x y) t) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = -((x / y) * t);
	double tmp;
	if ((x / y) <= -5e+60) {
		tmp = t_1;
	} else if ((x / y) <= 1e+26) {
		tmp = fma(z, (x / y), t);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t)
	t_1 = Float64(-Float64(Float64(x / y) * t))
	tmp = 0.0
	if (Float64(x / y) <= -5e+60)
		tmp = t_1;
	elseif (Float64(x / y) <= 1e+26)
		tmp = fma(z, Float64(x / y), t);
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_] := Block[{t$95$1 = (-N[(N[(x / y), $MachinePrecision] * t), $MachinePrecision])}, If[LessEqual[N[(x / y), $MachinePrecision], -5e+60], t$95$1, If[LessEqual[N[(x / y), $MachinePrecision], 1e+26], N[(z * N[(x / y), $MachinePrecision] + t), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := -\frac{x}{y} \cdot t\\
\mathbf{if}\;\frac{x}{y} \leq -5 \cdot 10^{+60}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;\frac{x}{y} \leq 10^{+26}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{x}{y}, t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 x y) < -4.99999999999999975e60 or 1.00000000000000005e26 < (/.f64 x y)

    1. Initial program 96.3%

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{z}{y} - \frac{t}{y}\right)} \]
    4. Step-by-step derivation
      1. div-subN/A

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

        \[\leadsto \color{blue}{\frac{x \cdot \left(z - t\right)}{y}} \]
      3. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot \left(z - t\right)}{y}} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot \left(z - t\right)}}{y} \]
      5. lower--.f6497.0

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

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

      \[\leadsto \frac{x \cdot \color{blue}{\left(-1 \cdot t\right)}}{y} \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \frac{x \cdot \color{blue}{\left(\mathsf{neg}\left(t\right)\right)}}{y} \]
      2. lower-neg.f6465.4

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

      \[\leadsto \frac{x \cdot \color{blue}{\left(-t\right)}}{y} \]
    9. Step-by-step derivation
      1. distribute-rgt-neg-outN/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(x \cdot t\right)}}{y} \]
      2. distribute-lft-neg-inN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot t}}{y} \]
      3. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot t}{y} \]
      4. associate-*r/N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \frac{t}{y}} \]
      5. clear-numN/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\frac{1}{\frac{y}{t}}} \]
      6. associate-/r/N/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\left(\frac{1}{y} \cdot t\right)} \]
      7. lift-/.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \left(\color{blue}{\frac{1}{y}} \cdot t\right) \]
      8. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(x\right)\right) \cdot \frac{1}{y}\right) \cdot t} \]
      9. lift-/.f64N/A

        \[\leadsto \left(\left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\frac{1}{y}}\right) \cdot t \]
      10. div-invN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x\right)}{y}} \cdot t \]
      11. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x\right)}{y} \cdot t} \]
      12. lower-/.f6469.6

        \[\leadsto \color{blue}{\frac{-x}{y}} \cdot t \]
    10. Applied egg-rr69.6%

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

    if -4.99999999999999975e60 < (/.f64 x y) < 1.00000000000000005e26

    1. Initial program 96.7%

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

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + t \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + t \]
      2. lower-*.f6493.8

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

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + t \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot z}}{y} + t \]
      2. div-invN/A

        \[\leadsto \color{blue}{\left(x \cdot z\right) \cdot \frac{1}{y}} + t \]
      3. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(x \cdot z\right)} \cdot \frac{1}{y} + t \]
      4. *-commutativeN/A

        \[\leadsto \color{blue}{\left(z \cdot x\right)} \cdot \frac{1}{y} + t \]
      5. associate-*l*N/A

        \[\leadsto \color{blue}{z \cdot \left(x \cdot \frac{1}{y}\right)} + t \]
      6. div-invN/A

        \[\leadsto z \cdot \color{blue}{\frac{x}{y}} + t \]
      7. lift-/.f64N/A

        \[\leadsto z \cdot \color{blue}{\frac{x}{y}} + t \]
      8. lower-fma.f6494.4

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, \frac{x}{y}, t\right)} \]
    7. Applied egg-rr94.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, \frac{x}{y}, t\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification84.1%

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

Alternative 4: 74.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := -x \cdot \frac{t}{y}\\ \mathbf{if}\;\frac{x}{y} \leq -2 \cdot 10^{+95}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\frac{x}{y} \leq 10^{+29}:\\ \;\;\;\;\mathsf{fma}\left(z, \frac{x}{y}, t\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (* x (/ t y)))))
   (if (<= (/ x y) -2e+95) t_1 (if (<= (/ x y) 1e+29) (fma z (/ x y) t) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = -(x * (t / y));
	double tmp;
	if ((x / y) <= -2e+95) {
		tmp = t_1;
	} else if ((x / y) <= 1e+29) {
		tmp = fma(z, (x / y), t);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t)
	t_1 = Float64(-Float64(x * Float64(t / y)))
	tmp = 0.0
	if (Float64(x / y) <= -2e+95)
		tmp = t_1;
	elseif (Float64(x / y) <= 1e+29)
		tmp = fma(z, Float64(x / y), t);
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_] := Block[{t$95$1 = (-N[(x * N[(t / y), $MachinePrecision]), $MachinePrecision])}, If[LessEqual[N[(x / y), $MachinePrecision], -2e+95], t$95$1, If[LessEqual[N[(x / y), $MachinePrecision], 1e+29], N[(z * N[(x / y), $MachinePrecision] + t), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := -x \cdot \frac{t}{y}\\
\mathbf{if}\;\frac{x}{y} \leq -2 \cdot 10^{+95}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;\frac{x}{y} \leq 10^{+29}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{x}{y}, t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 x y) < -2.00000000000000004e95 or 9.99999999999999914e28 < (/.f64 x y)

    1. Initial program 96.0%

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{z}{y} - \frac{t}{y}\right)} \]
    4. Step-by-step derivation
      1. div-subN/A

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

        \[\leadsto \color{blue}{\frac{x \cdot \left(z - t\right)}{y}} \]
      3. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot \left(z - t\right)}{y}} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot \left(z - t\right)}}{y} \]
      5. lower--.f6496.7

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

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

      \[\leadsto \frac{x \cdot \color{blue}{\left(-1 \cdot t\right)}}{y} \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \frac{x \cdot \color{blue}{\left(\mathsf{neg}\left(t\right)\right)}}{y} \]
      2. lower-neg.f6465.8

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

      \[\leadsto \frac{x \cdot \color{blue}{\left(-t\right)}}{y} \]
    9. Step-by-step derivation
      1. lift-neg.f64N/A

        \[\leadsto \frac{x \cdot \color{blue}{\left(\mathsf{neg}\left(t\right)\right)}}{y} \]
      2. associate-/l*N/A

        \[\leadsto \color{blue}{x \cdot \frac{\mathsf{neg}\left(t\right)}{y}} \]
      3. *-commutativeN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t\right)}{y} \cdot x} \]
      4. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(t\right)}{y} \cdot x} \]
      5. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(t\right)\right)\right)}{\mathsf{neg}\left(y\right)}} \cdot x \]
      6. lift-neg.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(t\right)\right)}\right)}{\mathsf{neg}\left(y\right)} \cdot x \]
      7. remove-double-negN/A

        \[\leadsto \frac{\color{blue}{t}}{\mathsf{neg}\left(y\right)} \cdot x \]
      8. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{t}{\mathsf{neg}\left(y\right)}} \cdot x \]
      9. lower-neg.f6466.9

        \[\leadsto \frac{t}{\color{blue}{-y}} \cdot x \]
    10. Applied egg-rr66.9%

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

    if -2.00000000000000004e95 < (/.f64 x y) < 9.99999999999999914e28

    1. Initial program 96.9%

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

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + t \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + t \]
      2. lower-*.f6490.7

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

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + t \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot z}}{y} + t \]
      2. div-invN/A

        \[\leadsto \color{blue}{\left(x \cdot z\right) \cdot \frac{1}{y}} + t \]
      3. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(x \cdot z\right)} \cdot \frac{1}{y} + t \]
      4. *-commutativeN/A

        \[\leadsto \color{blue}{\left(z \cdot x\right)} \cdot \frac{1}{y} + t \]
      5. associate-*l*N/A

        \[\leadsto \color{blue}{z \cdot \left(x \cdot \frac{1}{y}\right)} + t \]
      6. div-invN/A

        \[\leadsto z \cdot \color{blue}{\frac{x}{y}} + t \]
      7. lift-/.f64N/A

        \[\leadsto z \cdot \color{blue}{\frac{x}{y}} + t \]
      8. lower-fma.f6491.2

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, \frac{x}{y}, t\right)} \]
    7. Applied egg-rr91.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, \frac{x}{y}, t\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification82.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -2 \cdot 10^{+95}:\\ \;\;\;\;-x \cdot \frac{t}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq 10^{+29}:\\ \;\;\;\;\mathsf{fma}\left(z, \frac{x}{y}, t\right)\\ \mathbf{else}:\\ \;\;\;\;-x \cdot \frac{t}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 97.7% 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 96.5%

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

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

Alternative 6: 97.7% accurate, 1.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 96.5%

    \[\frac{x}{y} \cdot \left(z - t\right) + t \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{x}{y}} \cdot \left(z - t\right) + t \]
    2. lift--.f64N/A

      \[\leadsto \frac{x}{y} \cdot \color{blue}{\left(z - t\right)} + t \]
    3. lower-fma.f6496.5

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, z - t, t\right)} \]
  4. Applied egg-rr96.5%

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

Alternative 7: 77.5% accurate, 1.3× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + t \]
  4. Step-by-step derivation
    1. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + t \]
    2. lower-*.f6472.8

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

    \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + t \]
  6. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{\color{blue}{x \cdot z}}{y} + t \]
    2. div-invN/A

      \[\leadsto \color{blue}{\left(x \cdot z\right) \cdot \frac{1}{y}} + t \]
    3. lift-*.f64N/A

      \[\leadsto \color{blue}{\left(x \cdot z\right)} \cdot \frac{1}{y} + t \]
    4. *-commutativeN/A

      \[\leadsto \color{blue}{\left(z \cdot x\right)} \cdot \frac{1}{y} + t \]
    5. associate-*l*N/A

      \[\leadsto \color{blue}{z \cdot \left(x \cdot \frac{1}{y}\right)} + t \]
    6. div-invN/A

      \[\leadsto z \cdot \color{blue}{\frac{x}{y}} + t \]
    7. lift-/.f64N/A

      \[\leadsto z \cdot \color{blue}{\frac{x}{y}} + t \]
    8. lower-fma.f6474.6

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, \frac{x}{y}, t\right)} \]
  7. Applied egg-rr74.6%

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

Alternative 8: 41.5% accurate, 1.4× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{x \cdot z}{y}} \]
  4. Step-by-step derivation
    1. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} \]
    2. lower-*.f6435.6

      \[\leadsto \frac{\color{blue}{x \cdot z}}{y} \]
  5. Simplified35.6%

    \[\leadsto \color{blue}{\frac{x \cdot z}{y}} \]
  6. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \frac{\color{blue}{z \cdot x}}{y} \]
    2. associate-/l*N/A

      \[\leadsto \color{blue}{z \cdot \frac{x}{y}} \]
    3. lift-/.f64N/A

      \[\leadsto z \cdot \color{blue}{\frac{x}{y}} \]
    4. lower-*.f6437.2

      \[\leadsto \color{blue}{z \cdot \frac{x}{y}} \]
  7. Applied egg-rr37.2%

    \[\leadsto \color{blue}{z \cdot \frac{x}{y}} \]
  8. Final simplification37.2%

    \[\leadsto \frac{x}{y} \cdot z \]
  9. Add Preprocessing

Developer Target 1: 97.4% accurate, 0.7× 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 2024207 
(FPCore (x y z t)
  :name "Numeric.Signal.Multichannel:$cget from hsignal-0.2.7.1"
  :precision binary64

  :alt
  (! :herbie-platform default (if (< z 689864138640673/250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (+ (* (/ x y) (- z t)) t) (if (< z 581748612718609/25000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (+ (* x (/ (- z t) y)) t) (+ (* (/ x y) (- z t)) t))))

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