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

Percentage Accurate: 95.8% → 96.9%
Time: 8.9s
Alternatives: 8
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 8 alternatives:

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

Initial Program: 95.8% 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: 96.9% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 84.4%

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

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

        \[\leadsto \color{blue}{\frac{1}{y - z \cdot t} \cdot x} \]
    4. Applied egg-rr84.5%

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

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

        \[\leadsto \color{blue}{\frac{x}{y - z \cdot t}} \]
      3. sub-neg84.4%

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

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

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

        \[\leadsto \frac{x}{\left(-z\right) \cdot \color{blue}{\left(\sqrt{t} \cdot \sqrt{t}\right)} + y} \]
      7. associate-*r*49.0%

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

        \[\leadsto \frac{x}{\color{blue}{\mathsf{fma}\left(\left(-z\right) \cdot \sqrt{t}, \sqrt{t}, y\right)}} \]
      9. frac-2neg49.0%

        \[\leadsto \color{blue}{\frac{-x}{-\mathsf{fma}\left(\left(-z\right) \cdot \sqrt{t}, \sqrt{t}, y\right)}} \]
      10. neg-mul-149.0%

        \[\leadsto \frac{\color{blue}{-1 \cdot x}}{-\mathsf{fma}\left(\left(-z\right) \cdot \sqrt{t}, \sqrt{t}, y\right)} \]
      11. associate-/l*49.0%

        \[\leadsto \color{blue}{\frac{-1}{\frac{-\mathsf{fma}\left(\left(-z\right) \cdot \sqrt{t}, \sqrt{t}, y\right)}{x}}} \]
      12. add-sqr-sqrt24.6%

        \[\leadsto \frac{-1}{\frac{-\mathsf{fma}\left(\left(-z\right) \cdot \sqrt{t}, \sqrt{t}, y\right)}{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}} \]
      13. sqrt-unprod38.2%

        \[\leadsto \frac{-1}{\frac{-\mathsf{fma}\left(\left(-z\right) \cdot \sqrt{t}, \sqrt{t}, y\right)}{\color{blue}{\sqrt{x \cdot x}}}} \]
      14. sqr-neg38.2%

        \[\leadsto \frac{-1}{\frac{-\mathsf{fma}\left(\left(-z\right) \cdot \sqrt{t}, \sqrt{t}, y\right)}{\sqrt{\color{blue}{\left(-x\right) \cdot \left(-x\right)}}}} \]
      15. sqrt-unprod16.6%

        \[\leadsto \frac{-1}{\frac{-\mathsf{fma}\left(\left(-z\right) \cdot \sqrt{t}, \sqrt{t}, y\right)}{\color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}} \]
      16. add-sqr-sqrt35.9%

        \[\leadsto \frac{-1}{\frac{-\mathsf{fma}\left(\left(-z\right) \cdot \sqrt{t}, \sqrt{t}, y\right)}{\color{blue}{-x}}} \]
      17. frac-2neg35.9%

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

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

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

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

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

    if -1.00000000000000001e160 < (*.f64 z t)

    1. Initial program 98.5%

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

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

Alternative 2: 78.4% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;z \cdot t \leq -4 \cdot 10^{-90} \lor \neg \left(z \cdot t \leq 100000000\right):\\
\;\;\;\;-\frac{x}{z \cdot t}\\

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


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

    1. Initial program 83.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.00000000000000002e184 < (*.f64 z t) < -3.99999999999999998e-90 or 1e8 < (*.f64 z t)

    1. Initial program 97.1%

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

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

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

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

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

    if -3.99999999999999998e-90 < (*.f64 z t) < 1e8

    1. Initial program 99.9%

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

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

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

Alternative 3: 76.6% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -4 \cdot 10^{-90} \lor \neg \left(z \cdot t \leq 100000000\right):\\
\;\;\;\;-\frac{x}{z \cdot t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z t) < -3.99999999999999998e-90 or 1e8 < (*.f64 z t)

    1. Initial program 93.8%

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

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

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

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

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

    if -3.99999999999999998e-90 < (*.f64 z t) < 1e8

    1. Initial program 99.9%

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

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

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

Alternative 4: 78.3% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -4 \cdot 10^{-90} \lor \neg \left(z \cdot t \leq 100000000\right):\\
\;\;\;\;\frac{\frac{-x}{z}}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z t) < -3.99999999999999998e-90 or 1e8 < (*.f64 z t)

    1. Initial program 93.8%

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

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

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

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

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

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

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

    if -3.99999999999999998e-90 < (*.f64 z t) < 1e8

    1. Initial program 99.9%

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

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

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

Alternative 5: 78.2% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;z \cdot t \leq 100000000:\\
\;\;\;\;\frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 z t) < -3.99999999999999998e-90

    1. Initial program 93.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x}{\left(-z\right) \cdot \color{blue}{\left(\sqrt{t} \cdot \sqrt{t}\right)} + y} \]
      7. associate-*r*46.6%

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

        \[\leadsto \frac{x}{\color{blue}{\mathsf{fma}\left(\left(-z\right) \cdot \sqrt{t}, \sqrt{t}, y\right)}} \]
      9. frac-2neg46.6%

        \[\leadsto \color{blue}{\frac{-x}{-\mathsf{fma}\left(\left(-z\right) \cdot \sqrt{t}, \sqrt{t}, y\right)}} \]
      10. neg-mul-146.6%

        \[\leadsto \frac{\color{blue}{-1 \cdot x}}{-\mathsf{fma}\left(\left(-z\right) \cdot \sqrt{t}, \sqrt{t}, y\right)} \]
      11. associate-/l*46.6%

        \[\leadsto \color{blue}{\frac{-1}{\frac{-\mathsf{fma}\left(\left(-z\right) \cdot \sqrt{t}, \sqrt{t}, y\right)}{x}}} \]
      12. add-sqr-sqrt24.4%

        \[\leadsto \frac{-1}{\frac{-\mathsf{fma}\left(\left(-z\right) \cdot \sqrt{t}, \sqrt{t}, y\right)}{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}} \]
      13. sqrt-unprod27.4%

        \[\leadsto \frac{-1}{\frac{-\mathsf{fma}\left(\left(-z\right) \cdot \sqrt{t}, \sqrt{t}, y\right)}{\color{blue}{\sqrt{x \cdot x}}}} \]
      14. sqr-neg27.4%

        \[\leadsto \frac{-1}{\frac{-\mathsf{fma}\left(\left(-z\right) \cdot \sqrt{t}, \sqrt{t}, y\right)}{\sqrt{\color{blue}{\left(-x\right) \cdot \left(-x\right)}}}} \]
      15. sqrt-unprod8.5%

        \[\leadsto \frac{-1}{\frac{-\mathsf{fma}\left(\left(-z\right) \cdot \sqrt{t}, \sqrt{t}, y\right)}{\color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}} \]
      16. add-sqr-sqrt17.3%

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

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

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

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

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

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

    if -3.99999999999999998e-90 < (*.f64 z t) < 1e8

    1. Initial program 99.9%

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

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

    if 1e8 < (*.f64 z t)

    1. Initial program 94.9%

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

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

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

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

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

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

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

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

Alternative 6: 56.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.8 \cdot 10^{+189} \lor \neg \left(z \leq 2.3 \cdot 10^{+63}\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 -1.8e+189) (not (<= z 2.3e+63))) (/ x (* z t)) (/ x y)))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -1.8e+189) || !(z <= 2.3e+63)) {
		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 <= (-1.8d+189)) .or. (.not. (z <= 2.3d+63))) 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 <= -1.8e+189) || !(z <= 2.3e+63)) {
		tmp = x / (z * t);
	} else {
		tmp = x / y;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (z <= -1.8e+189) or not (z <= 2.3e+63):
		tmp = x / (z * t)
	else:
		tmp = x / y
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((z <= -1.8e+189) || !(z <= 2.3e+63))
		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 <= -1.8e+189) || ~((z <= 2.3e+63)))
		tmp = x / (z * t);
	else
		tmp = x / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1.8e+189], N[Not[LessEqual[z, 2.3e+63]], $MachinePrecision]], N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.8 \cdot 10^{+189} \lor \neg \left(z \leq 2.3 \cdot 10^{+63}\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 < -1.80000000000000004e189 or 2.29999999999999993e63 < z

    1. Initial program 93.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{-x}{z}}{t}\right)\right)} \]
      2. expm1-udef58.9%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{-x}{z}}{t}\right)} - 1} \]
      3. associate-/r*58.9%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{-x}{z \cdot t}}\right)} - 1 \]
      4. add-sqr-sqrt26.5%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}{z \cdot t}\right)} - 1 \]
      5. sqrt-unprod50.4%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}{z \cdot t}\right)} - 1 \]
      6. sqr-neg50.4%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{\color{blue}{x \cdot x}}}{z \cdot t}\right)} - 1 \]
      7. sqrt-unprod25.6%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{z \cdot t}\right)} - 1 \]
      8. add-sqr-sqrt49.4%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{x}}{z \cdot t}\right)} - 1 \]
    7. Applied egg-rr49.4%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{x}{z \cdot t}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def45.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x}{z \cdot t}\right)\right)} \]
      2. expm1-log1p45.4%

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

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

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

    if -1.80000000000000004e189 < z < 2.29999999999999993e63

    1. Initial program 97.8%

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1}{y}} \cdot x \]
  6. Step-by-step derivation
    1. associate-*l/50.2%

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

      \[\leadsto \color{blue}{\frac{1}{\frac{y}{x}}} \]
  7. Applied egg-rr50.3%

    \[\leadsto \color{blue}{\frac{1}{\frac{y}{x}}} \]
  8. Final simplification50.3%

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

Alternative 8: 54.4% 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.5%

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

    \[\leadsto \color{blue}{\frac{x}{y}} \]
  4. Final simplification50.2%

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

Developer target: 96.5% 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 2024020 
(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))))