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

Percentage Accurate: 85.9% → 91.2%
Time: 9.9s
Alternatives: 6
Speedup: 0.7×

Specification

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

\\
\frac{x - y \cdot z}{t - a \cdot z}
\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 6 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: 85.9% accurate, 1.0× speedup?

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

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

Alternative 1: 91.2% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.9 \cdot 10^{+117} \lor \neg \left(z \leq 1.25 \cdot 10^{+87}\right):\\
\;\;\;\;\frac{y}{a - \frac{t}{z}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -9.9000000000000005e117 or 1.24999999999999995e87 < z

    1. Initial program 58.6%

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

        \[\leadsto \frac{x - y \cdot z}{t - \color{blue}{z \cdot a}} \]
    3. Simplified58.6%

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(y \cdot z\right)}{t - a \cdot z}} \]
      2. mul-1-neg47.0%

        \[\leadsto \frac{\color{blue}{-y \cdot z}}{t - a \cdot z} \]
      3. distribute-rgt-neg-out47.0%

        \[\leadsto \frac{\color{blue}{y \cdot \left(-z\right)}}{t - a \cdot z} \]
      4. *-commutative47.0%

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

        \[\leadsto \color{blue}{\frac{y}{\frac{t - z \cdot a}{-z}}} \]
    6. Simplified63.9%

      \[\leadsto \color{blue}{\frac{y}{\frac{t - z \cdot a}{-z}}} \]
    7. Taylor expanded in t around 0 86.0%

      \[\leadsto \frac{y}{\color{blue}{a + -1 \cdot \frac{t}{z}}} \]
    8. Step-by-step derivation
      1. mul-1-neg86.0%

        \[\leadsto \frac{y}{a + \color{blue}{\left(-\frac{t}{z}\right)}} \]
      2. unsub-neg86.0%

        \[\leadsto \frac{y}{\color{blue}{a - \frac{t}{z}}} \]
    9. Simplified86.0%

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

    if -9.9000000000000005e117 < z < 1.24999999999999995e87

    1. Initial program 98.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -9.9 \cdot 10^{+117} \lor \neg \left(z \leq 1.25 \cdot 10^{+87}\right):\\ \;\;\;\;\frac{y}{a - \frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - z \cdot y}{t - z \cdot a}\\ \end{array} \]

Alternative 2: 71.8% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{y}{a - \frac{t}{z}}\\ \mathbf{if}\;z \leq -1.15 \cdot 10^{+49}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6.8 \cdot 10^{-166}:\\ \;\;\;\;\frac{x}{t - z \cdot a}\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+65}:\\ \;\;\;\;\frac{x - z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (/ y (- a (/ t z)))))
   (if (<= z -1.15e+49)
     t_1
     (if (<= z 6.8e-166)
       (/ x (- t (* z a)))
       (if (<= z 6.5e+65) (/ (- x (* z y)) t) t_1)))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = y / (a - (t / z));
	double tmp;
	if (z <= -1.15e+49) {
		tmp = t_1;
	} else if (z <= 6.8e-166) {
		tmp = x / (t - (z * a));
	} else if (z <= 6.5e+65) {
		tmp = (x - (z * y)) / t;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8) :: t_1
    real(8) :: tmp
    t_1 = y / (a - (t / z))
    if (z <= (-1.15d+49)) then
        tmp = t_1
    else if (z <= 6.8d-166) then
        tmp = x / (t - (z * a))
    else if (z <= 6.5d+65) then
        tmp = (x - (z * y)) / t
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = y / (a - (t / z));
	double tmp;
	if (z <= -1.15e+49) {
		tmp = t_1;
	} else if (z <= 6.8e-166) {
		tmp = x / (t - (z * a));
	} else if (z <= 6.5e+65) {
		tmp = (x - (z * y)) / t;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t, a):
	t_1 = y / (a - (t / z))
	tmp = 0
	if z <= -1.15e+49:
		tmp = t_1
	elif z <= 6.8e-166:
		tmp = x / (t - (z * a))
	elif z <= 6.5e+65:
		tmp = (x - (z * y)) / t
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t, a)
	t_1 = Float64(y / Float64(a - Float64(t / z)))
	tmp = 0.0
	if (z <= -1.15e+49)
		tmp = t_1;
	elseif (z <= 6.8e-166)
		tmp = Float64(x / Float64(t - Float64(z * a)));
	elseif (z <= 6.5e+65)
		tmp = Float64(Float64(x - Float64(z * y)) / t);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = y / (a - (t / z));
	tmp = 0.0;
	if (z <= -1.15e+49)
		tmp = t_1;
	elseif (z <= 6.8e-166)
		tmp = x / (t - (z * a));
	elseif (z <= 6.5e+65)
		tmp = (x - (z * y)) / t;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y / N[(a - N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.15e+49], t$95$1, If[LessEqual[z, 6.8e-166], N[(x / N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.5e+65], N[(N[(x - N[(z * y), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{y}{a - \frac{t}{z}}\\
\mathbf{if}\;z \leq -1.15 \cdot 10^{+49}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 6.8 \cdot 10^{-166}:\\
\;\;\;\;\frac{x}{t - z \cdot a}\\

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

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.15000000000000001e49 or 6.5000000000000003e65 < z

    1. Initial program 63.8%

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

        \[\leadsto \frac{x - y \cdot z}{t - \color{blue}{z \cdot a}} \]
    3. Simplified63.8%

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(y \cdot z\right)}{t - a \cdot z}} \]
      2. mul-1-neg50.1%

        \[\leadsto \frac{\color{blue}{-y \cdot z}}{t - a \cdot z} \]
      3. distribute-rgt-neg-out50.1%

        \[\leadsto \frac{\color{blue}{y \cdot \left(-z\right)}}{t - a \cdot z} \]
      4. *-commutative50.1%

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

        \[\leadsto \color{blue}{\frac{y}{\frac{t - z \cdot a}{-z}}} \]
    6. Simplified65.4%

      \[\leadsto \color{blue}{\frac{y}{\frac{t - z \cdot a}{-z}}} \]
    7. Taylor expanded in t around 0 84.2%

      \[\leadsto \frac{y}{\color{blue}{a + -1 \cdot \frac{t}{z}}} \]
    8. Step-by-step derivation
      1. mul-1-neg84.2%

        \[\leadsto \frac{y}{a + \color{blue}{\left(-\frac{t}{z}\right)}} \]
      2. unsub-neg84.2%

        \[\leadsto \frac{y}{\color{blue}{a - \frac{t}{z}}} \]
    9. Simplified84.2%

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

    if -1.15000000000000001e49 < z < 6.7999999999999995e-166

    1. Initial program 98.9%

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

        \[\leadsto \frac{x - y \cdot z}{t - \color{blue}{z \cdot a}} \]
    3. Simplified98.9%

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

      \[\leadsto \color{blue}{\frac{x}{t - a \cdot z}} \]
    5. Step-by-step derivation
      1. *-commutative76.3%

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

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

    if 6.7999999999999995e-166 < z < 6.5000000000000003e65

    1. Initial program 99.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.15 \cdot 10^{+49}:\\ \;\;\;\;\frac{y}{a - \frac{t}{z}}\\ \mathbf{elif}\;z \leq 6.8 \cdot 10^{-166}:\\ \;\;\;\;\frac{x}{t - z \cdot a}\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+65}:\\ \;\;\;\;\frac{x - z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a - \frac{t}{z}}\\ \end{array} \]

Alternative 3: 65.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.52 \cdot 10^{+85} \lor \neg \left(z \leq 1.8 \cdot 10^{+68}\right):\\
\;\;\;\;\frac{y}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.52e85 or 1.7999999999999999e68 < z

    1. Initial program 62.9%

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

        \[\leadsto \frac{x - y \cdot z}{t - \color{blue}{z \cdot a}} \]
    3. Simplified62.9%

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

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

    if -1.52e85 < z < 1.7999999999999999e68

    1. Initial program 98.7%

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

        \[\leadsto \frac{x - y \cdot z}{t - \color{blue}{z \cdot a}} \]
    3. Simplified98.7%

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

      \[\leadsto \color{blue}{\frac{x}{t - a \cdot z}} \]
    5. Step-by-step derivation
      1. *-commutative72.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.52 \cdot 10^{+85} \lor \neg \left(z \leq 1.8 \cdot 10^{+68}\right):\\ \;\;\;\;\frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t - z \cdot a}\\ \end{array} \]

Alternative 4: 72.4% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.35 \cdot 10^{+49} \lor \neg \left(z \leq 1.52 \cdot 10^{+66}\right):\\
\;\;\;\;\frac{y}{a - \frac{t}{z}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.35000000000000005e49 or 1.52000000000000004e66 < z

    1. Initial program 63.8%

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

        \[\leadsto \frac{x - y \cdot z}{t - \color{blue}{z \cdot a}} \]
    3. Simplified63.8%

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(y \cdot z\right)}{t - a \cdot z}} \]
      2. mul-1-neg50.1%

        \[\leadsto \frac{\color{blue}{-y \cdot z}}{t - a \cdot z} \]
      3. distribute-rgt-neg-out50.1%

        \[\leadsto \frac{\color{blue}{y \cdot \left(-z\right)}}{t - a \cdot z} \]
      4. *-commutative50.1%

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

        \[\leadsto \color{blue}{\frac{y}{\frac{t - z \cdot a}{-z}}} \]
    6. Simplified65.4%

      \[\leadsto \color{blue}{\frac{y}{\frac{t - z \cdot a}{-z}}} \]
    7. Taylor expanded in t around 0 84.2%

      \[\leadsto \frac{y}{\color{blue}{a + -1 \cdot \frac{t}{z}}} \]
    8. Step-by-step derivation
      1. mul-1-neg84.2%

        \[\leadsto \frac{y}{a + \color{blue}{\left(-\frac{t}{z}\right)}} \]
      2. unsub-neg84.2%

        \[\leadsto \frac{y}{\color{blue}{a - \frac{t}{z}}} \]
    9. Simplified84.2%

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

    if -1.35000000000000005e49 < z < 1.52000000000000004e66

    1. Initial program 99.2%

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

        \[\leadsto \frac{x - y \cdot z}{t - \color{blue}{z \cdot a}} \]
    3. Simplified99.2%

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

      \[\leadsto \color{blue}{\frac{x}{t - a \cdot z}} \]
    5. Step-by-step derivation
      1. *-commutative73.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.35 \cdot 10^{+49} \lor \neg \left(z \leq 1.52 \cdot 10^{+66}\right):\\ \;\;\;\;\frac{y}{a - \frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t - z \cdot a}\\ \end{array} \]

Alternative 5: 53.5% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2.55 \cdot 10^{+85}:\\ \;\;\;\;\frac{y}{a}\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+65}:\\ \;\;\;\;\frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (if (<= z -2.55e+85) (/ y a) (if (<= z 6.5e+65) (/ x t) (/ y a))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (z <= -2.55e+85) {
		tmp = y / a;
	} else if (z <= 6.5e+65) {
		tmp = x / t;
	} else {
		tmp = y / a;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8) :: tmp
    if (z <= (-2.55d+85)) then
        tmp = y / a
    else if (z <= 6.5d+65) then
        tmp = x / t
    else
        tmp = y / a
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (z <= -2.55e+85) {
		tmp = y / a;
	} else if (z <= 6.5e+65) {
		tmp = x / t;
	} else {
		tmp = y / a;
	}
	return tmp;
}
def code(x, y, z, t, a):
	tmp = 0
	if z <= -2.55e+85:
		tmp = y / a
	elif z <= 6.5e+65:
		tmp = x / t
	else:
		tmp = y / a
	return tmp
function code(x, y, z, t, a)
	tmp = 0.0
	if (z <= -2.55e+85)
		tmp = Float64(y / a);
	elseif (z <= 6.5e+65)
		tmp = Float64(x / t);
	else
		tmp = Float64(y / a);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if (z <= -2.55e+85)
		tmp = y / a;
	elseif (z <= 6.5e+65)
		tmp = x / t;
	else
		tmp = y / a;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -2.55e+85], N[(y / a), $MachinePrecision], If[LessEqual[z, 6.5e+65], N[(x / t), $MachinePrecision], N[(y / a), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.55 \cdot 10^{+85}:\\
\;\;\;\;\frac{y}{a}\\

\mathbf{elif}\;z \leq 6.5 \cdot 10^{+65}:\\
\;\;\;\;\frac{x}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.5499999999999999e85 or 6.5000000000000003e65 < z

    1. Initial program 62.9%

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

        \[\leadsto \frac{x - y \cdot z}{t - \color{blue}{z \cdot a}} \]
    3. Simplified62.9%

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

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

    if -2.5499999999999999e85 < z < 6.5000000000000003e65

    1. Initial program 98.7%

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

        \[\leadsto \frac{x - y \cdot z}{t - \color{blue}{z \cdot a}} \]
    3. Simplified98.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.55 \cdot 10^{+85}:\\ \;\;\;\;\frac{y}{a}\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+65}:\\ \;\;\;\;\frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a}\\ \end{array} \]

Alternative 6: 35.7% accurate, 3.7× speedup?

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

\\
\frac{x}{t}
\end{array}
Derivation
  1. Initial program 85.2%

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

      \[\leadsto \frac{x - y \cdot z}{t - \color{blue}{z \cdot a}} \]
  3. Simplified85.2%

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

    \[\leadsto \color{blue}{\frac{x}{t}} \]
  5. Final simplification39.5%

    \[\leadsto \frac{x}{t} \]

Developer target: 97.7% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_1 := t - a \cdot z\\
t_2 := \frac{x}{t_1} - \frac{y}{\frac{t}{z} - a}\\
\mathbf{if}\;z < -32113435955957344:\\
\;\;\;\;t_2\\

\mathbf{elif}\;z < 3.5139522372978296 \cdot 10^{-86}:\\
\;\;\;\;\left(x - y \cdot z\right) \cdot \frac{1}{t_1}\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}
\end{array}

Reproduce

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

  :herbie-target
  (if (< z -32113435955957344.0) (- (/ x (- t (* a z))) (/ y (- (/ t z) a))) (if (< z 3.5139522372978296e-86) (* (- x (* y z)) (/ 1.0 (- t (* a z)))) (- (/ x (- t (* a z))) (/ y (- (/ t z) a)))))

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