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

Percentage Accurate: 76.1% → 87.2%
Time: 8.4s
Alternatives: 11
Speedup: 0.2×

Specification

?
\[\begin{array}{l} \\ \frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))))
double code(double x, double y, double z, double t, double a, double b) {
	return (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
    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), intent (in) :: b
    code = (x + ((y * z) / t)) / ((a + 1.0d0) + ((y * b) / t))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t));
}
def code(x, y, z, t, a, b):
	return (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t))
function code(x, y, z, t, a, b)
	return Float64(Float64(x + Float64(Float64(y * z) / t)) / Float64(Float64(a + 1.0) + Float64(Float64(y * b) / t)))
end
function tmp = code(x, y, z, t, a, b)
	tmp = (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t));
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / N[(N[(a + 1.0), $MachinePrecision] + N[(N[(y * b), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}
\end{array}

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 11 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: 76.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))))
double code(double x, double y, double z, double t, double a, double b) {
	return (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
    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), intent (in) :: b
    code = (x + ((y * z) / t)) / ((a + 1.0d0) + ((y * b) / t))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t));
}
def code(x, y, z, t, a, b):
	return (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t))
function code(x, y, z, t, a, b)
	return Float64(Float64(x + Float64(Float64(y * z) / t)) / Float64(Float64(a + 1.0) + Float64(Float64(y * b) / t)))
end
function tmp = code(x, y, z, t, a, b)
	tmp = (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t));
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / N[(N[(a + 1.0), $MachinePrecision] + N[(N[(y * b), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}
\end{array}

Alternative 1: 87.2% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
t_1 := \frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-303}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{y}{t}, b, a\right), t, t\right)}, y, \frac{x}{\mathsf{fma}\left(\frac{y}{t}, b, a - -1\right)}\right)\\

\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(t, x, y \cdot z\right)}{b}}{y}\\

\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\mathsf{fma}\left(\mathsf{fma}\left(b, y, t\right), \frac{1}{t}, a\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < -4.9999999999999998e-303

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Applied rewrites76.9%

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

    if -4.9999999999999998e-303 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < 0.0

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in b around inf

      \[\leadsto \color{blue}{\frac{t \cdot \left(x + \frac{y \cdot z}{t}\right)}{b \cdot y}} \]
    3. Applied rewrites26.1%

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

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

    if 0.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < +inf.0

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Applied rewrites77.4%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\mathsf{fma}\left(\frac{y}{t}, b, a - -1\right)}} \]
    3. Applied rewrites75.5%

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

    if +inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t)))

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in b around inf

      \[\leadsto \color{blue}{\frac{t \cdot \left(x + \frac{y \cdot z}{t}\right)}{b \cdot y}} \]
    3. Applied rewrites26.1%

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

      \[\leadsto \frac{t}{b} \cdot \color{blue}{\left(\frac{z}{t} + \frac{x}{y}\right)} \]
    5. Applied rewrites40.0%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{x}{y}, t, z\right)}{b}} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 2: 86.5% accurate, 0.2× speedup?

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

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

\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(t, x, y \cdot z\right)}{b}}{y}\\

\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{t\_2}{\mathsf{fma}\left(\mathsf{fma}\left(b, y, t\right), \frac{1}{t}, a\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < -4.9999999999999998e-303

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Applied rewrites77.4%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\mathsf{fma}\left(\frac{y}{t}, b, a - -1\right)}} \]
    3. Applied rewrites75.5%

      \[\leadsto \frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, y, t\right), \frac{1}{t}, a\right)}} \]
    4. Applied rewrites75.5%

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

    if -4.9999999999999998e-303 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < 0.0

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in b around inf

      \[\leadsto \color{blue}{\frac{t \cdot \left(x + \frac{y \cdot z}{t}\right)}{b \cdot y}} \]
    3. Applied rewrites26.1%

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

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

    if 0.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < +inf.0

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Applied rewrites77.4%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\mathsf{fma}\left(\frac{y}{t}, b, a - -1\right)}} \]
    3. Applied rewrites75.5%

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

    if +inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t)))

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in b around inf

      \[\leadsto \color{blue}{\frac{t \cdot \left(x + \frac{y \cdot z}{t}\right)}{b \cdot y}} \]
    3. Applied rewrites26.1%

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

      \[\leadsto \frac{t}{b} \cdot \color{blue}{\left(\frac{z}{t} + \frac{x}{y}\right)} \]
    5. Applied rewrites40.0%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{x}{y}, t, z\right)}{b}} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 3: 86.1% accurate, 0.2× speedup?

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

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

\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(t, x, y \cdot z\right)}{b}}{y}\\

\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{t\_2}{\mathsf{fma}\left(\mathsf{fma}\left(b, y, t\right), \frac{1}{t}, a\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < -4.9999999999999998e-303

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Applied rewrites77.4%

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

    if -4.9999999999999998e-303 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < 0.0

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in b around inf

      \[\leadsto \color{blue}{\frac{t \cdot \left(x + \frac{y \cdot z}{t}\right)}{b \cdot y}} \]
    3. Applied rewrites26.1%

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

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

    if 0.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < +inf.0

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Applied rewrites77.4%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\mathsf{fma}\left(\frac{y}{t}, b, a - -1\right)}} \]
    3. Applied rewrites75.5%

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

    if +inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t)))

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in b around inf

      \[\leadsto \color{blue}{\frac{t \cdot \left(x + \frac{y \cdot z}{t}\right)}{b \cdot y}} \]
    3. Applied rewrites26.1%

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

      \[\leadsto \frac{t}{b} \cdot \color{blue}{\left(\frac{z}{t} + \frac{x}{y}\right)} \]
    5. Applied rewrites40.0%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{x}{y}, t, z\right)}{b}} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 4: 86.0% accurate, 0.2× speedup?

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

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

\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(t, x, y \cdot z\right)}{b}}{y}\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+297}:\\
\;\;\;\;t\_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < -4.9999999999999998e-303 or 0.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < 2e297

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Applied rewrites77.4%

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

    if -4.9999999999999998e-303 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < 0.0

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in b around inf

      \[\leadsto \color{blue}{\frac{t \cdot \left(x + \frac{y \cdot z}{t}\right)}{b \cdot y}} \]
    3. Applied rewrites26.1%

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

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

    if 2e297 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t)))

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in b around inf

      \[\leadsto \color{blue}{\frac{t \cdot \left(x + \frac{y \cdot z}{t}\right)}{b \cdot y}} \]
    3. Applied rewrites26.1%

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

      \[\leadsto \frac{t}{b} \cdot \color{blue}{\left(\frac{z}{t} + \frac{x}{y}\right)} \]
    5. Applied rewrites40.0%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{x}{y}, t, z\right)}{b}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 70.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\mathsf{fma}\left(\frac{x}{y}, t, z\right)}{b}\\ t_2 := x + \frac{y \cdot z}{t}\\ \mathbf{if}\;y \leq -1.75 \cdot 10^{+120}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq -5.3 \cdot 10^{-12}:\\ \;\;\;\;\frac{\mathsf{fma}\left(t, x, y \cdot z\right)}{\mathsf{fma}\left(b, y, t\right)}\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-127}:\\ \;\;\;\;\frac{t\_2}{1 + a}\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{+60}:\\ \;\;\;\;\frac{t\_2}{1 + \frac{y \cdot b}{t}}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (/ (fma (/ x y) t z) b)) (t_2 (+ x (/ (* y z) t))))
   (if (<= y -1.75e+120)
     t_1
     (if (<= y -5.3e-12)
       (/ (fma t x (* y z)) (fma b y t))
       (if (<= y 1.4e-127)
         (/ t_2 (+ 1.0 a))
         (if (<= y 5.4e+60) (/ t_2 (+ 1.0 (/ (* y b) t))) t_1))))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = fma((x / y), t, z) / b;
	double t_2 = x + ((y * z) / t);
	double tmp;
	if (y <= -1.75e+120) {
		tmp = t_1;
	} else if (y <= -5.3e-12) {
		tmp = fma(t, x, (y * z)) / fma(b, y, t);
	} else if (y <= 1.4e-127) {
		tmp = t_2 / (1.0 + a);
	} else if (y <= 5.4e+60) {
		tmp = t_2 / (1.0 + ((y * b) / t));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	t_1 = Float64(fma(Float64(x / y), t, z) / b)
	t_2 = Float64(x + Float64(Float64(y * z) / t))
	tmp = 0.0
	if (y <= -1.75e+120)
		tmp = t_1;
	elseif (y <= -5.3e-12)
		tmp = Float64(fma(t, x, Float64(y * z)) / fma(b, y, t));
	elseif (y <= 1.4e-127)
		tmp = Float64(t_2 / Float64(1.0 + a));
	elseif (y <= 5.4e+60)
		tmp = Float64(t_2 / Float64(1.0 + Float64(Float64(y * b) / t)));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(x / y), $MachinePrecision] * t + z), $MachinePrecision] / b), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.75e+120], t$95$1, If[LessEqual[y, -5.3e-12], N[(N[(t * x + N[(y * z), $MachinePrecision]), $MachinePrecision] / N[(b * y + t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.4e-127], N[(t$95$2 / N[(1.0 + a), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.4e+60], N[(t$95$2 / N[(1.0 + N[(N[(y * b), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{\mathsf{fma}\left(\frac{x}{y}, t, z\right)}{b}\\
t_2 := x + \frac{y \cdot z}{t}\\
\mathbf{if}\;y \leq -1.75 \cdot 10^{+120}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq -5.3 \cdot 10^{-12}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t, x, y \cdot z\right)}{\mathsf{fma}\left(b, y, t\right)}\\

\mathbf{elif}\;y \leq 1.4 \cdot 10^{-127}:\\
\;\;\;\;\frac{t\_2}{1 + a}\\

\mathbf{elif}\;y \leq 5.4 \cdot 10^{+60}:\\
\;\;\;\;\frac{t\_2}{1 + \frac{y \cdot b}{t}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.75000000000000004e120 or 5.3999999999999999e60 < y

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in b around inf

      \[\leadsto \color{blue}{\frac{t \cdot \left(x + \frac{y \cdot z}{t}\right)}{b \cdot y}} \]
    3. Applied rewrites26.1%

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

      \[\leadsto \frac{t}{b} \cdot \color{blue}{\left(\frac{z}{t} + \frac{x}{y}\right)} \]
    5. Applied rewrites40.0%

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

    if -1.75000000000000004e120 < y < -5.29999999999999963e-12

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Applied rewrites65.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(t, x, y \cdot z\right) \cdot \frac{\frac{t}{\mathsf{fma}\left(b, y, \mathsf{fma}\left(a, t, t\right)\right)}}{t}} \]
    3. Taylor expanded in a around 0

      \[\leadsto \color{blue}{\frac{t \cdot x + y \cdot z}{t + b \cdot y}} \]
    4. Applied rewrites49.3%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(t, x, y \cdot z\right)}{t + b \cdot y}} \]
    5. Applied rewrites49.3%

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

    if -5.29999999999999963e-12 < y < 1.4e-127

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in y around 0

      \[\leadsto \frac{x + \frac{y \cdot z}{t}}{\color{blue}{1 + a}} \]
    3. Applied rewrites57.3%

      \[\leadsto \frac{x + \frac{y \cdot z}{t}}{\color{blue}{1 + a}} \]

    if 1.4e-127 < y < 5.3999999999999999e60

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in a around 0

      \[\leadsto \frac{x + \frac{y \cdot z}{t}}{\color{blue}{1} + \frac{y \cdot b}{t}} \]
    3. Applied rewrites46.8%

      \[\leadsto \frac{x + \frac{y \cdot z}{t}}{\color{blue}{1} + \frac{y \cdot b}{t}} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 6: 69.6% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\mathsf{fma}\left(\frac{x}{y}, t, z\right)}{b}\\ \mathbf{if}\;y \leq -1.75 \cdot 10^{+120}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq -5.3 \cdot 10^{-12}:\\ \;\;\;\;\frac{\mathsf{fma}\left(t, x, y \cdot z\right)}{\mathsf{fma}\left(b, y, t\right)}\\ \mathbf{elif}\;y \leq 9.6 \cdot 10^{+82}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{1 + a}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (/ (fma (/ x y) t z) b)))
   (if (<= y -1.75e+120)
     t_1
     (if (<= y -5.3e-12)
       (/ (fma t x (* y z)) (fma b y t))
       (if (<= y 9.6e+82) (/ (fma (/ y t) z x) (+ 1.0 a)) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = fma((x / y), t, z) / b;
	double tmp;
	if (y <= -1.75e+120) {
		tmp = t_1;
	} else if (y <= -5.3e-12) {
		tmp = fma(t, x, (y * z)) / fma(b, y, t);
	} else if (y <= 9.6e+82) {
		tmp = fma((y / t), z, x) / (1.0 + a);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	t_1 = Float64(fma(Float64(x / y), t, z) / b)
	tmp = 0.0
	if (y <= -1.75e+120)
		tmp = t_1;
	elseif (y <= -5.3e-12)
		tmp = Float64(fma(t, x, Float64(y * z)) / fma(b, y, t));
	elseif (y <= 9.6e+82)
		tmp = Float64(fma(Float64(y / t), z, x) / Float64(1.0 + a));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(x / y), $MachinePrecision] * t + z), $MachinePrecision] / b), $MachinePrecision]}, If[LessEqual[y, -1.75e+120], t$95$1, If[LessEqual[y, -5.3e-12], N[(N[(t * x + N[(y * z), $MachinePrecision]), $MachinePrecision] / N[(b * y + t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9.6e+82], N[(N[(N[(y / t), $MachinePrecision] * z + x), $MachinePrecision] / N[(1.0 + a), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{\mathsf{fma}\left(\frac{x}{y}, t, z\right)}{b}\\
\mathbf{if}\;y \leq -1.75 \cdot 10^{+120}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq -5.3 \cdot 10^{-12}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t, x, y \cdot z\right)}{\mathsf{fma}\left(b, y, t\right)}\\

\mathbf{elif}\;y \leq 9.6 \cdot 10^{+82}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{1 + a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.75000000000000004e120 or 9.59999999999999992e82 < y

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in b around inf

      \[\leadsto \color{blue}{\frac{t \cdot \left(x + \frac{y \cdot z}{t}\right)}{b \cdot y}} \]
    3. Applied rewrites26.1%

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

      \[\leadsto \frac{t}{b} \cdot \color{blue}{\left(\frac{z}{t} + \frac{x}{y}\right)} \]
    5. Applied rewrites40.0%

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

    if -1.75000000000000004e120 < y < -5.29999999999999963e-12

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Applied rewrites65.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(t, x, y \cdot z\right) \cdot \frac{\frac{t}{\mathsf{fma}\left(b, y, \mathsf{fma}\left(a, t, t\right)\right)}}{t}} \]
    3. Taylor expanded in a around 0

      \[\leadsto \color{blue}{\frac{t \cdot x + y \cdot z}{t + b \cdot y}} \]
    4. Applied rewrites49.3%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(t, x, y \cdot z\right)}{t + b \cdot y}} \]
    5. Applied rewrites49.3%

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

    if -5.29999999999999963e-12 < y < 9.59999999999999992e82

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Applied rewrites77.4%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\mathsf{fma}\left(\frac{y}{t}, b, a - -1\right)}} \]
    3. Taylor expanded in y around 0

      \[\leadsto \frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\color{blue}{1 + a}} \]
    4. Applied rewrites58.9%

      \[\leadsto \frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\color{blue}{1 + a}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 7: 68.7% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\mathsf{fma}\left(\frac{x}{y}, t, z\right)}{b}\\ \mathbf{if}\;y \leq -1.15 \cdot 10^{+16}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 9.6 \cdot 10^{+82}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{1 + a}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (/ (fma (/ x y) t z) b)))
   (if (<= y -1.15e+16)
     t_1
     (if (<= y 9.6e+82) (/ (fma (/ y t) z x) (+ 1.0 a)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = fma((x / y), t, z) / b;
	double tmp;
	if (y <= -1.15e+16) {
		tmp = t_1;
	} else if (y <= 9.6e+82) {
		tmp = fma((y / t), z, x) / (1.0 + a);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	t_1 = Float64(fma(Float64(x / y), t, z) / b)
	tmp = 0.0
	if (y <= -1.15e+16)
		tmp = t_1;
	elseif (y <= 9.6e+82)
		tmp = Float64(fma(Float64(y / t), z, x) / Float64(1.0 + a));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(x / y), $MachinePrecision] * t + z), $MachinePrecision] / b), $MachinePrecision]}, If[LessEqual[y, -1.15e+16], t$95$1, If[LessEqual[y, 9.6e+82], N[(N[(N[(y / t), $MachinePrecision] * z + x), $MachinePrecision] / N[(1.0 + a), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{\mathsf{fma}\left(\frac{x}{y}, t, z\right)}{b}\\
\mathbf{if}\;y \leq -1.15 \cdot 10^{+16}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 9.6 \cdot 10^{+82}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{1 + a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.15e16 or 9.59999999999999992e82 < y

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in b around inf

      \[\leadsto \color{blue}{\frac{t \cdot \left(x + \frac{y \cdot z}{t}\right)}{b \cdot y}} \]
    3. Applied rewrites26.1%

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

      \[\leadsto \frac{t}{b} \cdot \color{blue}{\left(\frac{z}{t} + \frac{x}{y}\right)} \]
    5. Applied rewrites40.0%

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

    if -1.15e16 < y < 9.59999999999999992e82

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Applied rewrites77.4%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\mathsf{fma}\left(\frac{y}{t}, b, a - -1\right)}} \]
    3. Taylor expanded in y around 0

      \[\leadsto \frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\color{blue}{1 + a}} \]
    4. Applied rewrites58.9%

      \[\leadsto \frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\color{blue}{1 + a}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 60.7% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{\mathsf{fma}\left(\frac{x}{y}, t, z\right)}{b}\\ \mathbf{if}\;y \leq -6.8 \cdot 10^{+15}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 650000000:\\ \;\;\;\;\frac{x}{a - -1}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (/ (fma (/ x y) t z) b)))
   (if (<= y -6.8e+15) t_1 (if (<= y 650000000.0) (/ x (- a -1.0)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = fma((x / y), t, z) / b;
	double tmp;
	if (y <= -6.8e+15) {
		tmp = t_1;
	} else if (y <= 650000000.0) {
		tmp = x / (a - -1.0);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	t_1 = Float64(fma(Float64(x / y), t, z) / b)
	tmp = 0.0
	if (y <= -6.8e+15)
		tmp = t_1;
	elseif (y <= 650000000.0)
		tmp = Float64(x / Float64(a - -1.0));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(x / y), $MachinePrecision] * t + z), $MachinePrecision] / b), $MachinePrecision]}, If[LessEqual[y, -6.8e+15], t$95$1, If[LessEqual[y, 650000000.0], N[(x / N[(a - -1.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{\mathsf{fma}\left(\frac{x}{y}, t, z\right)}{b}\\
\mathbf{if}\;y \leq -6.8 \cdot 10^{+15}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 650000000:\\
\;\;\;\;\frac{x}{a - -1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.8e15 or 6.5e8 < y

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in b around inf

      \[\leadsto \color{blue}{\frac{t \cdot \left(x + \frac{y \cdot z}{t}\right)}{b \cdot y}} \]
    3. Applied rewrites26.1%

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

      \[\leadsto \frac{t}{b} \cdot \color{blue}{\left(\frac{z}{t} + \frac{x}{y}\right)} \]
    5. Applied rewrites40.0%

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

    if -6.8e15 < y < 6.5e8

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in y around 0

      \[\leadsto \color{blue}{\frac{x}{1 + a}} \]
    3. Applied rewrites42.6%

      \[\leadsto \color{blue}{\frac{x}{1 + a}} \]
    4. Applied rewrites42.6%

      \[\leadsto \color{blue}{\frac{x}{a - -1}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 55.7% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -6.8 \cdot 10^{+15}:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{elif}\;y \leq 275000000000:\\ \;\;\;\;\frac{x}{a - -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{b}\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (if (<= y -6.8e+15)
   (/ z b)
   (if (<= y 275000000000.0) (/ x (- a -1.0)) (/ z b))))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (y <= -6.8e+15) {
		tmp = z / b;
	} else if (y <= 275000000000.0) {
		tmp = x / (a - -1.0);
	} else {
		tmp = z / b;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
    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), intent (in) :: b
    real(8) :: tmp
    if (y <= (-6.8d+15)) then
        tmp = z / b
    else if (y <= 275000000000.0d0) then
        tmp = x / (a - (-1.0d0))
    else
        tmp = z / b
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (y <= -6.8e+15) {
		tmp = z / b;
	} else if (y <= 275000000000.0) {
		tmp = x / (a - -1.0);
	} else {
		tmp = z / b;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	tmp = 0
	if y <= -6.8e+15:
		tmp = z / b
	elif y <= 275000000000.0:
		tmp = x / (a - -1.0)
	else:
		tmp = z / b
	return tmp
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (y <= -6.8e+15)
		tmp = Float64(z / b);
	elseif (y <= 275000000000.0)
		tmp = Float64(x / Float64(a - -1.0));
	else
		tmp = Float64(z / b);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if (y <= -6.8e+15)
		tmp = z / b;
	elseif (y <= 275000000000.0)
		tmp = x / (a - -1.0);
	else
		tmp = z / b;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -6.8e+15], N[(z / b), $MachinePrecision], If[LessEqual[y, 275000000000.0], N[(x / N[(a - -1.0), $MachinePrecision]), $MachinePrecision], N[(z / b), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.8 \cdot 10^{+15}:\\
\;\;\;\;\frac{z}{b}\\

\mathbf{elif}\;y \leq 275000000000:\\
\;\;\;\;\frac{x}{a - -1}\\

\mathbf{else}:\\
\;\;\;\;\frac{z}{b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.8e15 or 2.75e11 < y

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in y around inf

      \[\leadsto \color{blue}{\frac{z}{b}} \]
    3. Applied rewrites33.7%

      \[\leadsto \color{blue}{\frac{z}{b}} \]

    if -6.8e15 < y < 2.75e11

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in y around 0

      \[\leadsto \color{blue}{\frac{x}{1 + a}} \]
    3. Applied rewrites42.6%

      \[\leadsto \color{blue}{\frac{x}{1 + a}} \]
    4. Applied rewrites42.6%

      \[\leadsto \color{blue}{\frac{x}{a - -1}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 41.9% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -4.8 \cdot 10^{-12}:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{-126}:\\ \;\;\;\;\frac{x}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{b}\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (if (<= y -4.8e-12) (/ z b) (if (<= y 8.2e-126) (/ x a) (/ z b))))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (y <= -4.8e-12) {
		tmp = z / b;
	} else if (y <= 8.2e-126) {
		tmp = x / a;
	} else {
		tmp = z / b;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
    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), intent (in) :: b
    real(8) :: tmp
    if (y <= (-4.8d-12)) then
        tmp = z / b
    else if (y <= 8.2d-126) then
        tmp = x / a
    else
        tmp = z / b
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (y <= -4.8e-12) {
		tmp = z / b;
	} else if (y <= 8.2e-126) {
		tmp = x / a;
	} else {
		tmp = z / b;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	tmp = 0
	if y <= -4.8e-12:
		tmp = z / b
	elif y <= 8.2e-126:
		tmp = x / a
	else:
		tmp = z / b
	return tmp
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (y <= -4.8e-12)
		tmp = Float64(z / b);
	elseif (y <= 8.2e-126)
		tmp = Float64(x / a);
	else
		tmp = Float64(z / b);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if (y <= -4.8e-12)
		tmp = z / b;
	elseif (y <= 8.2e-126)
		tmp = x / a;
	else
		tmp = z / b;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -4.8e-12], N[(z / b), $MachinePrecision], If[LessEqual[y, 8.2e-126], N[(x / a), $MachinePrecision], N[(z / b), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.8 \cdot 10^{-12}:\\
\;\;\;\;\frac{z}{b}\\

\mathbf{elif}\;y \leq 8.2 \cdot 10^{-126}:\\
\;\;\;\;\frac{x}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{z}{b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.79999999999999974e-12 or 8.1999999999999995e-126 < y

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in y around inf

      \[\leadsto \color{blue}{\frac{z}{b}} \]
    3. Applied rewrites33.7%

      \[\leadsto \color{blue}{\frac{z}{b}} \]

    if -4.79999999999999974e-12 < y < 8.1999999999999995e-126

    1. Initial program 76.1%

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in y around 0

      \[\leadsto \color{blue}{\frac{x}{1 + a}} \]
    3. Applied rewrites42.6%

      \[\leadsto \color{blue}{\frac{x}{1 + a}} \]
    4. Taylor expanded in a around inf

      \[\leadsto \frac{x}{\color{blue}{a}} \]
    5. Applied rewrites25.7%

      \[\leadsto \frac{x}{\color{blue}{a}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 11: 25.7% accurate, 5.8× speedup?

\[\begin{array}{l} \\ \frac{x}{a} \end{array} \]
(FPCore (x y z t a b) :precision binary64 (/ x a))
double code(double x, double y, double z, double t, double a, double b) {
	return x / a;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
    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), intent (in) :: b
    code = x / a
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return x / a;
}
def code(x, y, z, t, a, b):
	return x / a
function code(x, y, z, t, a, b)
	return Float64(x / a)
end
function tmp = code(x, y, z, t, a, b)
	tmp = x / a;
end
code[x_, y_, z_, t_, a_, b_] := N[(x / a), $MachinePrecision]
\begin{array}{l}

\\
\frac{x}{a}
\end{array}
Derivation
  1. Initial program 76.1%

    \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
  2. Taylor expanded in y around 0

    \[\leadsto \color{blue}{\frac{x}{1 + a}} \]
  3. Applied rewrites42.6%

    \[\leadsto \color{blue}{\frac{x}{1 + a}} \]
  4. Taylor expanded in a around inf

    \[\leadsto \frac{x}{\color{blue}{a}} \]
  5. Applied rewrites25.7%

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

Reproduce

?
herbie shell --seed 2025161 
(FPCore (x y z t a b)
  :name "Diagrams.Solve.Tridiagonal:solveCyclicTriDiagonal from diagrams-solve-0.1, B"
  :precision binary64
  (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))))