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

Percentage Accurate: 84.6% → 93.7%
Time: 15.3s
Alternatives: 10
Speedup: 0.2×

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 10 alternatives:

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

Initial Program: 84.6% 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: 93.7% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(z, -a, t\right)\\ t_2 := \mathsf{fma}\left(-1, y \cdot \frac{z}{t\_1}, \frac{x}{t\_1}\right)\\ t_3 := \frac{x - y \cdot z}{t - z \cdot a}\\ \mathbf{if}\;t\_3 \leq -2 \cdot 10^{-293}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_3 \leq 0:\\ \;\;\;\;\frac{y - \frac{x}{z}}{a}\\ \mathbf{elif}\;t\_3 \leq \infty:\\ \;\;\;\;t\_2\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (fma z (- a) t))
        (t_2 (fma -1.0 (* y (/ z t_1)) (/ x t_1)))
        (t_3 (/ (- x (* y z)) (- t (* z a)))))
   (if (<= t_3 -2e-293)
     t_2
     (if (<= t_3 0.0)
       (/ (- y (/ x z)) a)
       (if (<= t_3 INFINITY) t_2 (/ y a))))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = fma(z, -a, t);
	double t_2 = fma(-1.0, (y * (z / t_1)), (x / t_1));
	double t_3 = (x - (y * z)) / (t - (z * a));
	double tmp;
	if (t_3 <= -2e-293) {
		tmp = t_2;
	} else if (t_3 <= 0.0) {
		tmp = (y - (x / z)) / a;
	} else if (t_3 <= ((double) INFINITY)) {
		tmp = t_2;
	} else {
		tmp = y / a;
	}
	return tmp;
}
function code(x, y, z, t, a)
	t_1 = fma(z, Float64(-a), t)
	t_2 = fma(-1.0, Float64(y * Float64(z / t_1)), Float64(x / t_1))
	t_3 = Float64(Float64(x - Float64(y * z)) / Float64(t - Float64(z * a)))
	tmp = 0.0
	if (t_3 <= -2e-293)
		tmp = t_2;
	elseif (t_3 <= 0.0)
		tmp = Float64(Float64(y - Float64(x / z)) / a);
	elseif (t_3 <= Inf)
		tmp = t_2;
	else
		tmp = Float64(y / a);
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(z * (-a) + t), $MachinePrecision]}, Block[{t$95$2 = N[(-1.0 * N[(y * N[(z / t$95$1), $MachinePrecision]), $MachinePrecision] + N[(x / t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -2e-293], t$95$2, If[LessEqual[t$95$3, 0.0], N[(N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[t$95$3, Infinity], t$95$2, N[(y / a), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(z, -a, t\right)\\
t_2 := \mathsf{fma}\left(-1, y \cdot \frac{z}{t\_1}, \frac{x}{t\_1}\right)\\
t_3 := \frac{x - y \cdot z}{t - z \cdot a}\\
\mathbf{if}\;t\_3 \leq -2 \cdot 10^{-293}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_3 \leq 0:\\
\;\;\;\;\frac{y - \frac{x}{z}}{a}\\

\mathbf{elif}\;t\_3 \leq \infty:\\
\;\;\;\;t\_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -2.0000000000000001e-293 or -0.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < +inf.0

    1. Initial program 94.0%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-1, \color{blue}{y \cdot \frac{z}{t - a \cdot z}}, \frac{x}{t - a \cdot z}\right) \]
      3. cancel-sign-sub-inv97.6%

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

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

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

        \[\leadsto \mathsf{fma}\left(-1, y \cdot \frac{z}{\color{blue}{\mathsf{fma}\left(z, -a, t\right)}}, \frac{x}{t - a \cdot z}\right) \]
      7. cancel-sign-sub-inv97.6%

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

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

        \[\leadsto \mathsf{fma}\left(-1, y \cdot \frac{z}{\mathsf{fma}\left(z, -a, t\right)}, \frac{x}{\color{blue}{z \cdot \left(-a\right) + t}}\right) \]
      10. fma-define97.6%

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

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

    if -2.0000000000000001e-293 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -0.0

    1. Initial program 52.2%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-1, \color{blue}{y \cdot \frac{z}{t - a \cdot z}}, \frac{x}{t - a \cdot z}\right) \]
      3. cancel-sign-sub-inv52.2%

        \[\leadsto \mathsf{fma}\left(-1, y \cdot \frac{z}{\color{blue}{t + \left(-a\right) \cdot z}}, \frac{x}{t - a \cdot z}\right) \]
      4. *-commutative52.2%

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

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

        \[\leadsto \mathsf{fma}\left(-1, y \cdot \frac{z}{\color{blue}{\mathsf{fma}\left(z, -a, t\right)}}, \frac{x}{t - a \cdot z}\right) \]
      7. cancel-sign-sub-inv52.2%

        \[\leadsto \mathsf{fma}\left(-1, y \cdot \frac{z}{\mathsf{fma}\left(z, -a, t\right)}, \frac{x}{\color{blue}{t + \left(-a\right) \cdot z}}\right) \]
      8. *-commutative52.2%

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

        \[\leadsto \mathsf{fma}\left(-1, y \cdot \frac{z}{\mathsf{fma}\left(z, -a, t\right)}, \frac{x}{\color{blue}{z \cdot \left(-a\right) + t}}\right) \]
      10. fma-define52.2%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-1, y \cdot \frac{z}{\mathsf{fma}\left(z, -a, t\right)}, \frac{x}{\mathsf{fma}\left(z, -a, t\right)}\right)} \]
    8. Taylor expanded in a around inf 88.2%

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

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

        \[\leadsto \frac{\color{blue}{y - \frac{x}{z}}}{a} \]
    10. Simplified88.2%

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

    if +inf.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z)))

    1. Initial program 0.0%

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

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

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

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

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

Alternative 2: 90.2% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{x - y \cdot z}{t - z \cdot a}\\ \mathbf{if}\;t\_1 \leq -2 \cdot 10^{-293}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_1 \leq 0:\\ \;\;\;\;\frac{y - \frac{x}{z}}{a}\\ \mathbf{elif}\;t\_1 \leq \infty:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (/ (- x (* y z)) (- t (* z a)))))
   (if (<= t_1 -2e-293)
     t_1
     (if (<= t_1 0.0)
       (/ (- y (/ x z)) a)
       (if (<= t_1 INFINITY) t_1 (/ y a))))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = (x - (y * z)) / (t - (z * a));
	double tmp;
	if (t_1 <= -2e-293) {
		tmp = t_1;
	} else if (t_1 <= 0.0) {
		tmp = (y - (x / z)) / a;
	} else if (t_1 <= ((double) INFINITY)) {
		tmp = t_1;
	} else {
		tmp = y / a;
	}
	return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = (x - (y * z)) / (t - (z * a));
	double tmp;
	if (t_1 <= -2e-293) {
		tmp = t_1;
	} else if (t_1 <= 0.0) {
		tmp = (y - (x / z)) / a;
	} else if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else {
		tmp = y / a;
	}
	return tmp;
}
def code(x, y, z, t, a):
	t_1 = (x - (y * z)) / (t - (z * a))
	tmp = 0
	if t_1 <= -2e-293:
		tmp = t_1
	elif t_1 <= 0.0:
		tmp = (y - (x / z)) / a
	elif t_1 <= math.inf:
		tmp = t_1
	else:
		tmp = y / a
	return tmp
function code(x, y, z, t, a)
	t_1 = Float64(Float64(x - Float64(y * z)) / Float64(t - Float64(z * a)))
	tmp = 0.0
	if (t_1 <= -2e-293)
		tmp = t_1;
	elseif (t_1 <= 0.0)
		tmp = Float64(Float64(y - Float64(x / z)) / a);
	elseif (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = Float64(y / a);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = (x - (y * z)) / (t - (z * a));
	tmp = 0.0;
	if (t_1 <= -2e-293)
		tmp = t_1;
	elseif (t_1 <= 0.0)
		tmp = (y - (x / z)) / a;
	elseif (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = y / a;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-293], t$95$1, If[LessEqual[t$95$1, 0.0], N[(N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[t$95$1, Infinity], t$95$1, N[(y / a), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{x - y \cdot z}{t - z \cdot a}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-293}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{y - \frac{x}{z}}{a}\\

\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -2.0000000000000001e-293 or -0.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < +inf.0

    1. Initial program 94.0%

      \[\frac{x - y \cdot z}{t - a \cdot z} \]
    2. Add Preprocessing

    if -2.0000000000000001e-293 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -0.0

    1. Initial program 52.2%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-1, \color{blue}{y \cdot \frac{z}{t - a \cdot z}}, \frac{x}{t - a \cdot z}\right) \]
      3. cancel-sign-sub-inv52.2%

        \[\leadsto \mathsf{fma}\left(-1, y \cdot \frac{z}{\color{blue}{t + \left(-a\right) \cdot z}}, \frac{x}{t - a \cdot z}\right) \]
      4. *-commutative52.2%

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

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

        \[\leadsto \mathsf{fma}\left(-1, y \cdot \frac{z}{\color{blue}{\mathsf{fma}\left(z, -a, t\right)}}, \frac{x}{t - a \cdot z}\right) \]
      7. cancel-sign-sub-inv52.2%

        \[\leadsto \mathsf{fma}\left(-1, y \cdot \frac{z}{\mathsf{fma}\left(z, -a, t\right)}, \frac{x}{\color{blue}{t + \left(-a\right) \cdot z}}\right) \]
      8. *-commutative52.2%

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

        \[\leadsto \mathsf{fma}\left(-1, y \cdot \frac{z}{\mathsf{fma}\left(z, -a, t\right)}, \frac{x}{\color{blue}{z \cdot \left(-a\right) + t}}\right) \]
      10. fma-define52.2%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-1, y \cdot \frac{z}{\mathsf{fma}\left(z, -a, t\right)}, \frac{x}{\mathsf{fma}\left(z, -a, t\right)}\right)} \]
    8. Taylor expanded in a around inf 88.2%

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

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

        \[\leadsto \frac{\color{blue}{y - \frac{x}{z}}}{a} \]
    10. Simplified88.2%

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

    if +inf.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z)))

    1. Initial program 0.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x - y \cdot z}{t - z \cdot a} \leq -2 \cdot 10^{-293}:\\ \;\;\;\;\frac{x - y \cdot z}{t - z \cdot a}\\ \mathbf{elif}\;\frac{x - y \cdot z}{t - z \cdot a} \leq 0:\\ \;\;\;\;\frac{y - \frac{x}{z}}{a}\\ \mathbf{elif}\;\frac{x - y \cdot z}{t - z \cdot a} \leq \infty:\\ \;\;\;\;\frac{x - y \cdot z}{t - z \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 54.8% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2.7 \cdot 10^{+85}:\\ \;\;\;\;\frac{y}{a}\\ \mathbf{elif}\;z \leq -1.3 \cdot 10^{+26}:\\ \;\;\;\;y \cdot \frac{z}{-t}\\ \mathbf{elif}\;z \leq -8 \cdot 10^{+17}:\\ \;\;\;\;\frac{y}{a}\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-49}:\\ \;\;\;\;\frac{x}{t}\\ \mathbf{elif}\;z \leq 1.32 \cdot 10^{+17}:\\ \;\;\;\;\frac{\frac{x}{z}}{-a}\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{+39}:\\ \;\;\;\;\frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (if (<= z -2.7e+85)
   (/ y a)
   (if (<= z -1.3e+26)
     (* y (/ z (- t)))
     (if (<= z -8e+17)
       (/ y a)
       (if (<= z 6e-49)
         (/ x t)
         (if (<= z 1.32e+17)
           (/ (/ x z) (- a))
           (if (<= z 2.6e+39) (/ x t) (/ y a))))))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (z <= -2.7e+85) {
		tmp = y / a;
	} else if (z <= -1.3e+26) {
		tmp = y * (z / -t);
	} else if (z <= -8e+17) {
		tmp = y / a;
	} else if (z <= 6e-49) {
		tmp = x / t;
	} else if (z <= 1.32e+17) {
		tmp = (x / z) / -a;
	} else if (z <= 2.6e+39) {
		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.7d+85)) then
        tmp = y / a
    else if (z <= (-1.3d+26)) then
        tmp = y * (z / -t)
    else if (z <= (-8d+17)) then
        tmp = y / a
    else if (z <= 6d-49) then
        tmp = x / t
    else if (z <= 1.32d+17) then
        tmp = (x / z) / -a
    else if (z <= 2.6d+39) 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.7e+85) {
		tmp = y / a;
	} else if (z <= -1.3e+26) {
		tmp = y * (z / -t);
	} else if (z <= -8e+17) {
		tmp = y / a;
	} else if (z <= 6e-49) {
		tmp = x / t;
	} else if (z <= 1.32e+17) {
		tmp = (x / z) / -a;
	} else if (z <= 2.6e+39) {
		tmp = x / t;
	} else {
		tmp = y / a;
	}
	return tmp;
}
def code(x, y, z, t, a):
	tmp = 0
	if z <= -2.7e+85:
		tmp = y / a
	elif z <= -1.3e+26:
		tmp = y * (z / -t)
	elif z <= -8e+17:
		tmp = y / a
	elif z <= 6e-49:
		tmp = x / t
	elif z <= 1.32e+17:
		tmp = (x / z) / -a
	elif z <= 2.6e+39:
		tmp = x / t
	else:
		tmp = y / a
	return tmp
function code(x, y, z, t, a)
	tmp = 0.0
	if (z <= -2.7e+85)
		tmp = Float64(y / a);
	elseif (z <= -1.3e+26)
		tmp = Float64(y * Float64(z / Float64(-t)));
	elseif (z <= -8e+17)
		tmp = Float64(y / a);
	elseif (z <= 6e-49)
		tmp = Float64(x / t);
	elseif (z <= 1.32e+17)
		tmp = Float64(Float64(x / z) / Float64(-a));
	elseif (z <= 2.6e+39)
		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.7e+85)
		tmp = y / a;
	elseif (z <= -1.3e+26)
		tmp = y * (z / -t);
	elseif (z <= -8e+17)
		tmp = y / a;
	elseif (z <= 6e-49)
		tmp = x / t;
	elseif (z <= 1.32e+17)
		tmp = (x / z) / -a;
	elseif (z <= 2.6e+39)
		tmp = x / t;
	else
		tmp = y / a;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -2.7e+85], N[(y / a), $MachinePrecision], If[LessEqual[z, -1.3e+26], N[(y * N[(z / (-t)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -8e+17], N[(y / a), $MachinePrecision], If[LessEqual[z, 6e-49], N[(x / t), $MachinePrecision], If[LessEqual[z, 1.32e+17], N[(N[(x / z), $MachinePrecision] / (-a)), $MachinePrecision], If[LessEqual[z, 2.6e+39], N[(x / t), $MachinePrecision], N[(y / a), $MachinePrecision]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;z \leq -8 \cdot 10^{+17}:\\
\;\;\;\;\frac{y}{a}\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -2.69999999999999983e85 or -1.30000000000000001e26 < z < -8e17 or 2.6e39 < z

    1. Initial program 61.8%

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

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

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

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

    if -2.69999999999999983e85 < z < -1.30000000000000001e26

    1. Initial program 83.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot \left(y \cdot z\right)}{\color{blue}{\left(-a \cdot z\right)} + t} \]
      6. distribute-rgt-neg-in67.5%

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

        \[\leadsto \frac{-1 \cdot \left(y \cdot z\right)}{\color{blue}{\mathsf{fma}\left(a, -z, t\right)}} \]
      8. associate-*r/67.5%

        \[\leadsto \color{blue}{-1 \cdot \frac{y \cdot z}{\mathsf{fma}\left(a, -z, t\right)}} \]
      9. neg-mul-167.5%

        \[\leadsto \color{blue}{-\frac{y \cdot z}{\mathsf{fma}\left(a, -z, t\right)}} \]
      10. distribute-neg-frac267.5%

        \[\leadsto \color{blue}{\frac{y \cdot z}{-\mathsf{fma}\left(a, -z, t\right)}} \]
      11. neg-sub067.5%

        \[\leadsto \frac{y \cdot z}{\color{blue}{0 - \mathsf{fma}\left(a, -z, t\right)}} \]
      12. fma-undefine67.5%

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

        \[\leadsto \frac{y \cdot z}{0 - \left(\color{blue}{\left(-a \cdot z\right)} + t\right)} \]
      14. distribute-lft-neg-in67.5%

        \[\leadsto \frac{y \cdot z}{0 - \left(\color{blue}{\left(-a\right) \cdot z} + t\right)} \]
      15. *-commutative67.5%

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

        \[\leadsto \frac{y \cdot z}{\color{blue}{\left(0 - z \cdot \left(-a\right)\right) - t}} \]
      17. neg-sub067.5%

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

        \[\leadsto \frac{y \cdot z}{\left(-\color{blue}{\left(-z \cdot a\right)}\right) - t} \]
      19. remove-double-neg67.5%

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{y \cdot z}{t}} \]
    9. Step-by-step derivation
      1. mul-1-neg51.3%

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

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

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

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

    if -8e17 < z < 6e-49 or 1.32e17 < z < 2.6e39

    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 63.5%

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

    if 6e-49 < z < 1.32e17

    1. Initial program 92.9%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-x}}{a \cdot z} \]
      3. *-commutative31.8%

        \[\leadsto \frac{-x}{\color{blue}{z \cdot a}} \]
    8. Simplified31.8%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{a \cdot z}} \]
    10. Step-by-step derivation
      1. mul-1-neg31.8%

        \[\leadsto \color{blue}{-\frac{x}{a \cdot z}} \]
      2. associate-/l/38.6%

        \[\leadsto -\color{blue}{\frac{\frac{x}{z}}{a}} \]
    11. Simplified38.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.7 \cdot 10^{+85}:\\ \;\;\;\;\frac{y}{a}\\ \mathbf{elif}\;z \leq -1.3 \cdot 10^{+26}:\\ \;\;\;\;y \cdot \frac{z}{-t}\\ \mathbf{elif}\;z \leq -8 \cdot 10^{+17}:\\ \;\;\;\;\frac{y}{a}\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-49}:\\ \;\;\;\;\frac{x}{t}\\ \mathbf{elif}\;z \leq 1.32 \cdot 10^{+17}:\\ \;\;\;\;\frac{\frac{x}{z}}{-a}\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{+39}:\\ \;\;\;\;\frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 54.9% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -3.2 \cdot 10^{+84}:\\ \;\;\;\;\frac{y}{a}\\ \mathbf{elif}\;z \leq -5.2 \cdot 10^{+26}:\\ \;\;\;\;y \cdot \frac{z}{-t}\\ \mathbf{elif}\;z \leq -6.8 \cdot 10^{+17}:\\ \;\;\;\;\frac{y}{a}\\ \mathbf{elif}\;z \leq 4.9 \cdot 10^{-49}:\\ \;\;\;\;\frac{x}{t}\\ \mathbf{elif}\;z \leq 1.16 \cdot 10^{+21}:\\ \;\;\;\;\frac{\frac{x}{a}}{-z}\\ \mathbf{elif}\;z \leq 10^{+43}:\\ \;\;\;\;\frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a}\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (if (<= z -3.2e+84)
   (/ y a)
   (if (<= z -5.2e+26)
     (* y (/ z (- t)))
     (if (<= z -6.8e+17)
       (/ y a)
       (if (<= z 4.9e-49)
         (/ x t)
         (if (<= z 1.16e+21)
           (/ (/ x a) (- z))
           (if (<= z 1e+43) (/ x t) (/ y a))))))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (z <= -3.2e+84) {
		tmp = y / a;
	} else if (z <= -5.2e+26) {
		tmp = y * (z / -t);
	} else if (z <= -6.8e+17) {
		tmp = y / a;
	} else if (z <= 4.9e-49) {
		tmp = x / t;
	} else if (z <= 1.16e+21) {
		tmp = (x / a) / -z;
	} else if (z <= 1e+43) {
		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 <= (-3.2d+84)) then
        tmp = y / a
    else if (z <= (-5.2d+26)) then
        tmp = y * (z / -t)
    else if (z <= (-6.8d+17)) then
        tmp = y / a
    else if (z <= 4.9d-49) then
        tmp = x / t
    else if (z <= 1.16d+21) then
        tmp = (x / a) / -z
    else if (z <= 1d+43) 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 <= -3.2e+84) {
		tmp = y / a;
	} else if (z <= -5.2e+26) {
		tmp = y * (z / -t);
	} else if (z <= -6.8e+17) {
		tmp = y / a;
	} else if (z <= 4.9e-49) {
		tmp = x / t;
	} else if (z <= 1.16e+21) {
		tmp = (x / a) / -z;
	} else if (z <= 1e+43) {
		tmp = x / t;
	} else {
		tmp = y / a;
	}
	return tmp;
}
def code(x, y, z, t, a):
	tmp = 0
	if z <= -3.2e+84:
		tmp = y / a
	elif z <= -5.2e+26:
		tmp = y * (z / -t)
	elif z <= -6.8e+17:
		tmp = y / a
	elif z <= 4.9e-49:
		tmp = x / t
	elif z <= 1.16e+21:
		tmp = (x / a) / -z
	elif z <= 1e+43:
		tmp = x / t
	else:
		tmp = y / a
	return tmp
function code(x, y, z, t, a)
	tmp = 0.0
	if (z <= -3.2e+84)
		tmp = Float64(y / a);
	elseif (z <= -5.2e+26)
		tmp = Float64(y * Float64(z / Float64(-t)));
	elseif (z <= -6.8e+17)
		tmp = Float64(y / a);
	elseif (z <= 4.9e-49)
		tmp = Float64(x / t);
	elseif (z <= 1.16e+21)
		tmp = Float64(Float64(x / a) / Float64(-z));
	elseif (z <= 1e+43)
		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 <= -3.2e+84)
		tmp = y / a;
	elseif (z <= -5.2e+26)
		tmp = y * (z / -t);
	elseif (z <= -6.8e+17)
		tmp = y / a;
	elseif (z <= 4.9e-49)
		tmp = x / t;
	elseif (z <= 1.16e+21)
		tmp = (x / a) / -z;
	elseif (z <= 1e+43)
		tmp = x / t;
	else
		tmp = y / a;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -3.2e+84], N[(y / a), $MachinePrecision], If[LessEqual[z, -5.2e+26], N[(y * N[(z / (-t)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -6.8e+17], N[(y / a), $MachinePrecision], If[LessEqual[z, 4.9e-49], N[(x / t), $MachinePrecision], If[LessEqual[z, 1.16e+21], N[(N[(x / a), $MachinePrecision] / (-z)), $MachinePrecision], If[LessEqual[z, 1e+43], N[(x / t), $MachinePrecision], N[(y / a), $MachinePrecision]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;z \leq -6.8 \cdot 10^{+17}:\\
\;\;\;\;\frac{y}{a}\\

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

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

\mathbf{elif}\;z \leq 10^{+43}:\\
\;\;\;\;\frac{x}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -3.2000000000000001e84 or -5.20000000000000004e26 < z < -6.8e17 or 1.00000000000000001e43 < z

    1. Initial program 61.8%

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

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

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

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

    if -3.2000000000000001e84 < z < -5.20000000000000004e26

    1. Initial program 83.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot \left(y \cdot z\right)}{\color{blue}{\left(-a \cdot z\right)} + t} \]
      6. distribute-rgt-neg-in67.5%

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

        \[\leadsto \frac{-1 \cdot \left(y \cdot z\right)}{\color{blue}{\mathsf{fma}\left(a, -z, t\right)}} \]
      8. associate-*r/67.5%

        \[\leadsto \color{blue}{-1 \cdot \frac{y \cdot z}{\mathsf{fma}\left(a, -z, t\right)}} \]
      9. neg-mul-167.5%

        \[\leadsto \color{blue}{-\frac{y \cdot z}{\mathsf{fma}\left(a, -z, t\right)}} \]
      10. distribute-neg-frac267.5%

        \[\leadsto \color{blue}{\frac{y \cdot z}{-\mathsf{fma}\left(a, -z, t\right)}} \]
      11. neg-sub067.5%

        \[\leadsto \frac{y \cdot z}{\color{blue}{0 - \mathsf{fma}\left(a, -z, t\right)}} \]
      12. fma-undefine67.5%

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

        \[\leadsto \frac{y \cdot z}{0 - \left(\color{blue}{\left(-a \cdot z\right)} + t\right)} \]
      14. distribute-lft-neg-in67.5%

        \[\leadsto \frac{y \cdot z}{0 - \left(\color{blue}{\left(-a\right) \cdot z} + t\right)} \]
      15. *-commutative67.5%

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

        \[\leadsto \frac{y \cdot z}{\color{blue}{\left(0 - z \cdot \left(-a\right)\right) - t}} \]
      17. neg-sub067.5%

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

        \[\leadsto \frac{y \cdot z}{\left(-\color{blue}{\left(-z \cdot a\right)}\right) - t} \]
      19. remove-double-neg67.5%

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{y \cdot z}{t}} \]
    9. Step-by-step derivation
      1. mul-1-neg51.3%

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

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

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

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

    if -6.8e17 < z < 4.9000000000000002e-49 or 1.16e21 < z < 1.00000000000000001e43

    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 63.5%

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

    if 4.9000000000000002e-49 < z < 1.16e21

    1. Initial program 92.9%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{a \cdot z}} \]
    7. Step-by-step derivation
      1. mul-1-neg31.8%

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

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

        \[\leadsto \color{blue}{\frac{\frac{x}{a}}{-z}} \]
    8. Simplified38.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.2 \cdot 10^{+84}:\\ \;\;\;\;\frac{y}{a}\\ \mathbf{elif}\;z \leq -5.2 \cdot 10^{+26}:\\ \;\;\;\;y \cdot \frac{z}{-t}\\ \mathbf{elif}\;z \leq -6.8 \cdot 10^{+17}:\\ \;\;\;\;\frac{y}{a}\\ \mathbf{elif}\;z \leq 4.9 \cdot 10^{-49}:\\ \;\;\;\;\frac{x}{t}\\ \mathbf{elif}\;z \leq 1.16 \cdot 10^{+21}:\\ \;\;\;\;\frac{\frac{x}{a}}{-z}\\ \mathbf{elif}\;z \leq 10^{+43}:\\ \;\;\;\;\frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 71.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{x}{t - z \cdot a}\\ t_2 := \frac{y - \frac{x}{z}}{a}\\ \mathbf{if}\;z \leq -2.8 \cdot 10^{+44}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{-76}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{+18}:\\ \;\;\;\;\frac{y \cdot z}{z \cdot a - t}\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{+43}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (/ x (- t (* z a)))) (t_2 (/ (- y (/ x z)) a)))
   (if (<= z -2.8e+44)
     t_2
     (if (<= z 1.7e-76)
       t_1
       (if (<= z 7.5e+18)
         (/ (* y z) (- (* z a) t))
         (if (<= z 1.25e+43) t_1 t_2))))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = x / (t - (z * a));
	double t_2 = (y - (x / z)) / a;
	double tmp;
	if (z <= -2.8e+44) {
		tmp = t_2;
	} else if (z <= 1.7e-76) {
		tmp = t_1;
	} else if (z <= 7.5e+18) {
		tmp = (y * z) / ((z * a) - t);
	} else if (z <= 1.25e+43) {
		tmp = 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 = x / (t - (z * a))
    t_2 = (y - (x / z)) / a
    if (z <= (-2.8d+44)) then
        tmp = t_2
    else if (z <= 1.7d-76) then
        tmp = t_1
    else if (z <= 7.5d+18) then
        tmp = (y * z) / ((z * a) - t)
    else if (z <= 1.25d+43) then
        tmp = 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 = x / (t - (z * a));
	double t_2 = (y - (x / z)) / a;
	double tmp;
	if (z <= -2.8e+44) {
		tmp = t_2;
	} else if (z <= 1.7e-76) {
		tmp = t_1;
	} else if (z <= 7.5e+18) {
		tmp = (y * z) / ((z * a) - t);
	} else if (z <= 1.25e+43) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t, a):
	t_1 = x / (t - (z * a))
	t_2 = (y - (x / z)) / a
	tmp = 0
	if z <= -2.8e+44:
		tmp = t_2
	elif z <= 1.7e-76:
		tmp = t_1
	elif z <= 7.5e+18:
		tmp = (y * z) / ((z * a) - t)
	elif z <= 1.25e+43:
		tmp = t_1
	else:
		tmp = t_2
	return tmp
function code(x, y, z, t, a)
	t_1 = Float64(x / Float64(t - Float64(z * a)))
	t_2 = Float64(Float64(y - Float64(x / z)) / a)
	tmp = 0.0
	if (z <= -2.8e+44)
		tmp = t_2;
	elseif (z <= 1.7e-76)
		tmp = t_1;
	elseif (z <= 7.5e+18)
		tmp = Float64(Float64(y * z) / Float64(Float64(z * a) - t));
	elseif (z <= 1.25e+43)
		tmp = t_1;
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = x / (t - (z * a));
	t_2 = (y - (x / z)) / a;
	tmp = 0.0;
	if (z <= -2.8e+44)
		tmp = t_2;
	elseif (z <= 1.7e-76)
		tmp = t_1;
	elseif (z <= 7.5e+18)
		tmp = (y * z) / ((z * a) - t);
	elseif (z <= 1.25e+43)
		tmp = t_1;
	else
		tmp = t_2;
	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]}, Block[{t$95$2 = N[(N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[z, -2.8e+44], t$95$2, If[LessEqual[z, 1.7e-76], t$95$1, If[LessEqual[z, 7.5e+18], N[(N[(y * z), $MachinePrecision] / N[(N[(z * a), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.25e+43], t$95$1, t$95$2]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 1.7 \cdot 10^{-76}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 7.5 \cdot 10^{+18}:\\
\;\;\;\;\frac{y \cdot z}{z \cdot a - t}\\

\mathbf{elif}\;z \leq 1.25 \cdot 10^{+43}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -2.8000000000000001e44 or 1.2500000000000001e43 < z

    1. Initial program 61.0%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-1, \color{blue}{y \cdot \frac{z}{t - a \cdot z}}, \frac{x}{t - a \cdot z}\right) \]
      3. cancel-sign-sub-inv73.7%

        \[\leadsto \mathsf{fma}\left(-1, y \cdot \frac{z}{\color{blue}{t + \left(-a\right) \cdot z}}, \frac{x}{t - a \cdot z}\right) \]
      4. *-commutative73.7%

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

        \[\leadsto \mathsf{fma}\left(-1, y \cdot \frac{z}{\color{blue}{z \cdot \left(-a\right) + t}}, \frac{x}{t - a \cdot z}\right) \]
      6. fma-define73.7%

        \[\leadsto \mathsf{fma}\left(-1, y \cdot \frac{z}{\color{blue}{\mathsf{fma}\left(z, -a, t\right)}}, \frac{x}{t - a \cdot z}\right) \]
      7. cancel-sign-sub-inv73.7%

        \[\leadsto \mathsf{fma}\left(-1, y \cdot \frac{z}{\mathsf{fma}\left(z, -a, t\right)}, \frac{x}{\color{blue}{t + \left(-a\right) \cdot z}}\right) \]
      8. *-commutative73.7%

        \[\leadsto \mathsf{fma}\left(-1, y \cdot \frac{z}{\mathsf{fma}\left(z, -a, t\right)}, \frac{x}{t + \color{blue}{z \cdot \left(-a\right)}}\right) \]
      9. +-commutative73.7%

        \[\leadsto \mathsf{fma}\left(-1, y \cdot \frac{z}{\mathsf{fma}\left(z, -a, t\right)}, \frac{x}{\color{blue}{z \cdot \left(-a\right) + t}}\right) \]
      10. fma-define73.7%

        \[\leadsto \mathsf{fma}\left(-1, y \cdot \frac{z}{\mathsf{fma}\left(z, -a, t\right)}, \frac{x}{\color{blue}{\mathsf{fma}\left(z, -a, t\right)}}\right) \]
    7. Simplified73.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-1, y \cdot \frac{z}{\mathsf{fma}\left(z, -a, t\right)}, \frac{x}{\mathsf{fma}\left(z, -a, t\right)}\right)} \]
    8. Taylor expanded in a around inf 72.0%

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

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

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

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

    if -2.8000000000000001e44 < z < 1.7e-76 or 7.5e18 < z < 1.2500000000000001e43

    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 x around inf 77.8%

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

    if 1.7e-76 < z < 7.5e18

    1. Initial program 94.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot \left(y \cdot z\right)}{\color{blue}{\left(-a \cdot z\right)} + t} \]
      6. distribute-rgt-neg-in64.4%

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

        \[\leadsto \frac{-1 \cdot \left(y \cdot z\right)}{\color{blue}{\mathsf{fma}\left(a, -z, t\right)}} \]
      8. associate-*r/64.4%

        \[\leadsto \color{blue}{-1 \cdot \frac{y \cdot z}{\mathsf{fma}\left(a, -z, t\right)}} \]
      9. neg-mul-164.4%

        \[\leadsto \color{blue}{-\frac{y \cdot z}{\mathsf{fma}\left(a, -z, t\right)}} \]
      10. distribute-neg-frac264.4%

        \[\leadsto \color{blue}{\frac{y \cdot z}{-\mathsf{fma}\left(a, -z, t\right)}} \]
      11. neg-sub064.4%

        \[\leadsto \frac{y \cdot z}{\color{blue}{0 - \mathsf{fma}\left(a, -z, t\right)}} \]
      12. fma-undefine64.4%

        \[\leadsto \frac{y \cdot z}{0 - \color{blue}{\left(a \cdot \left(-z\right) + t\right)}} \]
      13. distribute-rgt-neg-in64.4%

        \[\leadsto \frac{y \cdot z}{0 - \left(\color{blue}{\left(-a \cdot z\right)} + t\right)} \]
      14. distribute-lft-neg-in64.4%

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

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

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

        \[\leadsto \frac{y \cdot z}{\color{blue}{\left(-z \cdot \left(-a\right)\right)} - t} \]
      18. distribute-rgt-neg-out64.4%

        \[\leadsto \frac{y \cdot z}{\left(-\color{blue}{\left(-z \cdot a\right)}\right) - t} \]
      19. remove-double-neg64.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.8 \cdot 10^{+44}:\\ \;\;\;\;\frac{y - \frac{x}{z}}{a}\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{-76}:\\ \;\;\;\;\frac{x}{t - z \cdot a}\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{+18}:\\ \;\;\;\;\frac{y \cdot z}{z \cdot a - t}\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{+43}:\\ \;\;\;\;\frac{x}{t - z \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y - \frac{x}{z}}{a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 55.0% accurate, 0.5× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -3.49999999999999985e46 or 2.35e39 < z

    1. Initial program 61.0%

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

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

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

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

    if -3.49999999999999985e46 < z < 2.1999999999999999e-49 or 1.52e19 < z < 2.35e39

    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 61.9%

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

    if 2.1999999999999999e-49 < z < 1.52e19

    1. Initial program 92.9%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-x}}{a \cdot z} \]
      3. *-commutative31.8%

        \[\leadsto \frac{-x}{\color{blue}{z \cdot a}} \]
    8. Simplified31.8%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{a \cdot z}} \]
    10. Step-by-step derivation
      1. mul-1-neg31.8%

        \[\leadsto \color{blue}{-\frac{x}{a \cdot z}} \]
      2. associate-/l/38.6%

        \[\leadsto -\color{blue}{\frac{\frac{x}{z}}{a}} \]
    11. Simplified38.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.5 \cdot 10^{+46}:\\ \;\;\;\;\frac{y}{a}\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{-49}:\\ \;\;\;\;\frac{x}{t}\\ \mathbf{elif}\;z \leq 1.52 \cdot 10^{+19}:\\ \;\;\;\;\frac{\frac{x}{z}}{-a}\\ \mathbf{elif}\;z \leq 2.35 \cdot 10^{+39}:\\ \;\;\;\;\frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 66.0% accurate, 0.6× speedup?

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

    1. Initial program 60.6%

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

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

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

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

    if -3.3e50 < z < 9.1999999999999995e55

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

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

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

Alternative 8: 72.2% accurate, 0.6× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.49999999999999996e52 or 7.2e-10 < z

    1. Initial program 64.0%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-1, \color{blue}{y \cdot \frac{z}{t - a \cdot z}}, \frac{x}{t - a \cdot z}\right) \]
      3. cancel-sign-sub-inv75.5%

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

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

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

        \[\leadsto \mathsf{fma}\left(-1, y \cdot \frac{z}{\color{blue}{\mathsf{fma}\left(z, -a, t\right)}}, \frac{x}{t - a \cdot z}\right) \]
      7. cancel-sign-sub-inv75.5%

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-1, y \cdot \frac{z}{\mathsf{fma}\left(z, -a, t\right)}, \frac{x}{\mathsf{fma}\left(z, -a, t\right)}\right)} \]
    8. Taylor expanded in a around inf 71.2%

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

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

        \[\leadsto \frac{\color{blue}{y - \frac{x}{z}}}{a} \]
    10. Simplified71.2%

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

    if -5.49999999999999996e52 < z < 7.2e-10

    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 t around inf 74.0%

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

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

Alternative 9: 54.5% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.1 \cdot 10^{+44} \lor \neg \left(z \leq 1.7 \cdot 10^{-77}\right):\\
\;\;\;\;\frac{y}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.09999999999999996e44 or 1.69999999999999991e-77 < z

    1. Initial program 67.8%

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

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

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

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

    if -3.09999999999999996e44 < z < 1.69999999999999991e-77

    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 62.1%

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

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

Alternative 10: 35.5% 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 84.6%

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

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

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

    \[\leadsto \color{blue}{\frac{x}{t}} \]
  6. Final simplification38.1%

    \[\leadsto \frac{x}{t} \]
  7. Add Preprocessing

Developer target: 97.2% 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 2024040 
(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))))