Numeric.Histogram:binBounds from Chart-1.5.3

Percentage Accurate: 92.8% → 97.8%
Time: 7.7s
Alternatives: 8
Speedup: 1.0×

Specification

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

\\
x + \frac{\left(y - x\right) \cdot z}{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: 92.8% accurate, 1.0× speedup?

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

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

Alternative 1: 97.8% accurate, 0.1× speedup?

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

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

    \[x + \frac{\left(y - x\right) \cdot z}{t} \]
  2. Step-by-step derivation
    1. +-commutative92.4%

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

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

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

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

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

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

Alternative 2: 94.3% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.1 \cdot 10^{+218}:\\
\;\;\;\;x + \frac{z}{t} \cdot y\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < -3.1000000000000002e218

    1. Initial program 77.0%

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

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

        \[\leadsto x + \color{blue}{y \cdot \frac{z}{t}} \]
    4. Simplified100.0%

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

    if -3.1000000000000002e218 < t < 1.30000000000000005e56

    1. Initial program 97.4%

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

    if 1.30000000000000005e56 < t

    1. Initial program 79.1%

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

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

        \[\leadsto x + \color{blue}{y \cdot \frac{z}{t}} \]
    4. Simplified89.9%

      \[\leadsto x + \color{blue}{y \cdot \frac{z}{t}} \]
    5. Taylor expanded in y around 0 83.1%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -3.1 \cdot 10^{+218}:\\ \;\;\;\;x + \frac{z}{t} \cdot y\\ \mathbf{elif}\;t \leq 1.3 \cdot 10^{+56}:\\ \;\;\;\;x + \frac{z \cdot \left(y - x\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z}{\frac{t}{y}}\\ \end{array} \]

Alternative 3: 85.6% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.64999999999999995e-115 or 2.75000000000000003e-73 < y

    1. Initial program 90.9%

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

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

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

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

    if -1.64999999999999995e-115 < y < 2.75000000000000003e-73

    1. Initial program 95.4%

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

      \[\leadsto \color{blue}{\left(1 + -1 \cdot \frac{z}{t}\right) \cdot x} \]
    3. Step-by-step derivation
      1. *-commutative90.0%

        \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \frac{z}{t}\right)} \]
      2. distribute-rgt-in90.0%

        \[\leadsto \color{blue}{1 \cdot x + \left(-1 \cdot \frac{z}{t}\right) \cdot x} \]
      3. *-lft-identity90.0%

        \[\leadsto \color{blue}{x} + \left(-1 \cdot \frac{z}{t}\right) \cdot x \]
      4. mul-1-neg90.0%

        \[\leadsto x + \color{blue}{\left(-\frac{z}{t}\right)} \cdot x \]
      5. cancel-sign-sub-inv90.0%

        \[\leadsto \color{blue}{x - \frac{z}{t} \cdot x} \]
      6. *-commutative90.0%

        \[\leadsto x - \color{blue}{x \cdot \frac{z}{t}} \]
    4. Simplified90.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.65 \cdot 10^{-115} \lor \neg \left(y \leq 2.75 \cdot 10^{-73}\right):\\ \;\;\;\;x + \frac{z}{t} \cdot y\\ \mathbf{else}:\\ \;\;\;\;x - \frac{z}{t} \cdot x\\ \end{array} \]

Alternative 4: 55.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -8000000 \lor \neg \left(z \leq 4.7 \cdot 10^{-57}\right):\\
\;\;\;\;z \cdot \frac{y}{t}\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -8e6 or 4.6999999999999998e-57 < z

    1. Initial program 86.4%

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

        \[\leadsto x + \color{blue}{\frac{y - x}{\frac{t}{z}}} \]
      2. div-sub88.0%

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

        \[\leadsto \color{blue}{\left(x + \frac{y}{\frac{t}{z}}\right) - \frac{x}{\frac{t}{z}}} \]
      4. div-inv88.0%

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

        \[\leadsto \left(x + y \cdot \color{blue}{\frac{z}{t}}\right) - \frac{x}{\frac{t}{z}} \]
      6. div-inv88.0%

        \[\leadsto \left(x + y \cdot \frac{z}{t}\right) - \color{blue}{x \cdot \frac{1}{\frac{t}{z}}} \]
      7. clear-num88.0%

        \[\leadsto \left(x + y \cdot \frac{z}{t}\right) - x \cdot \color{blue}{\frac{z}{t}} \]
    3. Applied egg-rr88.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{z}{\frac{t}{y}}} \]
      2. clear-num52.8%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{t}{y}}{z}}} \]
      3. associate-/r/52.8%

        \[\leadsto \color{blue}{\frac{1}{\frac{t}{y}} \cdot z} \]
      4. clear-num53.1%

        \[\leadsto \color{blue}{\frac{y}{t}} \cdot z \]
    9. Applied egg-rr53.1%

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

    if -8e6 < z < 4.6999999999999998e-57

    1. Initial program 98.4%

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

      \[\leadsto \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification58.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -8000000 \lor \neg \left(z \leq 4.7 \cdot 10^{-57}\right):\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 5: 53.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.2 \cdot 10^{+37} \lor \neg \left(y \leq 3.2 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{z}{t} \cdot y\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.2000000000000001e37 or 3.20000000000000012e-9 < y

    1. Initial program 91.6%

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

        \[\leadsto x + \color{blue}{\frac{y - x}{\frac{t}{z}}} \]
      2. div-sub93.5%

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

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

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

        \[\leadsto \left(x + y \cdot \color{blue}{\frac{z}{t}}\right) - \frac{x}{\frac{t}{z}} \]
      6. div-inv93.8%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{z \cdot y}}{t} \]
    7. Simplified58.7%

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

        \[\leadsto \color{blue}{\frac{z}{t} \cdot y} \]
    9. Applied egg-rr64.1%

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

    if -2.2000000000000001e37 < y < 3.20000000000000012e-9

    1. Initial program 93.2%

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

      \[\leadsto \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification59.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.2 \cdot 10^{+37} \lor \neg \left(y \leq 3.2 \cdot 10^{-9}\right):\\ \;\;\;\;\frac{z}{t} \cdot y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 6: 97.8% accurate, 1.0× speedup?

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

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

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

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

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

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

Alternative 7: 76.9% accurate, 1.3× speedup?

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

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

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

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

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

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

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

Alternative 8: 39.6% accurate, 9.0× speedup?

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

\\
x
\end{array}
Derivation
  1. Initial program 92.4%

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

    \[\leadsto \color{blue}{x} \]
  3. Final simplification42.7%

    \[\leadsto x \]

Developer target: 97.8% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x < -9.025511195533005 \cdot 10^{-135}:\\
\;\;\;\;x - \frac{z}{t} \cdot \left(x - y\right)\\

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

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023228 
(FPCore (x y z t)
  :name "Numeric.Histogram:binBounds from Chart-1.5.3"
  :precision binary64

  :herbie-target
  (if (< x -9.025511195533005e-135) (- x (* (/ z t) (- x y))) (if (< x 4.275032163700715e-250) (+ x (* (/ (- y x) t) z)) (+ x (/ (- y x) (/ t z)))))

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