Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, A

Percentage Accurate: 88.8% → 96.6%
Time: 9.8s
Alternatives: 10
Speedup: 0.7×

Specification

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

\\
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\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 10 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: 88.8% accurate, 1.0× speedup?

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

\\
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\end{array}

Alternative 1: 96.6% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
t_1 := y \cdot z - x\\
t_2 := z \cdot t - x\\
t_3 := \frac{x + \frac{t_1}{t_2}}{x + 1}\\
\mathbf{if}\;t_3 \leq -1 \cdot 10^{+25}:\\
\;\;\;\;\frac{y}{\frac{\left(x + 1\right) \cdot t_2}{z}}\\

\mathbf{elif}\;t_3 \leq 2 \cdot 10^{-27} \lor \neg \left(t_3 \leq 10^{+253}\right):\\
\;\;\;\;\left(\frac{y}{t \cdot \left(x + 1\right)} + \frac{x}{x + 1}\right) - \frac{x}{\left(x + 1\right) \cdot \left(z \cdot t\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + \frac{1}{\frac{t_2}{t_1}}}{x + 1}\\


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

    1. Initial program 82.0%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Step-by-step derivation
      1. *-commutative82.0%

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

      \[\leadsto \color{blue}{\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}} \]
    4. Taylor expanded in y around inf 82.1%

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

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

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

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

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

    if -1.00000000000000009e25 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 2.0000000000000001e-27 or 9.9999999999999994e252 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1))

    1. Initial program 65.9%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Step-by-step derivation
      1. *-commutative65.9%

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

      \[\leadsto \color{blue}{\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}} \]
    4. Taylor expanded in t around inf 92.1%

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

    if 2.0000000000000001e-27 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 9.9999999999999994e252

    1. Initial program 99.9%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Step-by-step derivation
      1. *-commutative99.9%

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

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

        \[\leadsto \frac{x + \color{blue}{\frac{1}{\frac{z \cdot t - x}{y \cdot z - x}}}}{x + 1} \]
      2. inv-pow99.9%

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

      \[\leadsto \frac{x + \color{blue}{{\left(\frac{z \cdot t - x}{y \cdot z - x}\right)}^{-1}}}{x + 1} \]
    6. Step-by-step derivation
      1. unpow-199.9%

        \[\leadsto \frac{x + \color{blue}{\frac{1}{\frac{z \cdot t - x}{y \cdot z - x}}}}{x + 1} \]
      2. *-commutative99.9%

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

        \[\leadsto \frac{x + \frac{1}{\frac{t \cdot z - x}{\color{blue}{z \cdot y} - x}}}{x + 1} \]
    7. Simplified99.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq -1 \cdot 10^{+25}:\\ \;\;\;\;\frac{y}{\frac{\left(x + 1\right) \cdot \left(z \cdot t - x\right)}{z}}\\ \mathbf{elif}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq 2 \cdot 10^{-27} \lor \neg \left(\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq 10^{+253}\right):\\ \;\;\;\;\left(\frac{y}{t \cdot \left(x + 1\right)} + \frac{x}{x + 1}\right) - \frac{x}{\left(x + 1\right) \cdot \left(z \cdot t\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{1}{\frac{z \cdot t - x}{y \cdot z - x}}}{x + 1}\\ \end{array} \]

Alternative 2: 96.1% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t_2 \leq 10^{+253}:\\
\;\;\;\;t_2\\

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


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

    1. Initial program 82.4%

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

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

      \[\leadsto \color{blue}{\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}} \]
    4. Taylor expanded in y around inf 82.5%

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

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

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

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

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

    if -5e17 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 9.9999999999999994e252

    1. Initial program 97.4%

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

    if 9.9999999999999994e252 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1))

    1. Initial program 16.9%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Step-by-step derivation
      1. *-commutative16.9%

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

      \[\leadsto \color{blue}{\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}} \]
    4. Taylor expanded in z around inf 75.2%

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

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

Alternative 3: 96.5% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
t_1 := z \cdot t - x\\
\frac{y \cdot \frac{z}{t_1} + \left(x - \frac{x}{t_1}\right)}{x + 1}
\end{array}
\end{array}
Derivation
  1. Initial program 88.9%

    \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
  2. Step-by-step derivation
    1. *-commutative88.9%

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{y \cdot z}{z \cdot t - x} - \left(\frac{x}{z \cdot t - x} - x\right)}}{x + 1} \]
    4. *-un-lft-identity88.9%

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

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

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

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{y}{1}, \frac{z}{z \cdot t - x}, -\left(\frac{x}{z \cdot t - x} - x\right)\right)}}{x + 1} \]
  6. Step-by-step derivation
    1. fma-udef94.5%

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

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

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

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

Alternative 4: 79.4% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -6e-175 or 4.29999999999999994e-128 < z

    1. Initial program 84.1%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Step-by-step derivation
      1. *-commutative84.1%

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

      \[\leadsto \color{blue}{\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}} \]
    4. Taylor expanded in z around inf 81.7%

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

    if -6e-175 < z < 4.29999999999999994e-128

    1. Initial program 99.8%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Step-by-step derivation
      1. *-commutative99.8%

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

      \[\leadsto \color{blue}{\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}} \]
    4. Taylor expanded in y around 0 79.0%

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

        \[\leadsto \frac{x - \frac{x}{t \cdot z - x}}{\color{blue}{x + 1}} \]
    6. Simplified79.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6 \cdot 10^{-175} \lor \neg \left(z \leq 4.3 \cdot 10^{-128}\right):\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \frac{x}{z \cdot t - x}}{x + 1}\\ \end{array} \]

Alternative 5: 75.7% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.5 \cdot 10^{-175} \lor \neg \left(z \leq 3.15 \cdot 10^{-223}\right):\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.5e-175 or 3.14999999999999993e-223 < z

    1. Initial program 85.7%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Step-by-step derivation
      1. *-commutative85.7%

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

      \[\leadsto \color{blue}{\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}} \]
    4. Taylor expanded in z around inf 80.2%

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

    if -2.5e-175 < z < 3.14999999999999993e-223

    1. Initial program 99.8%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Step-by-step derivation
      1. *-commutative99.8%

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{y \cdot z}{z \cdot t - x} - \left(\frac{x}{z \cdot t - x} - x\right)}}{x + 1} \]
      4. *-un-lft-identity99.8%

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{y}{1}, \frac{z}{z \cdot t - x}, -\left(\frac{x}{z \cdot t - x} - x\right)\right)}}{x + 1} \]
    5. Applied egg-rr99.8%

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

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification77.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.5 \cdot 10^{-175} \lor \neg \left(z \leq 3.15 \cdot 10^{-223}\right):\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 6: 68.2% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.25 \cdot 10^{-72}:\\
\;\;\;\;\frac{x}{x + 1}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -3.2499999999999998e-72

    1. Initial program 90.4%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Step-by-step derivation
      1. *-commutative90.4%

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

      \[\leadsto \color{blue}{\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}} \]
    4. Taylor expanded in t around inf 82.1%

      \[\leadsto \color{blue}{\frac{x}{1 + x}} \]
    5. Step-by-step derivation
      1. +-commutative82.1%

        \[\leadsto \frac{x}{\color{blue}{x + 1}} \]
    6. Simplified82.1%

      \[\leadsto \color{blue}{\frac{x}{x + 1}} \]

    if -3.2499999999999998e-72 < x < 5.00000000000000003e-42

    1. Initial program 88.5%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Step-by-step derivation
      1. *-commutative88.5%

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{y \cdot z}{z \cdot t - x} - \left(\frac{x}{z \cdot t - x} - x\right)}}{x + 1} \]
      4. *-un-lft-identity88.5%

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{y}{1}, \frac{z}{z \cdot t - x}, -\left(\frac{x}{z \cdot t - x} - x\right)\right)}}{x + 1} \]
    5. Applied egg-rr91.9%

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

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

    if 5.00000000000000003e-42 < x

    1. Initial program 87.6%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Step-by-step derivation
      1. *-commutative87.6%

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

      \[\leadsto \color{blue}{\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}} \]
    4. Taylor expanded in x around -inf 60.9%

      \[\leadsto \color{blue}{1 + -1 \cdot \frac{y \cdot z - t \cdot z}{{x}^{2}}} \]
    5. Step-by-step derivation
      1. mul-1-neg60.9%

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

        \[\leadsto \color{blue}{1 - \frac{y \cdot z - t \cdot z}{{x}^{2}}} \]
      3. distribute-rgt-out--60.9%

        \[\leadsto 1 - \frac{\color{blue}{z \cdot \left(y - t\right)}}{{x}^{2}} \]
      4. unpow260.9%

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

      \[\leadsto \color{blue}{1 - \frac{z \cdot \left(y - t\right)}{x \cdot x}} \]
    7. Taylor expanded in y around inf 74.0%

      \[\leadsto 1 - \color{blue}{\frac{y \cdot z}{{x}^{2}}} \]
    8. Step-by-step derivation
      1. *-commutative74.0%

        \[\leadsto 1 - \frac{\color{blue}{z \cdot y}}{{x}^{2}} \]
      2. unpow274.0%

        \[\leadsto 1 - \frac{z \cdot y}{\color{blue}{x \cdot x}} \]
    9. Simplified74.0%

      \[\leadsto 1 - \color{blue}{\frac{z \cdot y}{x \cdot x}} \]
    10. Step-by-step derivation
      1. times-frac78.7%

        \[\leadsto 1 - \color{blue}{\frac{z}{x} \cdot \frac{y}{x}} \]
    11. Applied egg-rr78.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.25 \cdot 10^{-72}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-42}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{z}{x} \cdot \frac{y}{x}\\ \end{array} \]

Alternative 7: 67.5% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-35}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq -2.65 \cdot 10^{-73}:\\
\;\;\;\;x - x \cdot x\\

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

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -4.00000000000000003e-35 or 4.6000000000000002e-41 < x

    1. Initial program 88.7%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Step-by-step derivation
      1. *-commutative88.7%

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{y \cdot z}{z \cdot t - x} - \left(\frac{x}{z \cdot t - x} - x\right)}}{x + 1} \]
      4. *-un-lft-identity88.7%

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

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

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

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

      \[\leadsto \color{blue}{1} \]

    if -4.00000000000000003e-35 < x < -2.64999999999999986e-73

    1. Initial program 100.0%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Step-by-step derivation
      1. *-commutative100.0%

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

      \[\leadsto \color{blue}{\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}} \]
    4. Taylor expanded in t around inf 84.1%

      \[\leadsto \color{blue}{\frac{x}{1 + x}} \]
    5. Step-by-step derivation
      1. +-commutative84.1%

        \[\leadsto \frac{x}{\color{blue}{x + 1}} \]
    6. Simplified84.1%

      \[\leadsto \color{blue}{\frac{x}{x + 1}} \]
    7. Taylor expanded in x around 0 84.1%

      \[\leadsto \color{blue}{-1 \cdot {x}^{2} + x} \]
    8. Step-by-step derivation
      1. +-commutative84.1%

        \[\leadsto \color{blue}{x + -1 \cdot {x}^{2}} \]
      2. mul-1-neg84.1%

        \[\leadsto x + \color{blue}{\left(-{x}^{2}\right)} \]
      3. unsub-neg84.1%

        \[\leadsto \color{blue}{x - {x}^{2}} \]
      4. unpow284.1%

        \[\leadsto x - \color{blue}{x \cdot x} \]
    9. Simplified84.1%

      \[\leadsto \color{blue}{x - x \cdot x} \]

    if -2.64999999999999986e-73 < x < 4.6000000000000002e-41

    1. Initial program 88.5%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Step-by-step derivation
      1. *-commutative88.5%

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{y \cdot z}{z \cdot t - x} - \left(\frac{x}{z \cdot t - x} - x\right)}}{x + 1} \]
      4. *-un-lft-identity88.5%

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{y}{1}, \frac{z}{z \cdot t - x}, -\left(\frac{x}{z \cdot t - x} - x\right)\right)}}{x + 1} \]
    5. Applied egg-rr91.9%

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

      \[\leadsto \color{blue}{\frac{y}{t}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification70.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{-35}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -2.65 \cdot 10^{-73}:\\ \;\;\;\;x - x \cdot x\\ \mathbf{elif}\;x \leq 4.6 \cdot 10^{-41}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 8: 67.4% accurate, 2.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{-36}:\\
\;\;\;\;1\\

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

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.70000000000000007e-36 or 5.80000000000000026e-36 < x

    1. Initial program 88.7%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Step-by-step derivation
      1. *-commutative88.7%

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{y \cdot z}{z \cdot t - x} - \left(\frac{x}{z \cdot t - x} - x\right)}}{x + 1} \]
      4. *-un-lft-identity88.7%

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

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

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

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

      \[\leadsto \color{blue}{1} \]

    if -2.70000000000000007e-36 < x < 5.80000000000000026e-36

    1. Initial program 89.0%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Step-by-step derivation
      1. *-commutative89.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{y}{t}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification68.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{-36}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{-36}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 9: 67.7% accurate, 2.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.65 \cdot 10^{-72}:\\
\;\;\;\;\frac{x}{x + 1}\\

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

\mathbf{else}:\\
\;\;\;\;1\\


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

    1. Initial program 90.4%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Step-by-step derivation
      1. *-commutative90.4%

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

      \[\leadsto \color{blue}{\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}} \]
    4. Taylor expanded in t around inf 82.1%

      \[\leadsto \color{blue}{\frac{x}{1 + x}} \]
    5. Step-by-step derivation
      1. +-commutative82.1%

        \[\leadsto \frac{x}{\color{blue}{x + 1}} \]
    6. Simplified82.1%

      \[\leadsto \color{blue}{\frac{x}{x + 1}} \]

    if -1.65e-72 < x < 5.00000000000000004e-36

    1. Initial program 88.5%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Step-by-step derivation
      1. *-commutative88.5%

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{y \cdot z}{z \cdot t - x} - \left(\frac{x}{z \cdot t - x} - x\right)}}{x + 1} \]
      4. *-un-lft-identity88.5%

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{y}{1}, \frac{z}{z \cdot t - x}, -\left(\frac{x}{z \cdot t - x} - x\right)\right)}}{x + 1} \]
    5. Applied egg-rr91.9%

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

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

    if 5.00000000000000004e-36 < x

    1. Initial program 87.6%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Step-by-step derivation
      1. *-commutative87.6%

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

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

        \[\leadsto \frac{\color{blue}{\frac{y \cdot z - x}{z \cdot t - x} + x}}{x + 1} \]
      2. div-sub87.6%

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

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

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

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

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

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

      \[\leadsto \color{blue}{1} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification69.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.65 \cdot 10^{-72}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-36}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 10: 52.3% accurate, 17.0× speedup?

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

\\
1
\end{array}
Derivation
  1. Initial program 88.9%

    \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
  2. Step-by-step derivation
    1. *-commutative88.9%

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{y \cdot z}{z \cdot t - x} - \left(\frac{x}{z \cdot t - x} - x\right)}}{x + 1} \]
    4. *-un-lft-identity88.9%

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

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

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

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

    \[\leadsto \color{blue}{1} \]
  7. Final simplification51.2%

    \[\leadsto 1 \]

Developer target: 99.5% accurate, 0.8× speedup?

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

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

Reproduce

?
herbie shell --seed 2023252 
(FPCore (x y z t)
  :name "Diagrams.Trail:splitAtParam  from diagrams-lib-1.3.0.3, A"
  :precision binary64

  :herbie-target
  (/ (+ x (- (/ y (- t (/ x z))) (/ x (- (* t z) x)))) (+ x 1.0))

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