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

Percentage Accurate: 85.3% → 90.9%
Time: 11.1s
Alternatives: 8
Speedup: 0.5×

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 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: 85.3% 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: 90.9% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.6 \cdot 10^{+188} \lor \neg \left(z \leq 6 \cdot 10^{+129}\right):\\
\;\;\;\;\frac{y - \frac{x}{z}}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.59999999999999987e188 or 6.0000000000000006e129 < z

    1. Initial program 52.8%

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

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

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

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

        \[\leadsto \color{blue}{-\frac{\left(\frac{x}{z} + \frac{t \cdot \left(x - y \cdot z\right)}{a \cdot {z}^{2}}\right) - y}{a}} \]
      2. associate--l+56.0%

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

        \[\leadsto -\frac{\frac{x}{z} + \left(\color{blue}{t \cdot \frac{x - y \cdot z}{a \cdot {z}^{2}}} - y\right)}{a} \]
    7. Simplified64.0%

      \[\leadsto \color{blue}{-\frac{\frac{x}{z} + \left(t \cdot \frac{x - y \cdot z}{a \cdot {z}^{2}} - y\right)}{a}} \]
    8. Taylor expanded in t around 0 88.2%

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

    if -2.59999999999999987e188 < z < 6.0000000000000006e129

    1. Initial program 97.4%

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

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

Alternative 2: 52.7% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := y \cdot \frac{z}{-t}\\ \mathbf{if}\;z \leq -1.3 \cdot 10^{+15}:\\ \;\;\;\;\frac{y}{a}\\ \mathbf{elif}\;z \leq -1.62 \cdot 10^{-127}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{-35}:\\ \;\;\;\;\frac{x}{t}\\ \mathbf{elif}\;z \leq 8 \cdot 10^{+44}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{+111}:\\ \;\;\;\;\frac{\frac{x}{a}}{-z}\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{+124}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (* y (/ z (- t)))))
   (if (<= z -1.3e+15)
     (/ y a)
     (if (<= z -1.62e-127)
       t_1
       (if (<= z 6.5e-35)
         (/ x t)
         (if (<= z 8e+44)
           t_1
           (if (<= z 3.3e+111)
             (/ (/ x a) (- z))
             (if (<= z 4.4e+124) t_1 (/ y a)))))))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = y * (z / -t);
	double tmp;
	if (z <= -1.3e+15) {
		tmp = y / a;
	} else if (z <= -1.62e-127) {
		tmp = t_1;
	} else if (z <= 6.5e-35) {
		tmp = x / t;
	} else if (z <= 8e+44) {
		tmp = t_1;
	} else if (z <= 3.3e+111) {
		tmp = (x / a) / -z;
	} else if (z <= 4.4e+124) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_1 = y * (z / -t)
    if (z <= (-1.3d+15)) then
        tmp = y / a
    else if (z <= (-1.62d-127)) then
        tmp = t_1
    else if (z <= 6.5d-35) then
        tmp = x / t
    else if (z <= 8d+44) then
        tmp = t_1
    else if (z <= 3.3d+111) then
        tmp = (x / a) / -z
    else if (z <= 4.4d+124) then
        tmp = t_1
    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 t_1 = y * (z / -t);
	double tmp;
	if (z <= -1.3e+15) {
		tmp = y / a;
	} else if (z <= -1.62e-127) {
		tmp = t_1;
	} else if (z <= 6.5e-35) {
		tmp = x / t;
	} else if (z <= 8e+44) {
		tmp = t_1;
	} else if (z <= 3.3e+111) {
		tmp = (x / a) / -z;
	} else if (z <= 4.4e+124) {
		tmp = t_1;
	} else {
		tmp = y / a;
	}
	return tmp;
}
def code(x, y, z, t, a):
	t_1 = y * (z / -t)
	tmp = 0
	if z <= -1.3e+15:
		tmp = y / a
	elif z <= -1.62e-127:
		tmp = t_1
	elif z <= 6.5e-35:
		tmp = x / t
	elif z <= 8e+44:
		tmp = t_1
	elif z <= 3.3e+111:
		tmp = (x / a) / -z
	elif z <= 4.4e+124:
		tmp = t_1
	else:
		tmp = y / a
	return tmp
function code(x, y, z, t, a)
	t_1 = Float64(y * Float64(z / Float64(-t)))
	tmp = 0.0
	if (z <= -1.3e+15)
		tmp = Float64(y / a);
	elseif (z <= -1.62e-127)
		tmp = t_1;
	elseif (z <= 6.5e-35)
		tmp = Float64(x / t);
	elseif (z <= 8e+44)
		tmp = t_1;
	elseif (z <= 3.3e+111)
		tmp = Float64(Float64(x / a) / Float64(-z));
	elseif (z <= 4.4e+124)
		tmp = t_1;
	else
		tmp = Float64(y / a);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = y * (z / -t);
	tmp = 0.0;
	if (z <= -1.3e+15)
		tmp = y / a;
	elseif (z <= -1.62e-127)
		tmp = t_1;
	elseif (z <= 6.5e-35)
		tmp = x / t;
	elseif (z <= 8e+44)
		tmp = t_1;
	elseif (z <= 3.3e+111)
		tmp = (x / a) / -z;
	elseif (z <= 4.4e+124)
		tmp = t_1;
	else
		tmp = y / a;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(z / (-t)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.3e+15], N[(y / a), $MachinePrecision], If[LessEqual[z, -1.62e-127], t$95$1, If[LessEqual[z, 6.5e-35], N[(x / t), $MachinePrecision], If[LessEqual[z, 8e+44], t$95$1, If[LessEqual[z, 3.3e+111], N[(N[(x / a), $MachinePrecision] / (-z)), $MachinePrecision], If[LessEqual[z, 4.4e+124], t$95$1, N[(y / a), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -1.62 \cdot 10^{-127}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;z \leq 8 \cdot 10^{+44}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 3.3 \cdot 10^{+111}:\\
\;\;\;\;\frac{\frac{x}{a}}{-z}\\

\mathbf{elif}\;z \leq 4.4 \cdot 10^{+124}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -1.3e15 or 4.4000000000000002e124 < z

    1. Initial program 69.8%

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

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

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

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

    if -1.3e15 < z < -1.61999999999999993e-127 or 6.4999999999999999e-35 < z < 8.0000000000000007e44 or 3.3000000000000001e111 < z < 4.4000000000000002e124

    1. Initial program 98.1%

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(y \cdot z\right)}}{t} \]
    7. Step-by-step derivation
      1. associate-*r*48.5%

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

        \[\leadsto \frac{\color{blue}{\left(-y\right)} \cdot z}{t} \]
    8. Simplified48.5%

      \[\leadsto \frac{\color{blue}{\left(-y\right) \cdot z}}{t} \]
    9. Taylor expanded in y around 0 48.5%

      \[\leadsto \color{blue}{-1 \cdot \frac{y \cdot z}{t}} \]
    10. Step-by-step derivation
      1. mul-1-neg48.5%

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

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

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

        \[\leadsto y \cdot \color{blue}{\frac{-z}{t}} \]
    11. Simplified50.1%

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

    if -1.61999999999999993e-127 < z < 6.4999999999999999e-35

    1. Initial program 99.8%

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

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

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

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

    if 8.0000000000000007e44 < z < 3.3000000000000001e111

    1. Initial program 92.4%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-\left(x - y \cdot z\right)}}{a \cdot z} \]
      3. neg-sub063.5%

        \[\leadsto \frac{\color{blue}{0 - \left(x - y \cdot z\right)}}{a \cdot z} \]
      4. sub-neg63.5%

        \[\leadsto \frac{0 - \color{blue}{\left(x + \left(-y \cdot z\right)\right)}}{a \cdot z} \]
      5. distribute-rgt-neg-out63.5%

        \[\leadsto \frac{0 - \left(x + \color{blue}{y \cdot \left(-z\right)}\right)}{a \cdot z} \]
      6. +-commutative63.5%

        \[\leadsto \frac{0 - \color{blue}{\left(y \cdot \left(-z\right) + x\right)}}{a \cdot z} \]
      7. associate--r+63.5%

        \[\leadsto \frac{\color{blue}{\left(0 - y \cdot \left(-z\right)\right) - x}}{a \cdot z} \]
      8. neg-sub063.5%

        \[\leadsto \frac{\color{blue}{\left(-y \cdot \left(-z\right)\right)} - x}{a \cdot z} \]
      9. distribute-rgt-neg-out63.5%

        \[\leadsto \frac{\left(-\color{blue}{\left(-y \cdot z\right)}\right) - x}{a \cdot z} \]
      10. remove-double-neg63.5%

        \[\leadsto \frac{\color{blue}{y \cdot z} - x}{a \cdot z} \]
      11. *-commutative63.5%

        \[\leadsto \frac{y \cdot z - x}{\color{blue}{z \cdot a}} \]
    7. Simplified63.5%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{a \cdot z}} \]
    9. Step-by-step derivation
      1. mul-1-neg55.0%

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

        \[\leadsto -\color{blue}{\frac{\frac{x}{a}}{z}} \]
      3. distribute-neg-frac255.0%

        \[\leadsto \color{blue}{\frac{\frac{x}{a}}{-z}} \]
    10. Simplified55.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.3 \cdot 10^{+15}:\\ \;\;\;\;\frac{y}{a}\\ \mathbf{elif}\;z \leq -1.62 \cdot 10^{-127}:\\ \;\;\;\;y \cdot \frac{z}{-t}\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{-35}:\\ \;\;\;\;\frac{x}{t}\\ \mathbf{elif}\;z \leq 8 \cdot 10^{+44}:\\ \;\;\;\;y \cdot \frac{z}{-t}\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{+111}:\\ \;\;\;\;\frac{\frac{x}{a}}{-z}\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{+124}:\\ \;\;\;\;y \cdot \frac{z}{-t}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 52.9% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := y \cdot \frac{z}{-t}\\ \mathbf{if}\;z \leq -4.4 \cdot 10^{+14}:\\ \;\;\;\;\frac{y}{a}\\ \mathbf{elif}\;z \leq -1.62 \cdot 10^{-127}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{-39}:\\ \;\;\;\;\frac{x}{t}\\ \mathbf{elif}\;z \leq 1.66 \cdot 10^{+47}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 1.16 \cdot 10^{+114}:\\ \;\;\;\;\frac{\frac{x}{z}}{-a}\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{+125}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (* y (/ z (- t)))))
   (if (<= z -4.4e+14)
     (/ y a)
     (if (<= z -1.62e-127)
       t_1
       (if (<= z 1.55e-39)
         (/ x t)
         (if (<= z 1.66e+47)
           t_1
           (if (<= z 1.16e+114)
             (/ (/ x z) (- a))
             (if (<= z 1.45e+125) t_1 (/ y a)))))))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = y * (z / -t);
	double tmp;
	if (z <= -4.4e+14) {
		tmp = y / a;
	} else if (z <= -1.62e-127) {
		tmp = t_1;
	} else if (z <= 1.55e-39) {
		tmp = x / t;
	} else if (z <= 1.66e+47) {
		tmp = t_1;
	} else if (z <= 1.16e+114) {
		tmp = (x / z) / -a;
	} else if (z <= 1.45e+125) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_1 = y * (z / -t)
    if (z <= (-4.4d+14)) then
        tmp = y / a
    else if (z <= (-1.62d-127)) then
        tmp = t_1
    else if (z <= 1.55d-39) then
        tmp = x / t
    else if (z <= 1.66d+47) then
        tmp = t_1
    else if (z <= 1.16d+114) then
        tmp = (x / z) / -a
    else if (z <= 1.45d+125) then
        tmp = t_1
    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 t_1 = y * (z / -t);
	double tmp;
	if (z <= -4.4e+14) {
		tmp = y / a;
	} else if (z <= -1.62e-127) {
		tmp = t_1;
	} else if (z <= 1.55e-39) {
		tmp = x / t;
	} else if (z <= 1.66e+47) {
		tmp = t_1;
	} else if (z <= 1.16e+114) {
		tmp = (x / z) / -a;
	} else if (z <= 1.45e+125) {
		tmp = t_1;
	} else {
		tmp = y / a;
	}
	return tmp;
}
def code(x, y, z, t, a):
	t_1 = y * (z / -t)
	tmp = 0
	if z <= -4.4e+14:
		tmp = y / a
	elif z <= -1.62e-127:
		tmp = t_1
	elif z <= 1.55e-39:
		tmp = x / t
	elif z <= 1.66e+47:
		tmp = t_1
	elif z <= 1.16e+114:
		tmp = (x / z) / -a
	elif z <= 1.45e+125:
		tmp = t_1
	else:
		tmp = y / a
	return tmp
function code(x, y, z, t, a)
	t_1 = Float64(y * Float64(z / Float64(-t)))
	tmp = 0.0
	if (z <= -4.4e+14)
		tmp = Float64(y / a);
	elseif (z <= -1.62e-127)
		tmp = t_1;
	elseif (z <= 1.55e-39)
		tmp = Float64(x / t);
	elseif (z <= 1.66e+47)
		tmp = t_1;
	elseif (z <= 1.16e+114)
		tmp = Float64(Float64(x / z) / Float64(-a));
	elseif (z <= 1.45e+125)
		tmp = t_1;
	else
		tmp = Float64(y / a);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = y * (z / -t);
	tmp = 0.0;
	if (z <= -4.4e+14)
		tmp = y / a;
	elseif (z <= -1.62e-127)
		tmp = t_1;
	elseif (z <= 1.55e-39)
		tmp = x / t;
	elseif (z <= 1.66e+47)
		tmp = t_1;
	elseif (z <= 1.16e+114)
		tmp = (x / z) / -a;
	elseif (z <= 1.45e+125)
		tmp = t_1;
	else
		tmp = y / a;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(z / (-t)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.4e+14], N[(y / a), $MachinePrecision], If[LessEqual[z, -1.62e-127], t$95$1, If[LessEqual[z, 1.55e-39], N[(x / t), $MachinePrecision], If[LessEqual[z, 1.66e+47], t$95$1, If[LessEqual[z, 1.16e+114], N[(N[(x / z), $MachinePrecision] / (-a)), $MachinePrecision], If[LessEqual[z, 1.45e+125], t$95$1, N[(y / a), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -1.62 \cdot 10^{-127}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 1.55 \cdot 10^{-39}:\\
\;\;\;\;\frac{x}{t}\\

\mathbf{elif}\;z \leq 1.66 \cdot 10^{+47}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 1.16 \cdot 10^{+114}:\\
\;\;\;\;\frac{\frac{x}{z}}{-a}\\

\mathbf{elif}\;z \leq 1.45 \cdot 10^{+125}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -4.4e14 or 1.44999999999999997e125 < z

    1. Initial program 69.8%

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

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

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

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

    if -4.4e14 < z < -1.61999999999999993e-127 or 1.54999999999999985e-39 < z < 1.6599999999999999e47 or 1.15999999999999994e114 < z < 1.44999999999999997e125

    1. Initial program 98.1%

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(y \cdot z\right)}}{t} \]
    7. Step-by-step derivation
      1. associate-*r*48.5%

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

        \[\leadsto \frac{\color{blue}{\left(-y\right)} \cdot z}{t} \]
    8. Simplified48.5%

      \[\leadsto \frac{\color{blue}{\left(-y\right) \cdot z}}{t} \]
    9. Taylor expanded in y around 0 48.5%

      \[\leadsto \color{blue}{-1 \cdot \frac{y \cdot z}{t}} \]
    10. Step-by-step derivation
      1. mul-1-neg48.5%

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

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

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

        \[\leadsto y \cdot \color{blue}{\frac{-z}{t}} \]
    11. Simplified50.1%

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

    if -1.61999999999999993e-127 < z < 1.54999999999999985e-39

    1. Initial program 99.8%

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

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

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

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

    if 1.6599999999999999e47 < z < 1.15999999999999994e114

    1. Initial program 92.4%

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

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

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

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

        \[\leadsto \color{blue}{-\frac{\left(\frac{x}{z} + \frac{t \cdot \left(x - y \cdot z\right)}{a \cdot {z}^{2}}\right) - y}{a}} \]
      2. associate--l+61.7%

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

        \[\leadsto -\frac{\frac{x}{z} + \left(\color{blue}{t \cdot \frac{x - y \cdot z}{a \cdot {z}^{2}}} - y\right)}{a} \]
    7. Simplified61.7%

      \[\leadsto \color{blue}{-\frac{\frac{x}{z} + \left(t \cdot \frac{x - y \cdot z}{a \cdot {z}^{2}} - y\right)}{a}} \]
    8. Taylor expanded in t around 0 63.5%

      \[\leadsto -\frac{\color{blue}{\frac{x}{z} - y}}{a} \]
    9. Taylor expanded in x around inf 55.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.4 \cdot 10^{+14}:\\ \;\;\;\;\frac{y}{a}\\ \mathbf{elif}\;z \leq -1.62 \cdot 10^{-127}:\\ \;\;\;\;y \cdot \frac{z}{-t}\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{-39}:\\ \;\;\;\;\frac{x}{t}\\ \mathbf{elif}\;z \leq 1.66 \cdot 10^{+47}:\\ \;\;\;\;y \cdot \frac{z}{-t}\\ \mathbf{elif}\;z \leq 1.16 \cdot 10^{+114}:\\ \;\;\;\;\frac{\frac{x}{z}}{-a}\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{+125}:\\ \;\;\;\;y \cdot \frac{z}{-t}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 61.0% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.6 \cdot 10^{+57}:\\
\;\;\;\;\frac{y}{a}\\

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

\mathbf{elif}\;a \leq 2.8 \cdot 10^{+142} \lor \neg \left(a \leq 9.4 \cdot 10^{+194}\right):\\
\;\;\;\;\frac{x}{t - z \cdot a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -4.5999999999999998e57 or 2.8e142 < a < 9.39999999999999945e194

    1. Initial program 72.9%

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

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

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

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

    if -4.5999999999999998e57 < a < 1.3999999999999999e-17

    1. Initial program 96.4%

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

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

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

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

    if 1.3999999999999999e-17 < a < 2.8e142 or 9.39999999999999945e194 < a

    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. Add Preprocessing
    5. Taylor expanded in x around inf 65.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -4.6 \cdot 10^{+57}:\\ \;\;\;\;\frac{y}{a}\\ \mathbf{elif}\;a \leq 1.4 \cdot 10^{-17}:\\ \;\;\;\;\frac{x - z \cdot y}{t}\\ \mathbf{elif}\;a \leq 2.8 \cdot 10^{+142} \lor \neg \left(a \leq 9.4 \cdot 10^{+194}\right):\\ \;\;\;\;\frac{x}{t - z \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 64.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{x}{t - z \cdot a}\\ \mathbf{if}\;z \leq -1.7 \cdot 10^{+97}:\\ \;\;\;\;\frac{y}{a}\\ \mathbf{elif}\;z \leq 2.15 \cdot 10^{-33}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+41}:\\ \;\;\;\;y \cdot \frac{z}{-t}\\ \mathbf{elif}\;z \leq 7.8 \cdot 10^{+127}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (/ x (- t (* z a)))))
   (if (<= z -1.7e+97)
     (/ y a)
     (if (<= z 2.15e-33)
       t_1
       (if (<= z 2e+41) (* y (/ z (- t))) (if (<= z 7.8e+127) t_1 (/ y a)))))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = x / (t - (z * a));
	double tmp;
	if (z <= -1.7e+97) {
		tmp = y / a;
	} else if (z <= 2.15e-33) {
		tmp = t_1;
	} else if (z <= 2e+41) {
		tmp = y * (z / -t);
	} else if (z <= 7.8e+127) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_1 = x / (t - (z * a))
    if (z <= (-1.7d+97)) then
        tmp = y / a
    else if (z <= 2.15d-33) then
        tmp = t_1
    else if (z <= 2d+41) then
        tmp = y * (z / -t)
    else if (z <= 7.8d+127) then
        tmp = t_1
    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 t_1 = x / (t - (z * a));
	double tmp;
	if (z <= -1.7e+97) {
		tmp = y / a;
	} else if (z <= 2.15e-33) {
		tmp = t_1;
	} else if (z <= 2e+41) {
		tmp = y * (z / -t);
	} else if (z <= 7.8e+127) {
		tmp = t_1;
	} else {
		tmp = y / a;
	}
	return tmp;
}
def code(x, y, z, t, a):
	t_1 = x / (t - (z * a))
	tmp = 0
	if z <= -1.7e+97:
		tmp = y / a
	elif z <= 2.15e-33:
		tmp = t_1
	elif z <= 2e+41:
		tmp = y * (z / -t)
	elif z <= 7.8e+127:
		tmp = t_1
	else:
		tmp = y / a
	return tmp
function code(x, y, z, t, a)
	t_1 = Float64(x / Float64(t - Float64(z * a)))
	tmp = 0.0
	if (z <= -1.7e+97)
		tmp = Float64(y / a);
	elseif (z <= 2.15e-33)
		tmp = t_1;
	elseif (z <= 2e+41)
		tmp = Float64(y * Float64(z / Float64(-t)));
	elseif (z <= 7.8e+127)
		tmp = t_1;
	else
		tmp = Float64(y / a);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = x / (t - (z * a));
	tmp = 0.0;
	if (z <= -1.7e+97)
		tmp = y / a;
	elseif (z <= 2.15e-33)
		tmp = t_1;
	elseif (z <= 2e+41)
		tmp = y * (z / -t);
	elseif (z <= 7.8e+127)
		tmp = t_1;
	else
		tmp = y / a;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x / N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.7e+97], N[(y / a), $MachinePrecision], If[LessEqual[z, 2.15e-33], t$95$1, If[LessEqual[z, 2e+41], N[(y * N[(z / (-t)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 7.8e+127], t$95$1, N[(y / a), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 2.15 \cdot 10^{-33}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 2 \cdot 10^{+41}:\\
\;\;\;\;y \cdot \frac{z}{-t}\\

\mathbf{elif}\;z \leq 7.8 \cdot 10^{+127}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.70000000000000005e97 or 7.79999999999999962e127 < z

    1. Initial program 63.1%

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

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

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

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

    if -1.70000000000000005e97 < z < 2.15000000000000015e-33 or 2.00000000000000001e41 < z < 7.79999999999999962e127

    1. Initial program 98.6%

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

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

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

      \[\leadsto \color{blue}{\frac{x}{t - a \cdot z}} \]
    6. Step-by-step derivation
      1. *-commutative67.0%

        \[\leadsto \frac{x}{t - \color{blue}{z \cdot a}} \]
    7. Simplified67.0%

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

    if 2.15000000000000015e-33 < z < 2.00000000000000001e41

    1. Initial program 99.3%

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(y \cdot z\right)}}{t} \]
    7. Step-by-step derivation
      1. associate-*r*57.2%

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

        \[\leadsto \frac{\color{blue}{\left(-y\right)} \cdot z}{t} \]
    8. Simplified57.2%

      \[\leadsto \frac{\color{blue}{\left(-y\right) \cdot z}}{t} \]
    9. Taylor expanded in y around 0 57.2%

      \[\leadsto \color{blue}{-1 \cdot \frac{y \cdot z}{t}} \]
    10. Step-by-step derivation
      1. mul-1-neg57.2%

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

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

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

        \[\leadsto y \cdot \color{blue}{\frac{-z}{t}} \]
    11. Simplified57.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.7 \cdot 10^{+97}:\\ \;\;\;\;\frac{y}{a}\\ \mathbf{elif}\;z \leq 2.15 \cdot 10^{-33}:\\ \;\;\;\;\frac{x}{t - z \cdot a}\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+41}:\\ \;\;\;\;y \cdot \frac{z}{-t}\\ \mathbf{elif}\;z \leq 7.8 \cdot 10^{+127}:\\ \;\;\;\;\frac{x}{t - z \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 68.8% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -7.5 \cdot 10^{+49} \lor \neg \left(a \leq 8000000\right):\\
\;\;\;\;\frac{y - \frac{x}{z}}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -7.4999999999999995e49 or 8e6 < a

    1. Initial program 78.5%

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

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

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

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

        \[\leadsto \color{blue}{-\frac{\left(\frac{x}{z} + \frac{t \cdot \left(x - y \cdot z\right)}{a \cdot {z}^{2}}\right) - y}{a}} \]
      2. associate--l+46.6%

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

        \[\leadsto -\frac{\frac{x}{z} + \left(\color{blue}{t \cdot \frac{x - y \cdot z}{a \cdot {z}^{2}}} - y\right)}{a} \]
    7. Simplified53.8%

      \[\leadsto \color{blue}{-\frac{\frac{x}{z} + \left(t \cdot \frac{x - y \cdot z}{a \cdot {z}^{2}} - y\right)}{a}} \]
    8. Taylor expanded in t around 0 72.9%

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

    if -7.4999999999999995e49 < a < 8e6

    1. Initial program 96.5%

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

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

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

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

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

Alternative 7: 55.6% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -62000000000000 \lor \neg \left(z \leq 1.45 \cdot 10^{-6}\right):\\
\;\;\;\;\frac{y}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -6.2e13 or 1.4500000000000001e-6 < z

    1. Initial program 75.7%

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

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

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

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

    if -6.2e13 < z < 1.4500000000000001e-6

    1. Initial program 99.8%

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

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

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

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

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

Alternative 8: 35.6% 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 88.7%

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

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

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

    \[\leadsto \color{blue}{\frac{x}{t}} \]
  6. Add Preprocessing

Developer target: 97.4% accurate, 0.4× 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 2024089 
(FPCore (x y z t a)
  :name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, A"
  :precision binary64

  :alt
  (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))))