Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, B

Percentage Accurate: 95.9% → 97.8%
Time: 10.0s
Alternatives: 9
Speedup: 0.5×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 95.9% accurate, 1.0× speedup?

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

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

Alternative 1: 97.8% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \cdot t \leq -\infty:\\ \;\;\;\;\frac{-1}{t} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\mathsf{fma}\left(-z, t, y\right)}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= (* z t) (- INFINITY)) (* (/ -1.0 t) (/ x z)) (/ x (fma (- z) t y))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((z * t) <= -((double) INFINITY)) {
		tmp = (-1.0 / t) * (x / z);
	} else {
		tmp = x / fma(-z, t, y);
	}
	return tmp;
}
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(z * t) <= Float64(-Inf))
		tmp = Float64(Float64(-1.0 / t) * Float64(x / z));
	else
		tmp = Float64(x / fma(Float64(-z), t, y));
	end
	return tmp
end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * t), $MachinePrecision], (-Infinity)], N[(N[(-1.0 / t), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x / N[((-z) * t + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -\infty:\\
\;\;\;\;\frac{-1}{t} \cdot \frac{x}{z}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(-z, t, y\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z t) < -inf.0

    1. Initial program 75.9%

      \[\frac{x}{y - z \cdot t} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 75.9%

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

        \[\leadsto \color{blue}{-\frac{x}{t \cdot z}} \]
      2. associate-/r*99.9%

        \[\leadsto -\color{blue}{\frac{\frac{x}{t}}{z}} \]
      3. distribute-neg-frac299.9%

        \[\leadsto \color{blue}{\frac{\frac{x}{t}}{-z}} \]
    5. Simplified99.9%

      \[\leadsto \color{blue}{\frac{\frac{x}{t}}{-z}} \]
    6. Step-by-step derivation
      1. div-inv99.9%

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

        \[\leadsto \color{blue}{x \cdot \frac{\frac{1}{t}}{-z}} \]
      3. add-sqr-sqrt47.3%

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}} \]
      4. sqrt-unprod75.8%

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}} \]
      5. sqr-neg75.8%

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\sqrt{\color{blue}{z \cdot z}}} \]
      6. sqrt-unprod28.5%

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}} \]
      7. add-sqr-sqrt75.8%

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\color{blue}{z}} \]
    7. Applied egg-rr75.8%

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

        \[\leadsto x \cdot \color{blue}{\frac{1}{z \cdot t}} \]
      2. associate-*r/75.9%

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

        \[\leadsto \frac{\color{blue}{1 \cdot x}}{z \cdot t} \]
      4. *-commutative75.9%

        \[\leadsto \frac{1 \cdot x}{\color{blue}{t \cdot z}} \]
      5. *-lft-identity75.9%

        \[\leadsto \frac{\color{blue}{x}}{t \cdot z} \]
    9. Simplified75.9%

      \[\leadsto \color{blue}{\frac{x}{t \cdot z}} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt75.9%

        \[\leadsto \color{blue}{\sqrt{\frac{x}{t \cdot z}} \cdot \sqrt{\frac{x}{t \cdot z}}} \]
      2. sqrt-unprod75.9%

        \[\leadsto \color{blue}{\sqrt{\frac{x}{t \cdot z} \cdot \frac{x}{t \cdot z}}} \]
      3. sqr-neg75.9%

        \[\leadsto \sqrt{\color{blue}{\left(-\frac{x}{t \cdot z}\right) \cdot \left(-\frac{x}{t \cdot z}\right)}} \]
      4. distribute-frac-neg75.9%

        \[\leadsto \sqrt{\color{blue}{\frac{-x}{t \cdot z}} \cdot \left(-\frac{x}{t \cdot z}\right)} \]
      5. distribute-frac-neg75.9%

        \[\leadsto \sqrt{\frac{-x}{t \cdot z} \cdot \color{blue}{\frac{-x}{t \cdot z}}} \]
      6. sqrt-unprod75.9%

        \[\leadsto \color{blue}{\sqrt{\frac{-x}{t \cdot z}} \cdot \sqrt{\frac{-x}{t \cdot z}}} \]
      7. add-sqr-sqrt75.9%

        \[\leadsto \color{blue}{\frac{-x}{t \cdot z}} \]
      8. neg-mul-175.9%

        \[\leadsto \frac{\color{blue}{-1 \cdot x}}{t \cdot z} \]
      9. times-frac99.9%

        \[\leadsto \color{blue}{\frac{-1}{t} \cdot \frac{x}{z}} \]
    11. Applied egg-rr99.9%

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

    if -inf.0 < (*.f64 z t)

    1. Initial program 98.3%

      \[\frac{x}{y - z \cdot t} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg98.3%

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

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

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

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

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

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

Alternative 2: 72.2% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.2 \cdot 10^{+59}:\\
\;\;\;\;\frac{1}{\frac{y}{x}}\\

\mathbf{elif}\;y \leq 1.35 \cdot 10^{-73} \lor \neg \left(y \leq 1.12 \cdot 10^{-29}\right) \land y \leq 1.2 \cdot 10^{+26}:\\
\;\;\;\;\frac{x}{t \cdot \left(-z\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -9.20000000000000032e59

    1. Initial program 93.2%

      \[\frac{x}{y - z \cdot t} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num91.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.20000000000000032e59 < y < 1.34999999999999997e-73 or 1.11999999999999995e-29 < y < 1.20000000000000002e26

    1. Initial program 97.8%

      \[\frac{x}{y - z \cdot t} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 76.6%

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

        \[\leadsto \color{blue}{\frac{-1 \cdot x}{t \cdot z}} \]
      2. neg-mul-176.6%

        \[\leadsto \frac{\color{blue}{-x}}{t \cdot z} \]
    5. Simplified76.6%

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

    if 1.34999999999999997e-73 < y < 1.11999999999999995e-29 or 1.20000000000000002e26 < y

    1. Initial program 95.1%

      \[\frac{x}{y - z \cdot t} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 83.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.2 \cdot 10^{+59}:\\ \;\;\;\;\frac{1}{\frac{y}{x}}\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{-73} \lor \neg \left(y \leq 1.12 \cdot 10^{-29}\right) \land y \leq 1.2 \cdot 10^{+26}:\\ \;\;\;\;\frac{x}{t \cdot \left(-z\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 68.3% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -5.5 \cdot 10^{-137} \lor \neg \left(t \leq 1.08 \cdot 10^{+71}\right):\\
\;\;\;\;\frac{\frac{x}{t}}{-z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -5.5000000000000003e-137 or 1.08e71 < t

    1. Initial program 93.4%

      \[\frac{x}{y - z \cdot t} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 67.8%

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

        \[\leadsto \color{blue}{-\frac{x}{t \cdot z}} \]
      2. associate-/r*75.3%

        \[\leadsto -\color{blue}{\frac{\frac{x}{t}}{z}} \]
      3. distribute-neg-frac275.3%

        \[\leadsto \color{blue}{\frac{\frac{x}{t}}{-z}} \]
    5. Simplified75.3%

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

    if -5.5000000000000003e-137 < t < 1.08e71

    1. Initial program 99.9%

      \[\frac{x}{y - z \cdot t} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 72.2%

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

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

Alternative 4: 68.6% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -9 \cdot 10^{-130}:\\
\;\;\;\;\frac{x}{t} \cdot \frac{-1}{z}\\

\mathbf{elif}\;t \leq 3.4 \cdot 10^{+69}:\\
\;\;\;\;\frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < -9e-130

    1. Initial program 91.1%

      \[\frac{x}{y - z \cdot t} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 61.8%

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

        \[\leadsto \color{blue}{-\frac{x}{t \cdot z}} \]
      2. associate-/r*67.8%

        \[\leadsto -\color{blue}{\frac{\frac{x}{t}}{z}} \]
      3. distribute-neg-frac267.8%

        \[\leadsto \color{blue}{\frac{\frac{x}{t}}{-z}} \]
    5. Simplified67.8%

      \[\leadsto \color{blue}{\frac{\frac{x}{t}}{-z}} \]
    6. Step-by-step derivation
      1. div-inv67.8%

        \[\leadsto \color{blue}{\frac{x}{t} \cdot \frac{1}{-z}} \]
      2. frac-2neg67.8%

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

        \[\leadsto \frac{x}{t} \cdot \frac{\color{blue}{-1}}{-\left(-z\right)} \]
      4. remove-double-neg67.8%

        \[\leadsto \frac{x}{t} \cdot \frac{-1}{\color{blue}{z}} \]
    7. Applied egg-rr67.8%

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

    if -9e-130 < t < 3.39999999999999986e69

    1. Initial program 99.9%

      \[\frac{x}{y - z \cdot t} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 72.2%

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

    if 3.39999999999999986e69 < t

    1. Initial program 96.9%

      \[\frac{x}{y - z \cdot t} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 76.6%

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

        \[\leadsto \color{blue}{-\frac{x}{t \cdot z}} \]
      2. associate-/r*86.4%

        \[\leadsto -\color{blue}{\frac{\frac{x}{t}}{z}} \]
      3. distribute-neg-frac286.4%

        \[\leadsto \color{blue}{\frac{\frac{x}{t}}{-z}} \]
    5. Simplified86.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -9 \cdot 10^{-130}:\\ \;\;\;\;\frac{x}{t} \cdot \frac{-1}{z}\\ \mathbf{elif}\;t \leq 3.4 \cdot 10^{+69}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{t}}{-z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 56.0% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.6 \cdot 10^{+171} \lor \neg \left(z \leq 1.9 \cdot 10^{+55}\right):\\
\;\;\;\;\frac{x}{z \cdot t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -7.6000000000000004e171 or 1.9e55 < z

    1. Initial program 92.2%

      \[\frac{x}{y - z \cdot t} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 68.5%

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

        \[\leadsto \color{blue}{-\frac{x}{t \cdot z}} \]
      2. associate-/r*73.1%

        \[\leadsto -\color{blue}{\frac{\frac{x}{t}}{z}} \]
      3. distribute-neg-frac273.1%

        \[\leadsto \color{blue}{\frac{\frac{x}{t}}{-z}} \]
    5. Simplified73.1%

      \[\leadsto \color{blue}{\frac{\frac{x}{t}}{-z}} \]
    6. Step-by-step derivation
      1. div-inv73.1%

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

        \[\leadsto \color{blue}{x \cdot \frac{\frac{1}{t}}{-z}} \]
      3. add-sqr-sqrt25.0%

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}} \]
      4. sqrt-unprod45.2%

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}} \]
      5. sqr-neg45.2%

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\sqrt{\color{blue}{z \cdot z}}} \]
      6. sqrt-unprod23.3%

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}} \]
      7. add-sqr-sqrt43.1%

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\color{blue}{z}} \]
    7. Applied egg-rr43.1%

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

        \[\leadsto x \cdot \color{blue}{\frac{1}{z \cdot t}} \]
      2. associate-*r/43.1%

        \[\leadsto \color{blue}{\frac{x \cdot 1}{z \cdot t}} \]
      3. *-commutative43.1%

        \[\leadsto \frac{\color{blue}{1 \cdot x}}{z \cdot t} \]
      4. *-commutative43.1%

        \[\leadsto \frac{1 \cdot x}{\color{blue}{t \cdot z}} \]
      5. *-lft-identity43.1%

        \[\leadsto \frac{\color{blue}{x}}{t \cdot z} \]
    9. Simplified43.1%

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

    if -7.6000000000000004e171 < z < 1.9e55

    1. Initial program 98.7%

      \[\frac{x}{y - z \cdot t} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 62.3%

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

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

Alternative 6: 56.3% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;z \leq 1.15 \cdot 10^{+55}:\\
\;\;\;\;\frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -7.00000000000000038e169

    1. Initial program 93.2%

      \[\frac{x}{y - z \cdot t} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 75.0%

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

        \[\leadsto \color{blue}{-\frac{x}{t \cdot z}} \]
      2. associate-/r*78.6%

        \[\leadsto -\color{blue}{\frac{\frac{x}{t}}{z}} \]
      3. distribute-neg-frac278.6%

        \[\leadsto \color{blue}{\frac{\frac{x}{t}}{-z}} \]
    5. Simplified78.6%

      \[\leadsto \color{blue}{\frac{\frac{x}{t}}{-z}} \]
    6. Step-by-step derivation
      1. div-inv78.6%

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

        \[\leadsto \color{blue}{x \cdot \frac{\frac{1}{t}}{-z}} \]
      3. add-sqr-sqrt74.9%

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}} \]
      4. sqrt-unprod62.2%

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}} \]
      5. sqr-neg62.2%

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

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}} \]
      7. add-sqr-sqrt59.3%

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\color{blue}{z}} \]
    7. Applied egg-rr59.3%

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

        \[\leadsto x \cdot \color{blue}{\frac{1}{z \cdot t}} \]
      2. associate-*r/59.3%

        \[\leadsto \color{blue}{\frac{x \cdot 1}{z \cdot t}} \]
      3. *-commutative59.3%

        \[\leadsto \frac{\color{blue}{1 \cdot x}}{z \cdot t} \]
      4. *-commutative59.3%

        \[\leadsto \frac{1 \cdot x}{\color{blue}{t \cdot z}} \]
      5. *-lft-identity59.3%

        \[\leadsto \frac{\color{blue}{x}}{t \cdot z} \]
    9. Simplified59.3%

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

        \[\leadsto \color{blue}{\frac{\frac{x}{t}}{z}} \]
      2. div-inv59.1%

        \[\leadsto \color{blue}{\frac{x}{t} \cdot \frac{1}{z}} \]
      3. div-inv59.1%

        \[\leadsto \color{blue}{\left(x \cdot \frac{1}{t}\right)} \cdot \frac{1}{z} \]
      4. associate-*r*59.3%

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

        \[\leadsto x \cdot \color{blue}{\frac{1 \cdot \frac{1}{z}}{t}} \]
      6. *-un-lft-identity59.3%

        \[\leadsto x \cdot \frac{\color{blue}{\frac{1}{z}}}{t} \]
    11. Applied egg-rr59.3%

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

        \[\leadsto \color{blue}{\frac{x \cdot \frac{1}{z}}{t}} \]
      2. *-commutative62.2%

        \[\leadsto \frac{\color{blue}{\frac{1}{z} \cdot x}}{t} \]
      3. associate-*l/62.2%

        \[\leadsto \frac{\color{blue}{\frac{1 \cdot x}{z}}}{t} \]
      4. associate-*r/62.2%

        \[\leadsto \frac{\color{blue}{1 \cdot \frac{x}{z}}}{t} \]
      5. *-lft-identity62.2%

        \[\leadsto \frac{\color{blue}{\frac{x}{z}}}{t} \]
    13. Simplified62.2%

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

    if -7.00000000000000038e169 < z < 1.14999999999999994e55

    1. Initial program 98.7%

      \[\frac{x}{y - z \cdot t} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 62.3%

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

    if 1.14999999999999994e55 < z

    1. Initial program 91.7%

      \[\frac{x}{y - z \cdot t} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 65.2%

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{t \cdot z}} \]
    4. Step-by-step derivation
      1. mul-1-neg65.2%

        \[\leadsto \color{blue}{-\frac{x}{t \cdot z}} \]
      2. associate-/r*70.3%

        \[\leadsto -\color{blue}{\frac{\frac{x}{t}}{z}} \]
      3. distribute-neg-frac270.3%

        \[\leadsto \color{blue}{\frac{\frac{x}{t}}{-z}} \]
    5. Simplified70.3%

      \[\leadsto \color{blue}{\frac{\frac{x}{t}}{-z}} \]
    6. Step-by-step derivation
      1. div-inv70.3%

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

        \[\leadsto \color{blue}{x \cdot \frac{\frac{1}{t}}{-z}} \]
      3. add-sqr-sqrt0.0%

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}} \]
      4. sqrt-unprod36.7%

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}} \]
      5. sqr-neg36.7%

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

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}} \]
      7. add-sqr-sqrt35.0%

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

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

        \[\leadsto x \cdot \color{blue}{\frac{1}{z \cdot t}} \]
      2. associate-*r/35.0%

        \[\leadsto \color{blue}{\frac{x \cdot 1}{z \cdot t}} \]
      3. *-commutative35.0%

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

        \[\leadsto \frac{1 \cdot x}{\color{blue}{t \cdot z}} \]
      5. *-lft-identity35.0%

        \[\leadsto \frac{\color{blue}{x}}{t \cdot z} \]
    9. Simplified35.0%

      \[\leadsto \color{blue}{\frac{x}{t \cdot z}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification55.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7 \cdot 10^{+169}:\\ \;\;\;\;\frac{\frac{x}{z}}{t}\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{+55}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z \cdot t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 97.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \cdot t \leq -\infty:\\ \;\;\;\;\frac{-1}{t} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y - z \cdot t}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= (* z t) (- INFINITY)) (* (/ -1.0 t) (/ x z)) (/ x (- y (* z t)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((z * t) <= -((double) INFINITY)) {
		tmp = (-1.0 / t) * (x / z);
	} else {
		tmp = x / (y - (z * t));
	}
	return tmp;
}
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((z * t) <= -Double.POSITIVE_INFINITY) {
		tmp = (-1.0 / t) * (x / z);
	} else {
		tmp = x / (y - (z * t));
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (z * t) <= -math.inf:
		tmp = (-1.0 / t) * (x / z)
	else:
		tmp = x / (y - (z * t))
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(z * t) <= Float64(-Inf))
		tmp = Float64(Float64(-1.0 / t) * Float64(x / 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 ((z * t) <= -Inf)
		tmp = (-1.0 / t) * (x / z);
	else
		tmp = x / (y - (z * t));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * t), $MachinePrecision], (-Infinity)], N[(N[(-1.0 / t), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -\infty:\\
\;\;\;\;\frac{-1}{t} \cdot \frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z t) < -inf.0

    1. Initial program 75.9%

      \[\frac{x}{y - z \cdot t} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 75.9%

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

        \[\leadsto \color{blue}{-\frac{x}{t \cdot z}} \]
      2. associate-/r*99.9%

        \[\leadsto -\color{blue}{\frac{\frac{x}{t}}{z}} \]
      3. distribute-neg-frac299.9%

        \[\leadsto \color{blue}{\frac{\frac{x}{t}}{-z}} \]
    5. Simplified99.9%

      \[\leadsto \color{blue}{\frac{\frac{x}{t}}{-z}} \]
    6. Step-by-step derivation
      1. div-inv99.9%

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

        \[\leadsto \color{blue}{x \cdot \frac{\frac{1}{t}}{-z}} \]
      3. add-sqr-sqrt47.3%

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}} \]
      4. sqrt-unprod75.8%

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}} \]
      5. sqr-neg75.8%

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\sqrt{\color{blue}{z \cdot z}}} \]
      6. sqrt-unprod28.5%

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}} \]
      7. add-sqr-sqrt75.8%

        \[\leadsto x \cdot \frac{\frac{1}{t}}{\color{blue}{z}} \]
    7. Applied egg-rr75.8%

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

        \[\leadsto x \cdot \color{blue}{\frac{1}{z \cdot t}} \]
      2. associate-*r/75.9%

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

        \[\leadsto \frac{\color{blue}{1 \cdot x}}{z \cdot t} \]
      4. *-commutative75.9%

        \[\leadsto \frac{1 \cdot x}{\color{blue}{t \cdot z}} \]
      5. *-lft-identity75.9%

        \[\leadsto \frac{\color{blue}{x}}{t \cdot z} \]
    9. Simplified75.9%

      \[\leadsto \color{blue}{\frac{x}{t \cdot z}} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt75.9%

        \[\leadsto \color{blue}{\sqrt{\frac{x}{t \cdot z}} \cdot \sqrt{\frac{x}{t \cdot z}}} \]
      2. sqrt-unprod75.9%

        \[\leadsto \color{blue}{\sqrt{\frac{x}{t \cdot z} \cdot \frac{x}{t \cdot z}}} \]
      3. sqr-neg75.9%

        \[\leadsto \sqrt{\color{blue}{\left(-\frac{x}{t \cdot z}\right) \cdot \left(-\frac{x}{t \cdot z}\right)}} \]
      4. distribute-frac-neg75.9%

        \[\leadsto \sqrt{\color{blue}{\frac{-x}{t \cdot z}} \cdot \left(-\frac{x}{t \cdot z}\right)} \]
      5. distribute-frac-neg75.9%

        \[\leadsto \sqrt{\frac{-x}{t \cdot z} \cdot \color{blue}{\frac{-x}{t \cdot z}}} \]
      6. sqrt-unprod75.9%

        \[\leadsto \color{blue}{\sqrt{\frac{-x}{t \cdot z}} \cdot \sqrt{\frac{-x}{t \cdot z}}} \]
      7. add-sqr-sqrt75.9%

        \[\leadsto \color{blue}{\frac{-x}{t \cdot z}} \]
      8. neg-mul-175.9%

        \[\leadsto \frac{\color{blue}{-1 \cdot x}}{t \cdot z} \]
      9. times-frac99.9%

        \[\leadsto \color{blue}{\frac{-1}{t} \cdot \frac{x}{z}} \]
    11. Applied egg-rr99.9%

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

    if -inf.0 < (*.f64 z t)

    1. Initial program 98.3%

      \[\frac{x}{y - z \cdot t} \]
    2. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Final simplification98.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot t \leq -\infty:\\ \;\;\;\;\frac{-1}{t} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y - z \cdot t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 54.0% accurate, 1.4× speedup?

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

\\
\frac{1}{\frac{y}{x}}
\end{array}
Derivation
  1. Initial program 96.3%

    \[\frac{x}{y - z \cdot t} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. clear-num95.8%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{y - t \cdot z}{x}}} \]
    6. *-commutative95.8%

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

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

    \[\leadsto \frac{1}{\color{blue}{\frac{y}{x}}} \]
  9. Final simplification51.9%

    \[\leadsto \frac{1}{\frac{y}{x}} \]
  10. Add Preprocessing

Alternative 9: 54.5% accurate, 2.3× speedup?

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

\\
\frac{x}{y}
\end{array}
Derivation
  1. Initial program 96.3%

    \[\frac{x}{y - z \cdot t} \]
  2. Add Preprocessing
  3. Taylor expanded in y around inf 51.8%

    \[\leadsto \color{blue}{\frac{x}{y}} \]
  4. Final simplification51.8%

    \[\leadsto \frac{x}{y} \]
  5. Add Preprocessing

Developer target: 96.3% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_1 := \frac{1}{\frac{y}{x} - \frac{z}{x} \cdot t}\\
\mathbf{if}\;x < -1.618195973607049 \cdot 10^{+50}:\\
\;\;\;\;t\_1\\

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

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024044 
(FPCore (x y z t)
  :name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, B"
  :precision binary64

  :herbie-target
  (if (< x -1.618195973607049e+50) (/ 1.0 (- (/ y x) (* (/ z x) t))) (if (< x 2.1378306434876444e+131) (/ x (- y (* z t))) (/ 1.0 (- (/ y x) (* (/ z x) t)))))

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