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

Percentage Accurate: 98.0% → 98.0%
Time: 10.5s
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: 98.0% 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: 98.0% accurate, 0.8× speedup?

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{z - t}{\frac{y}{x}}} + t \]
    4. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{z - t}{\frac{y}{x}}} + t \]
    5. --lowering--.f64N/A

      \[\leadsto \frac{\color{blue}{z - t}}{\frac{y}{x}} + t \]
    6. /-lowering-/.f6497.3

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

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

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

Alternative 2: 94.9% accurate, 0.4× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 x y) < -2e14 or 2e6 < (/.f64 x y)

    1. Initial program 96.0%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, z - t, t\right)} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{x}{y}}, z - t, t\right) \]
      3. --lowering--.f6496.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, z - t, t\right)} \]
    5. Taylor expanded in x around inf

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

        \[\leadsto x \cdot \color{blue}{\frac{z - t}{y}} \]
      2. sub-negN/A

        \[\leadsto x \cdot \frac{\color{blue}{z + \left(\mathsf{neg}\left(t\right)\right)}}{y} \]
      3. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{z - t}{y} \cdot x} \]
      4. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{z - t}{y}} \cdot x \]
      5. --lowering--.f6494.7

        \[\leadsto \frac{\color{blue}{z - t}}{y} \cdot x \]
    9. Applied egg-rr94.7%

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

    if -2e14 < (/.f64 x y) < 2e6

    1. Initial program 97.8%

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, z, t\right)} \]
        2. /-lowering-/.f6494.6

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

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

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

    Alternative 3: 64.9% accurate, 0.5× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_1 := z \cdot \frac{x}{y}\\ \mathbf{if}\;\frac{x}{y} \leq -4 \cdot 10^{-68}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\frac{x}{y} \leq 4 \cdot 10^{-42}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
    (FPCore (x y z t)
     :precision binary64
     (let* ((t_1 (* z (/ x y))))
       (if (<= (/ x y) -4e-68) t_1 (if (<= (/ x y) 4e-42) t t_1))))
    double code(double x, double y, double z, double t) {
    	double t_1 = z * (x / y);
    	double tmp;
    	if ((x / y) <= -4e-68) {
    		tmp = t_1;
    	} else if ((x / y) <= 4e-42) {
    		tmp = 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 = z * (x / y)
        if ((x / y) <= (-4d-68)) then
            tmp = t_1
        else if ((x / y) <= 4d-42) then
            tmp = 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 = z * (x / y);
    	double tmp;
    	if ((x / y) <= -4e-68) {
    		tmp = t_1;
    	} else if ((x / y) <= 4e-42) {
    		tmp = t;
    	} else {
    		tmp = t_1;
    	}
    	return tmp;
    }
    
    def code(x, y, z, t):
    	t_1 = z * (x / y)
    	tmp = 0
    	if (x / y) <= -4e-68:
    		tmp = t_1
    	elif (x / y) <= 4e-42:
    		tmp = t
    	else:
    		tmp = t_1
    	return tmp
    
    function code(x, y, z, t)
    	t_1 = Float64(z * Float64(x / y))
    	tmp = 0.0
    	if (Float64(x / y) <= -4e-68)
    		tmp = t_1;
    	elseif (Float64(x / y) <= 4e-42)
    		tmp = t;
    	else
    		tmp = t_1;
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y, z, t)
    	t_1 = z * (x / y);
    	tmp = 0.0;
    	if ((x / y) <= -4e-68)
    		tmp = t_1;
    	elseif ((x / y) <= 4e-42)
    		tmp = t;
    	else
    		tmp = t_1;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x / y), $MachinePrecision], -4e-68], t$95$1, If[LessEqual[N[(x / y), $MachinePrecision], 4e-42], t, t$95$1]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_1 := z \cdot \frac{x}{y}\\
    \mathbf{if}\;\frac{x}{y} \leq -4 \cdot 10^{-68}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;\frac{x}{y} \leq 4 \cdot 10^{-42}:\\
    \;\;\;\;t\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (/.f64 x y) < -4.00000000000000027e-68 or 4.00000000000000015e-42 < (/.f64 x y)

      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}} \]
      4. Step-by-step derivation
        1. +-rgt-identityN/A

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

          \[\leadsto \color{blue}{x \cdot \frac{z}{y}} + 0 \]
        3. accelerator-lowering-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, 0\right)} \]
        4. /-lowering-/.f6448.4

          \[\leadsto \mathsf{fma}\left(x, \color{blue}{\frac{z}{y}}, 0\right) \]
      5. Simplified48.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, 0\right)} \]
      6. Step-by-step derivation
        1. +-rgt-identityN/A

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

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

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

          \[\leadsto \color{blue}{z \cdot \frac{x}{y}} \]
        5. *-lowering-*.f64N/A

          \[\leadsto \color{blue}{z \cdot \frac{x}{y}} \]
        6. /-lowering-/.f6450.6

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

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

      if -4.00000000000000027e-68 < (/.f64 x y) < 4.00000000000000015e-42

      1. Initial program 97.3%

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

        \[\leadsto \color{blue}{t} \]
      4. Step-by-step derivation
        1. Simplified81.5%

          \[\leadsto \color{blue}{t} \]
      5. Recombined 2 regimes into one program.
      6. Add Preprocessing

      Alternative 4: 42.1% accurate, 0.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -2 \cdot 10^{+78}:\\ \;\;\;\;y \cdot \frac{t}{y}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \end{array} \]
      (FPCore (x y z t) :precision binary64 (if (<= (/ x y) -2e+78) (* y (/ t y)) t))
      double code(double x, double y, double z, double t) {
      	double tmp;
      	if ((x / y) <= -2e+78) {
      		tmp = y * (t / y);
      	} else {
      		tmp = t;
      	}
      	return tmp;
      }
      
      real(8) function code(x, y, z, t)
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8), intent (in) :: z
          real(8), intent (in) :: t
          real(8) :: tmp
          if ((x / y) <= (-2d+78)) then
              tmp = y * (t / y)
          else
              tmp = t
          end if
          code = tmp
      end function
      
      public static double code(double x, double y, double z, double t) {
      	double tmp;
      	if ((x / y) <= -2e+78) {
      		tmp = y * (t / y);
      	} else {
      		tmp = t;
      	}
      	return tmp;
      }
      
      def code(x, y, z, t):
      	tmp = 0
      	if (x / y) <= -2e+78:
      		tmp = y * (t / y)
      	else:
      		tmp = t
      	return tmp
      
      function code(x, y, z, t)
      	tmp = 0.0
      	if (Float64(x / y) <= -2e+78)
      		tmp = Float64(y * Float64(t / y));
      	else
      		tmp = t;
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z, t)
      	tmp = 0.0;
      	if ((x / y) <= -2e+78)
      		tmp = y * (t / y);
      	else
      		tmp = t;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -2e+78], N[(y * N[(t / y), $MachinePrecision]), $MachinePrecision], t]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;\frac{x}{y} \leq -2 \cdot 10^{+78}:\\
      \;\;\;\;y \cdot \frac{t}{y}\\
      
      \mathbf{else}:\\
      \;\;\;\;t\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (/.f64 x y) < -2.00000000000000002e78

        1. Initial program 96.7%

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{\left(t \cdot y + t \cdot \color{blue}{\left(-1 \cdot x\right)}\right) + x \cdot z}{y} \]
          11. distribute-lft-outN/A

            \[\leadsto \frac{\color{blue}{t \cdot \left(y + -1 \cdot x\right)} + x \cdot z}{y} \]
          12. accelerator-lowering-fma.f64N/A

            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(t, y + -1 \cdot x, x \cdot z\right)}}{y} \]
          13. mul-1-negN/A

            \[\leadsto \frac{\mathsf{fma}\left(t, y + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}, x \cdot z\right)}{y} \]
          14. unsub-negN/A

            \[\leadsto \frac{\mathsf{fma}\left(t, \color{blue}{y - x}, x \cdot z\right)}{y} \]
          15. --lowering--.f64N/A

            \[\leadsto \frac{\mathsf{fma}\left(t, \color{blue}{y - x}, x \cdot z\right)}{y} \]
          16. +-rgt-identityN/A

            \[\leadsto \frac{\mathsf{fma}\left(t, y - x, \color{blue}{x \cdot z + 0}\right)}{y} \]
          17. accelerator-lowering-fma.f6492.0

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

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

          \[\leadsto \frac{\color{blue}{t \cdot y}}{y} \]
        7. Step-by-step derivation
          1. +-rgt-identityN/A

            \[\leadsto \frac{\color{blue}{t \cdot y + 0}}{y} \]
          2. accelerator-lowering-fma.f645.5

            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(t, y, 0\right)}}{y} \]
        8. Simplified5.5%

          \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(t, y, 0\right)}}{y} \]
        9. Step-by-step derivation
          1. +-rgt-identityN/A

            \[\leadsto \frac{\color{blue}{t \cdot y}}{y} \]
          2. *-commutativeN/A

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

            \[\leadsto \color{blue}{y \cdot \frac{t}{y}} \]
          4. *-lowering-*.f64N/A

            \[\leadsto \color{blue}{y \cdot \frac{t}{y}} \]
          5. /-lowering-/.f6423.5

            \[\leadsto y \cdot \color{blue}{\frac{t}{y}} \]
        10. Applied egg-rr23.5%

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

        if -2.00000000000000002e78 < (/.f64 x y)

        1. Initial program 97.0%

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

          \[\leadsto \color{blue}{t} \]
        4. Step-by-step derivation
          1. Simplified48.5%

            \[\leadsto \color{blue}{t} \]
        5. Recombined 2 regimes into one program.
        6. Add Preprocessing

        Alternative 5: 85.8% accurate, 0.7× speedup?

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

          1. Initial program 97.6%

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

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

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, z, t\right)} \]
              2. /-lowering-/.f6485.5

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

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

            if -5.5999999999999998e-32 < z < 6.2e52

            1. Initial program 96.3%

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, z - t, t\right)} \]
              2. /-lowering-/.f64N/A

                \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{x}{y}}, z - t, t\right) \]
              3. --lowering--.f6496.4

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

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

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

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

                \[\leadsto \color{blue}{t - \frac{t \cdot x}{y}} \]
              3. *-rgt-identityN/A

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

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

                \[\leadsto \color{blue}{t \cdot \left(1 - \frac{x}{y}\right)} \]
              6. *-inversesN/A

                \[\leadsto t \cdot \left(\color{blue}{\frac{y}{y}} - \frac{x}{y}\right) \]
              7. div-subN/A

                \[\leadsto t \cdot \color{blue}{\frac{y - x}{y}} \]
              8. *-lowering-*.f64N/A

                \[\leadsto \color{blue}{t \cdot \frac{y - x}{y}} \]
              9. div-subN/A

                \[\leadsto t \cdot \color{blue}{\left(\frac{y}{y} - \frac{x}{y}\right)} \]
              10. *-inversesN/A

                \[\leadsto t \cdot \left(\color{blue}{1} - \frac{x}{y}\right) \]
              11. --lowering--.f64N/A

                \[\leadsto t \cdot \color{blue}{\left(1 - \frac{x}{y}\right)} \]
              12. /-lowering-/.f6485.4

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

              \[\leadsto \color{blue}{t \cdot \left(1 - \frac{x}{y}\right)} \]
          5. Recombined 2 regimes into one program.
          6. Add Preprocessing

          Alternative 6: 98.0% 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.9%

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, z - t, t\right)} \]
            2. /-lowering-/.f64N/A

              \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{x}{y}}, z - t, t\right) \]
            3. --lowering--.f6496.9

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

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

          Alternative 7: 77.0% accurate, 1.3× speedup?

          \[\begin{array}{l} \\ \mathsf{fma}\left(\frac{x}{y}, z, t\right) \end{array} \]
          (FPCore (x y z t) :precision binary64 (fma (/ x y) z t))
          double code(double x, double y, double z, double t) {
          	return fma((x / y), z, t);
          }
          
          function code(x, y, z, t)
          	return fma(Float64(x / y), z, t)
          end
          
          code[x_, y_, z_, t_] := N[(N[(x / y), $MachinePrecision] * z + t), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          \mathsf{fma}\left(\frac{x}{y}, z, t\right)
          \end{array}
          
          Derivation
          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 \frac{x}{y} \cdot \color{blue}{z} + t \]
          4. Step-by-step derivation
            1. Simplified72.1%

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, z, t\right)} \]
              2. /-lowering-/.f6472.1

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

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

            Alternative 8: 38.6% accurate, 23.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 96.9%

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

              \[\leadsto \color{blue}{t} \]
            4. Step-by-step derivation
              1. Simplified37.7%

                \[\leadsto \color{blue}{t} \]
              2. Add Preprocessing

              Developer Target 1: 97.7% 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 2024196 
              (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))