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

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

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 97.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: 97.5% accurate, 0.6× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.65e-116

    1. Initial program 97.6%

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

    if 1.65e-116 < x

    1. Initial program 94.6%

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

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

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

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{y}{z - t}}} + t \]
      4. un-div-inv99.8%

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

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

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

Alternative 2: 83.1% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t \leq -2.5 \cdot 10^{-33}:\\
\;\;\;\;t + x \cdot \frac{z}{y}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if t < -2.19999999999999999e91 or 4.4000000000000001e189 < t

    1. Initial program 99.9%

      \[\frac{x}{y} \cdot \left(z - t\right) + t \]
    2. Step-by-step derivation
      1. associate-*l/94.7%

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

        \[\leadsto \color{blue}{x \cdot \frac{z - t}{y}} + t \]
      3. fma-define81.9%

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

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

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

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

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

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

        \[\leadsto t \cdot 1 + \color{blue}{t \cdot \left(-\frac{x}{y}\right)} \]
      5. mul-1-neg94.8%

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

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

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

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

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

    if -2.19999999999999999e91 < t < -2.50000000000000014e-33

    1. Initial program 99.9%

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

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

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

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

    if -2.50000000000000014e-33 < t < -5.19999999999999994e-56

    1. Initial program 88.3%

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

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

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

        \[\leadsto \frac{\color{blue}{-t \cdot x}}{y} + t \]
      3. *-commutative99.8%

        \[\leadsto \frac{-\color{blue}{x \cdot t}}{y} + t \]
      4. distribute-rgt-neg-out99.8%

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

        \[\leadsto \color{blue}{x \cdot \frac{-t}{y}} + t \]
      6. distribute-neg-frac99.6%

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

        \[\leadsto x \cdot \color{blue}{\frac{t}{-y}} + t \]
    5. Simplified99.6%

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

    if -5.19999999999999994e-56 < t < 4.4000000000000001e189

    1. Initial program 94.7%

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

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

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

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{y}{z - t}}} + t \]
      4. un-div-inv94.0%

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{y}{z}}} + t \]
    6. Step-by-step derivation
      1. associate-/r/85.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -2.2 \cdot 10^{+91}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{elif}\;t \leq -2.5 \cdot 10^{-33}:\\ \;\;\;\;t + x \cdot \frac{z}{y}\\ \mathbf{elif}\;t \leq -5.2 \cdot 10^{-56}:\\ \;\;\;\;t - x \cdot \frac{t}{y}\\ \mathbf{elif}\;t \leq 4.4 \cdot 10^{+189}:\\ \;\;\;\;t + \frac{x}{y} \cdot z\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 83.0% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t \leq -2.5 \cdot 10^{-33}:\\
\;\;\;\;t + x \cdot \frac{z}{y}\\

\mathbf{elif}\;t \leq -6.2 \cdot 10^{-58}:\\
\;\;\;\;t - x \cdot \frac{t}{y}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if t < -2.29999999999999991e91

    1. Initial program 99.9%

      \[\frac{x}{y} \cdot \left(z - t\right) + t \]
    2. Step-by-step derivation
      1. associate-*l/93.1%

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

        \[\leadsto \color{blue}{x \cdot \frac{z - t}{y}} + t \]
      3. fma-define86.7%

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

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

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

        \[\leadsto t + \color{blue}{\left(-\frac{t \cdot x}{y}\right)} \]
      2. *-rgt-identity86.8%

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

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

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

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

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

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

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

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

    if -2.29999999999999991e91 < t < -2.50000000000000014e-33

    1. Initial program 99.9%

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

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

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

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

    if -2.50000000000000014e-33 < t < -6.1999999999999998e-58

    1. Initial program 88.3%

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

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

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

        \[\leadsto \frac{\color{blue}{-t \cdot x}}{y} + t \]
      3. *-commutative99.8%

        \[\leadsto \frac{-\color{blue}{x \cdot t}}{y} + t \]
      4. distribute-rgt-neg-out99.8%

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

        \[\leadsto \color{blue}{x \cdot \frac{-t}{y}} + t \]
      6. distribute-neg-frac99.6%

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

        \[\leadsto x \cdot \color{blue}{\frac{t}{-y}} + t \]
    5. Simplified99.6%

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

    if -6.1999999999999998e-58 < t < 1.74999999999999998e189

    1. Initial program 94.7%

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

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

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

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{y}{z - t}}} + t \]
      4. un-div-inv94.0%

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{y}{z}}} + t \]
    6. Step-by-step derivation
      1. associate-/r/85.2%

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

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

    if 1.74999999999999998e189 < t

    1. Initial program 99.9%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -2.3 \cdot 10^{+91}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{elif}\;t \leq -2.5 \cdot 10^{-33}:\\ \;\;\;\;t + x \cdot \frac{z}{y}\\ \mathbf{elif}\;t \leq -6.2 \cdot 10^{-58}:\\ \;\;\;\;t - x \cdot \frac{t}{y}\\ \mathbf{elif}\;t \leq 1.75 \cdot 10^{+189}:\\ \;\;\;\;t + \frac{x}{y} \cdot z\\ \mathbf{else}:\\ \;\;\;\;t - \frac{x}{y} \cdot t\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 83.0% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t \leq -2.5 \cdot 10^{-33}:\\
\;\;\;\;t + x \cdot \frac{z}{y}\\

\mathbf{elif}\;t \leq -6.2 \cdot 10^{-58}:\\
\;\;\;\;t - \frac{x \cdot t}{y}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if t < -1.7000000000000001e89

    1. Initial program 99.9%

      \[\frac{x}{y} \cdot \left(z - t\right) + t \]
    2. Step-by-step derivation
      1. associate-*l/93.1%

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

        \[\leadsto \color{blue}{x \cdot \frac{z - t}{y}} + t \]
      3. fma-define86.7%

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

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

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

        \[\leadsto t + \color{blue}{\left(-\frac{t \cdot x}{y}\right)} \]
      2. *-rgt-identity86.8%

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

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

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

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

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

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

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

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

    if -1.7000000000000001e89 < t < -2.50000000000000014e-33

    1. Initial program 99.9%

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

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

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

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

    if -2.50000000000000014e-33 < t < -6.1999999999999998e-58

    1. Initial program 88.3%

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

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

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

        \[\leadsto \frac{\color{blue}{-t \cdot x}}{y} + t \]
      3. *-commutative99.8%

        \[\leadsto \frac{-\color{blue}{x \cdot t}}{y} + t \]
      4. distribute-rgt-neg-out99.8%

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

        \[\leadsto \color{blue}{x \cdot \frac{-t}{y}} + t \]
      6. distribute-neg-frac99.6%

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

        \[\leadsto x \cdot \color{blue}{\frac{t}{-y}} + t \]
    5. Simplified99.6%

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

        \[\leadsto \color{blue}{\frac{t}{-y} \cdot x} + t \]
      2. distribute-frac-neg299.6%

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

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

        \[\leadsto \color{blue}{\frac{\left(-t\right) \cdot x}{y}} + t \]
    7. Applied egg-rr99.8%

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

    if -6.1999999999999998e-58 < t < 1.74999999999999998e189

    1. Initial program 94.7%

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

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

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

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{y}{z - t}}} + t \]
      4. un-div-inv94.0%

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{y}{z}}} + t \]
    6. Step-by-step derivation
      1. associate-/r/85.2%

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

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

    if 1.74999999999999998e189 < t

    1. Initial program 99.9%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.7 \cdot 10^{+89}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{elif}\;t \leq -2.5 \cdot 10^{-33}:\\ \;\;\;\;t + x \cdot \frac{z}{y}\\ \mathbf{elif}\;t \leq -6.2 \cdot 10^{-58}:\\ \;\;\;\;t - \frac{x \cdot t}{y}\\ \mathbf{elif}\;t \leq 1.75 \cdot 10^{+189}:\\ \;\;\;\;t + \frac{x}{y} \cdot z\\ \mathbf{else}:\\ \;\;\;\;t - \frac{x}{y} \cdot t\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 82.8% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.6 \cdot 10^{+88} \lor \neg \left(t \leq 1.02 \cdot 10^{-61}\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -4.6000000000000003e88 or 1.02e-61 < t

    1. Initial program 98.3%

      \[\frac{x}{y} \cdot \left(z - t\right) + t \]
    2. Step-by-step derivation
      1. associate-*l/94.3%

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

        \[\leadsto \color{blue}{x \cdot \frac{z - t}{y}} + t \]
      3. fma-define87.1%

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.6000000000000003e88 < t < 1.02e-61

    1. Initial program 95.0%

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

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

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

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

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

Alternative 6: 84.1% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.8 \cdot 10^{+90} \lor \neg \left(t \leq 1.75 \cdot 10^{+189}\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -3.8000000000000001e90 or 1.74999999999999998e189 < t

    1. Initial program 99.9%

      \[\frac{x}{y} \cdot \left(z - t\right) + t \]
    2. Step-by-step derivation
      1. associate-*l/94.7%

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

        \[\leadsto \color{blue}{x \cdot \frac{z - t}{y}} + t \]
      3. fma-define81.9%

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

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

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

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

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

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

        \[\leadsto t \cdot 1 + \color{blue}{t \cdot \left(-\frac{x}{y}\right)} \]
      5. mul-1-neg94.8%

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

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

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

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

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

    if -3.8000000000000001e90 < t < 1.74999999999999998e189

    1. Initial program 95.2%

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

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

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

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{y}{z - t}}} + t \]
      4. un-div-inv94.7%

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{y}{z}}} + t \]
    6. Step-by-step derivation
      1. associate-/r/85.0%

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

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

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

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

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

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

Alternative 8: 65.2% accurate, 1.3× speedup?

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

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

    \[\frac{x}{y} \cdot \left(z - t\right) + t \]
  2. Step-by-step derivation
    1. associate-*l/92.5%

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

      \[\leadsto \color{blue}{x \cdot \frac{z - t}{y}} + t \]
    3. fma-define90.6%

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

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

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

      \[\leadsto t + \color{blue}{\left(-\frac{t \cdot x}{y}\right)} \]
    2. *-rgt-identity62.3%

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

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

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

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

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

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

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

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

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

Alternative 9: 38.0% accurate, 9.0× speedup?

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

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

    \[\frac{x}{y} \cdot \left(z - t\right) + t \]
  2. Step-by-step derivation
    1. associate-*l/92.5%

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

      \[\leadsto \color{blue}{x \cdot \frac{z - t}{y}} + t \]
    3. fma-define90.6%

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

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

    \[\leadsto \color{blue}{t} \]
  6. Final simplification38.2%

    \[\leadsto t \]
  7. Add Preprocessing

Developer target: 97.7% accurate, 0.5× speedup?

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

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

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

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


\end{array}
\end{array}

Reproduce

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

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

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