Numeric.Histogram:binBounds from Chart-1.5.3

Percentage Accurate: 92.7% → 98.6%
Time: 7.1s
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.7% 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: 98.6% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
t_1 := \left(y - x\right) \cdot z\\
t_2 := x + \frac{t\_1}{t}\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+216}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\\

\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+302}:\\
\;\;\;\;x + t\_1 \cdot \frac{1}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < -2e216

    1. Initial program 87.1%

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

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

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

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

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

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

    if -2e216 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < 5e302

    1. Initial program 99.2%

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

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

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

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

    if 5e302 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t))

    1. Initial program 84.6%

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

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

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

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

Alternative 2: 85.7% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.3 \cdot 10^{-39} \lor \neg \left(y \leq 1.32 \cdot 10^{+60}\right):\\
\;\;\;\;x + y \cdot \frac{z}{t}\\

\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.2999999999999999e-39 or 1.32e60 < y

    1. Initial program 90.6%

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

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

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

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

    if -4.2999999999999999e-39 < y < 1.32e60

    1. Initial program 97.1%

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

      \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \frac{z}{t}\right)} \]
    4. Step-by-step derivation
      1. mul-1-neg88.6%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(-\frac{z}{t}\right)}\right) \]
      2. unsub-neg88.6%

        \[\leadsto x \cdot \color{blue}{\left(1 - \frac{z}{t}\right)} \]
    5. Simplified88.6%

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

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

Alternative 3: 84.2% accurate, 0.5× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.4999999999999999e-37

    1. Initial program 95.1%

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

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

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

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

    if -2.4999999999999999e-37 < y < 2.4e60

    1. Initial program 97.1%

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

      \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \frac{z}{t}\right)} \]
    4. Step-by-step derivation
      1. mul-1-neg88.6%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(-\frac{z}{t}\right)}\right) \]
      2. unsub-neg88.6%

        \[\leadsto x \cdot \color{blue}{\left(1 - \frac{z}{t}\right)} \]
    5. Simplified88.6%

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

    if 2.4e60 < y

    1. Initial program 82.8%

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

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

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

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

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

Alternative 4: 84.4% accurate, 0.5× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -5.30000000000000003e-39

    1. Initial program 95.1%

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

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

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

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

    if -5.30000000000000003e-39 < y < 1.4e60

    1. Initial program 97.1%

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

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

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

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

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

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

        \[\leadsto x + \left(-\color{blue}{\frac{x}{\frac{t}{z}}}\right) \]
      3. distribute-neg-frac88.6%

        \[\leadsto x + \color{blue}{\frac{-x}{\frac{t}{z}}} \]
    7. Simplified88.6%

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

    if 1.4e60 < y

    1. Initial program 82.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.3 \cdot 10^{-39}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{+60}:\\ \;\;\;\;x - \frac{x}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 93.4% accurate, 0.6× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -9.4999999999999997e193

    1. Initial program 74.8%

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

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

    if -9.4999999999999997e193 < z

    1. Initial program 96.5%

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

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

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

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

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

    \[\leadsto \color{blue}{x + \frac{y - x}{\frac{t}{z}}} \]
  4. Add Preprocessing
  5. Final simplification96.7%

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

Alternative 7: 65.3% accurate, 1.3× speedup?

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

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

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

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

      \[\leadsto x \cdot \left(1 + \color{blue}{\left(-\frac{z}{t}\right)}\right) \]
    2. unsub-neg65.3%

      \[\leadsto x \cdot \color{blue}{\left(1 - \frac{z}{t}\right)} \]
  5. Simplified65.3%

    \[\leadsto \color{blue}{x \cdot \left(1 - \frac{z}{t}\right)} \]
  6. Final simplification65.3%

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

Alternative 8: 38.1% 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 94.0%

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

    \[\leadsto \color{blue}{x} \]
  4. Final simplification39.1%

    \[\leadsto x \]
  5. Add Preprocessing

Developer target: 97.6% accurate, 0.5× 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 2024040 
(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)))