VandenBroeck and Keller, Equation (23)

Percentage Accurate: 77.1% → 99.5%
Time: 6.5s
Alternatives: 22
Speedup: 2.1×

Specification

?
\[\begin{array}{l} \\ \left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (+
  (- (* x (/ 1.0 (tan B))))
  (* (/ F (sin B)) (pow (+ (+ (* F F) 2.0) (* 2.0 x)) (- (/ 1.0 2.0))))))
double code(double F, double B, double x) {
	return -(x * (1.0 / tan(B))) + ((F / sin(B)) * pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)));
}
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(f, b, x)
use fmin_fmax_functions
    real(8), intent (in) :: f
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    code = -(x * (1.0d0 / tan(b))) + ((f / sin(b)) * ((((f * f) + 2.0d0) + (2.0d0 * x)) ** -(1.0d0 / 2.0d0)))
end function
public static double code(double F, double B, double x) {
	return -(x * (1.0 / Math.tan(B))) + ((F / Math.sin(B)) * Math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)));
}
def code(F, B, x):
	return -(x * (1.0 / math.tan(B))) + ((F / math.sin(B)) * math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)))
function code(F, B, x)
	return Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(Float64(F / sin(B)) * (Float64(Float64(Float64(F * F) + 2.0) + Float64(2.0 * x)) ^ Float64(-Float64(1.0 / 2.0)))))
end
function tmp = code(F, B, x)
	tmp = -(x * (1.0 / tan(B))) + ((F / sin(B)) * ((((F * F) + 2.0) + (2.0 * x)) ^ -(1.0 / 2.0)));
end
code[F_, B_, x_] := N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(N[(F / N[Sin[B], $MachinePrecision]), $MachinePrecision] * N[Power[N[(N[(N[(F * F), $MachinePrecision] + 2.0), $MachinePrecision] + N[(2.0 * x), $MachinePrecision]), $MachinePrecision], (-N[(1.0 / 2.0), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}
\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 22 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: 77.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (+
  (- (* x (/ 1.0 (tan B))))
  (* (/ F (sin B)) (pow (+ (+ (* F F) 2.0) (* 2.0 x)) (- (/ 1.0 2.0))))))
double code(double F, double B, double x) {
	return -(x * (1.0 / tan(B))) + ((F / sin(B)) * pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)));
}
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(f, b, x)
use fmin_fmax_functions
    real(8), intent (in) :: f
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    code = -(x * (1.0d0 / tan(b))) + ((f / sin(b)) * ((((f * f) + 2.0d0) + (2.0d0 * x)) ** -(1.0d0 / 2.0d0)))
end function
public static double code(double F, double B, double x) {
	return -(x * (1.0 / Math.tan(B))) + ((F / Math.sin(B)) * Math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)));
}
def code(F, B, x):
	return -(x * (1.0 / math.tan(B))) + ((F / math.sin(B)) * math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)))
function code(F, B, x)
	return Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(Float64(F / sin(B)) * (Float64(Float64(Float64(F * F) + 2.0) + Float64(2.0 * x)) ^ Float64(-Float64(1.0 / 2.0)))))
end
function tmp = code(F, B, x)
	tmp = -(x * (1.0 / tan(B))) + ((F / sin(B)) * ((((F * F) + 2.0) + (2.0 * x)) ^ -(1.0 / 2.0)));
end
code[F_, B_, x_] := N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(N[(F / N[Sin[B], $MachinePrecision]), $MachinePrecision] * N[Power[N[(N[(N[(F * F), $MachinePrecision] + 2.0), $MachinePrecision] + N[(2.0 * x), $MachinePrecision]), $MachinePrecision], (-N[(1.0 / 2.0), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}
\end{array}

Alternative 1: 99.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;F \leq -3 \cdot 10^{+30}:\\ \;\;\;\;-\frac{1 + \cos B \cdot x}{\sin B}\\ \mathbf{elif}\;F \leq 6 \cdot 10^{+40}:\\ \;\;\;\;\left(-\frac{x \cdot 1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F \cdot 1}{\sin B \cdot F}\\ \end{array} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (if (<= F -3e+30)
   (- (/ (+ 1.0 (* (cos B) x)) (sin B)))
   (if (<= F 6e+40)
     (+
      (- (/ (* x 1.0) (tan B)))
      (* (/ F (sin B)) (pow (+ (+ (* F F) 2.0) (* 2.0 x)) (- (/ 1.0 2.0)))))
     (+ (- (* x (/ 1.0 (tan B)))) (/ (* F 1.0) (* (sin B) F))))))
double code(double F, double B, double x) {
	double tmp;
	if (F <= -3e+30) {
		tmp = -((1.0 + (cos(B) * x)) / sin(B));
	} else if (F <= 6e+40) {
		tmp = -((x * 1.0) / tan(B)) + ((F / sin(B)) * pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)));
	} else {
		tmp = -(x * (1.0 / tan(B))) + ((F * 1.0) / (sin(B) * F));
	}
	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(f, b, x)
use fmin_fmax_functions
    real(8), intent (in) :: f
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    real(8) :: tmp
    if (f <= (-3d+30)) then
        tmp = -((1.0d0 + (cos(b) * x)) / sin(b))
    else if (f <= 6d+40) then
        tmp = -((x * 1.0d0) / tan(b)) + ((f / sin(b)) * ((((f * f) + 2.0d0) + (2.0d0 * x)) ** -(1.0d0 / 2.0d0)))
    else
        tmp = -(x * (1.0d0 / tan(b))) + ((f * 1.0d0) / (sin(b) * f))
    end if
    code = tmp
end function
public static double code(double F, double B, double x) {
	double tmp;
	if (F <= -3e+30) {
		tmp = -((1.0 + (Math.cos(B) * x)) / Math.sin(B));
	} else if (F <= 6e+40) {
		tmp = -((x * 1.0) / Math.tan(B)) + ((F / Math.sin(B)) * Math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)));
	} else {
		tmp = -(x * (1.0 / Math.tan(B))) + ((F * 1.0) / (Math.sin(B) * F));
	}
	return tmp;
}
def code(F, B, x):
	tmp = 0
	if F <= -3e+30:
		tmp = -((1.0 + (math.cos(B) * x)) / math.sin(B))
	elif F <= 6e+40:
		tmp = -((x * 1.0) / math.tan(B)) + ((F / math.sin(B)) * math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)))
	else:
		tmp = -(x * (1.0 / math.tan(B))) + ((F * 1.0) / (math.sin(B) * F))
	return tmp
function code(F, B, x)
	tmp = 0.0
	if (F <= -3e+30)
		tmp = Float64(-Float64(Float64(1.0 + Float64(cos(B) * x)) / sin(B)));
	elseif (F <= 6e+40)
		tmp = Float64(Float64(-Float64(Float64(x * 1.0) / tan(B))) + Float64(Float64(F / sin(B)) * (Float64(Float64(Float64(F * F) + 2.0) + Float64(2.0 * x)) ^ Float64(-Float64(1.0 / 2.0)))));
	else
		tmp = Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(Float64(F * 1.0) / Float64(sin(B) * F)));
	end
	return tmp
end
function tmp_2 = code(F, B, x)
	tmp = 0.0;
	if (F <= -3e+30)
		tmp = -((1.0 + (cos(B) * x)) / sin(B));
	elseif (F <= 6e+40)
		tmp = -((x * 1.0) / tan(B)) + ((F / sin(B)) * ((((F * F) + 2.0) + (2.0 * x)) ^ -(1.0 / 2.0)));
	else
		tmp = -(x * (1.0 / tan(B))) + ((F * 1.0) / (sin(B) * F));
	end
	tmp_2 = tmp;
end
code[F_, B_, x_] := If[LessEqual[F, -3e+30], (-N[(N[(1.0 + N[(N[Cos[B], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]), If[LessEqual[F, 6e+40], N[((-N[(N[(x * 1.0), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision]) + N[(N[(F / N[Sin[B], $MachinePrecision]), $MachinePrecision] * N[Power[N[(N[(N[(F * F), $MachinePrecision] + 2.0), $MachinePrecision] + N[(2.0 * x), $MachinePrecision]), $MachinePrecision], (-N[(1.0 / 2.0), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(N[(F * 1.0), $MachinePrecision] / N[(N[Sin[B], $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;F \leq -3 \cdot 10^{+30}:\\
\;\;\;\;-\frac{1 + \cos B \cdot x}{\sin B}\\

\mathbf{elif}\;F \leq 6 \cdot 10^{+40}:\\
\;\;\;\;\left(-\frac{x \cdot 1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}\\

\mathbf{else}:\\
\;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F \cdot 1}{\sin B \cdot F}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if F < -2.99999999999999978e30

    1. Initial program 54.5%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \color{blue}{-1 \cdot \left(\frac{1}{\sin B} + \frac{x \cdot \cos B}{\sin B}\right)} \]
    3. Applied rewrites99.8%

      \[\leadsto \color{blue}{-\frac{1 + \cos B \cdot x}{\sin B}} \]

    if -2.99999999999999978e30 < F < 6.0000000000000004e40

    1. Initial program 99.2%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Applied rewrites99.3%

      \[\leadsto \left(-\color{blue}{\frac{x \cdot 1}{\tan B}}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]

    if 6.0000000000000004e40 < F

    1. Initial program 53.5%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Applied rewrites70.9%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}} \]
    3. Applied rewrites70.9%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}} \]
    4. Taylor expanded in F around inf

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{F \cdot 1}{\sin B \cdot \color{blue}{F}} \]
    5. Applied rewrites99.5%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{F \cdot 1}{\sin B \cdot \color{blue}{F}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 2: 98.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos B \cdot x\\ \mathbf{if}\;F \leq -5 \cdot 10^{+32}:\\ \;\;\;\;-\frac{1 + t\_0}{\sin B}\\ \mathbf{elif}\;F \leq 4.2 \cdot 10^{-22}:\\ \;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - t\_0}{\sin B}\\ \end{array} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (let* ((t_0 (* (cos B) x)))
   (if (<= F -5e+32)
     (- (/ (+ 1.0 t_0) (sin B)))
     (if (<= F 4.2e-22)
       (+
        (- (* x (/ 1.0 (tan B))))
        (* (/ F (sin B)) (pow (+ (+ (* F F) 2.0) (* 2.0 x)) (- (/ 1.0 2.0)))))
       (/ (- 1.0 t_0) (sin B))))))
double code(double F, double B, double x) {
	double t_0 = cos(B) * x;
	double tmp;
	if (F <= -5e+32) {
		tmp = -((1.0 + t_0) / sin(B));
	} else if (F <= 4.2e-22) {
		tmp = -(x * (1.0 / tan(B))) + ((F / sin(B)) * pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)));
	} else {
		tmp = (1.0 - t_0) / sin(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(f, b, x)
use fmin_fmax_functions
    real(8), intent (in) :: f
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    real(8) :: t_0
    real(8) :: tmp
    t_0 = cos(b) * x
    if (f <= (-5d+32)) then
        tmp = -((1.0d0 + t_0) / sin(b))
    else if (f <= 4.2d-22) then
        tmp = -(x * (1.0d0 / tan(b))) + ((f / sin(b)) * ((((f * f) + 2.0d0) + (2.0d0 * x)) ** -(1.0d0 / 2.0d0)))
    else
        tmp = (1.0d0 - t_0) / sin(b)
    end if
    code = tmp
end function
public static double code(double F, double B, double x) {
	double t_0 = Math.cos(B) * x;
	double tmp;
	if (F <= -5e+32) {
		tmp = -((1.0 + t_0) / Math.sin(B));
	} else if (F <= 4.2e-22) {
		tmp = -(x * (1.0 / Math.tan(B))) + ((F / Math.sin(B)) * Math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)));
	} else {
		tmp = (1.0 - t_0) / Math.sin(B);
	}
	return tmp;
}
def code(F, B, x):
	t_0 = math.cos(B) * x
	tmp = 0
	if F <= -5e+32:
		tmp = -((1.0 + t_0) / math.sin(B))
	elif F <= 4.2e-22:
		tmp = -(x * (1.0 / math.tan(B))) + ((F / math.sin(B)) * math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)))
	else:
		tmp = (1.0 - t_0) / math.sin(B)
	return tmp
function code(F, B, x)
	t_0 = Float64(cos(B) * x)
	tmp = 0.0
	if (F <= -5e+32)
		tmp = Float64(-Float64(Float64(1.0 + t_0) / sin(B)));
	elseif (F <= 4.2e-22)
		tmp = Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(Float64(F / sin(B)) * (Float64(Float64(Float64(F * F) + 2.0) + Float64(2.0 * x)) ^ Float64(-Float64(1.0 / 2.0)))));
	else
		tmp = Float64(Float64(1.0 - t_0) / sin(B));
	end
	return tmp
end
function tmp_2 = code(F, B, x)
	t_0 = cos(B) * x;
	tmp = 0.0;
	if (F <= -5e+32)
		tmp = -((1.0 + t_0) / sin(B));
	elseif (F <= 4.2e-22)
		tmp = -(x * (1.0 / tan(B))) + ((F / sin(B)) * ((((F * F) + 2.0) + (2.0 * x)) ^ -(1.0 / 2.0)));
	else
		tmp = (1.0 - t_0) / sin(B);
	end
	tmp_2 = tmp;
end
code[F_, B_, x_] := Block[{t$95$0 = N[(N[Cos[B], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[F, -5e+32], (-N[(N[(1.0 + t$95$0), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]), If[LessEqual[F, 4.2e-22], N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(N[(F / N[Sin[B], $MachinePrecision]), $MachinePrecision] * N[Power[N[(N[(N[(F * F), $MachinePrecision] + 2.0), $MachinePrecision] + N[(2.0 * x), $MachinePrecision]), $MachinePrecision], (-N[(1.0 / 2.0), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - t$95$0), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos B \cdot x\\
\mathbf{if}\;F \leq -5 \cdot 10^{+32}:\\
\;\;\;\;-\frac{1 + t\_0}{\sin B}\\

\mathbf{elif}\;F \leq 4.2 \cdot 10^{-22}:\\
\;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{1 - t\_0}{\sin B}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if F < -4.9999999999999997e32

    1. Initial program 54.2%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \color{blue}{-1 \cdot \left(\frac{1}{\sin B} + \frac{x \cdot \cos B}{\sin B}\right)} \]
    3. Applied rewrites99.8%

      \[\leadsto \color{blue}{-\frac{1 + \cos B \cdot x}{\sin B}} \]

    if -4.9999999999999997e32 < F < 4.20000000000000016e-22

    1. Initial program 99.4%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]

    if 4.20000000000000016e-22 < F

    1. Initial program 60.5%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around inf

      \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x \cdot \cos B}{\sin B}} \]
    3. Applied rewrites95.4%

      \[\leadsto \color{blue}{\frac{1 - \cos B \cdot x}{\sin B}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 98.3% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos B \cdot x\\ \mathbf{if}\;F \leq -5.2 \cdot 10^{+17}:\\ \;\;\;\;-\frac{1 + t\_0}{\sin B}\\ \mathbf{elif}\;F \leq 4.2 \cdot 10^{-22}:\\ \;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{\frac{F}{\sin B} \cdot 1}{\sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - t\_0}{\sin B}\\ \end{array} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (let* ((t_0 (* (cos B) x)))
   (if (<= F -5.2e+17)
     (- (/ (+ 1.0 t_0) (sin B)))
     (if (<= F 4.2e-22)
       (+
        (- (* x (/ 1.0 (tan B))))
        (/ (* (/ F (sin B)) 1.0) (sqrt (fma 2.0 x (fma F F 2.0)))))
       (/ (- 1.0 t_0) (sin B))))))
double code(double F, double B, double x) {
	double t_0 = cos(B) * x;
	double tmp;
	if (F <= -5.2e+17) {
		tmp = -((1.0 + t_0) / sin(B));
	} else if (F <= 4.2e-22) {
		tmp = -(x * (1.0 / tan(B))) + (((F / sin(B)) * 1.0) / sqrt(fma(2.0, x, fma(F, F, 2.0))));
	} else {
		tmp = (1.0 - t_0) / sin(B);
	}
	return tmp;
}
function code(F, B, x)
	t_0 = Float64(cos(B) * x)
	tmp = 0.0
	if (F <= -5.2e+17)
		tmp = Float64(-Float64(Float64(1.0 + t_0) / sin(B)));
	elseif (F <= 4.2e-22)
		tmp = Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(Float64(Float64(F / sin(B)) * 1.0) / sqrt(fma(2.0, x, fma(F, F, 2.0)))));
	else
		tmp = Float64(Float64(1.0 - t_0) / sin(B));
	end
	return tmp
end
code[F_, B_, x_] := Block[{t$95$0 = N[(N[Cos[B], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[F, -5.2e+17], (-N[(N[(1.0 + t$95$0), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]), If[LessEqual[F, 4.2e-22], N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(N[(N[(F / N[Sin[B], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] / N[Sqrt[N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - t$95$0), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos B \cdot x\\
\mathbf{if}\;F \leq -5.2 \cdot 10^{+17}:\\
\;\;\;\;-\frac{1 + t\_0}{\sin B}\\

\mathbf{elif}\;F \leq 4.2 \cdot 10^{-22}:\\
\;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{\frac{F}{\sin B} \cdot 1}{\sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}\\

\mathbf{else}:\\
\;\;\;\;\frac{1 - t\_0}{\sin B}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if F < -5.2e17

    1. Initial program 55.8%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \color{blue}{-1 \cdot \left(\frac{1}{\sin B} + \frac{x \cdot \cos B}{\sin B}\right)} \]
    3. Applied rewrites99.8%

      \[\leadsto \color{blue}{-\frac{1 + \cos B \cdot x}{\sin B}} \]

    if -5.2e17 < F < 4.20000000000000016e-22

    1. Initial program 99.4%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Applied rewrites99.5%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}} \]
    3. Applied rewrites99.4%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{\frac{F}{\sin B} \cdot 1}{\sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}} \]

    if 4.20000000000000016e-22 < F

    1. Initial program 60.5%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around inf

      \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x \cdot \cos B}{\sin B}} \]
    3. Applied rewrites95.4%

      \[\leadsto \color{blue}{\frac{1 - \cos B \cdot x}{\sin B}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 4: 98.4% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos B \cdot x\\ \mathbf{if}\;F \leq -5.2 \cdot 10^{+17}:\\ \;\;\;\;-\frac{1 + t\_0}{\sin B}\\ \mathbf{elif}\;F \leq 4.2 \cdot 10^{-22}:\\ \;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - t\_0}{\sin B}\\ \end{array} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (let* ((t_0 (* (cos B) x)))
   (if (<= F -5.2e+17)
     (- (/ (+ 1.0 t_0) (sin B)))
     (if (<= F 4.2e-22)
       (+
        (- (* x (/ 1.0 (tan B))))
        (/ (* F 1.0) (* (sin B) (sqrt (fma 2.0 x (fma F F 2.0))))))
       (/ (- 1.0 t_0) (sin B))))))
double code(double F, double B, double x) {
	double t_0 = cos(B) * x;
	double tmp;
	if (F <= -5.2e+17) {
		tmp = -((1.0 + t_0) / sin(B));
	} else if (F <= 4.2e-22) {
		tmp = -(x * (1.0 / tan(B))) + ((F * 1.0) / (sin(B) * sqrt(fma(2.0, x, fma(F, F, 2.0)))));
	} else {
		tmp = (1.0 - t_0) / sin(B);
	}
	return tmp;
}
function code(F, B, x)
	t_0 = Float64(cos(B) * x)
	tmp = 0.0
	if (F <= -5.2e+17)
		tmp = Float64(-Float64(Float64(1.0 + t_0) / sin(B)));
	elseif (F <= 4.2e-22)
		tmp = Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(Float64(F * 1.0) / Float64(sin(B) * sqrt(fma(2.0, x, fma(F, F, 2.0))))));
	else
		tmp = Float64(Float64(1.0 - t_0) / sin(B));
	end
	return tmp
end
code[F_, B_, x_] := Block[{t$95$0 = N[(N[Cos[B], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[F, -5.2e+17], (-N[(N[(1.0 + t$95$0), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]), If[LessEqual[F, 4.2e-22], N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(N[(F * 1.0), $MachinePrecision] / N[(N[Sin[B], $MachinePrecision] * N[Sqrt[N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - t$95$0), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos B \cdot x\\
\mathbf{if}\;F \leq -5.2 \cdot 10^{+17}:\\
\;\;\;\;-\frac{1 + t\_0}{\sin B}\\

\mathbf{elif}\;F \leq 4.2 \cdot 10^{-22}:\\
\;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}\\

\mathbf{else}:\\
\;\;\;\;\frac{1 - t\_0}{\sin B}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if F < -5.2e17

    1. Initial program 55.8%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \color{blue}{-1 \cdot \left(\frac{1}{\sin B} + \frac{x \cdot \cos B}{\sin B}\right)} \]
    3. Applied rewrites99.8%

      \[\leadsto \color{blue}{-\frac{1 + \cos B \cdot x}{\sin B}} \]

    if -5.2e17 < F < 4.20000000000000016e-22

    1. Initial program 99.4%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Applied rewrites99.5%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}} \]
    3. Applied rewrites99.4%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}} \]

    if 4.20000000000000016e-22 < F

    1. Initial program 60.5%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around inf

      \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x \cdot \cos B}{\sin B}} \]
    3. Applied rewrites95.4%

      \[\leadsto \color{blue}{\frac{1 - \cos B \cdot x}{\sin B}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 98.1% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos B \cdot x\\ \mathbf{if}\;F \leq -1.5:\\ \;\;\;\;-\frac{1 + t\_0}{\sin B}\\ \mathbf{elif}\;F \leq 4.2 \cdot 10^{-22}:\\ \;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, 2\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - t\_0}{\sin B}\\ \end{array} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (let* ((t_0 (* (cos B) x)))
   (if (<= F -1.5)
     (- (/ (+ 1.0 t_0) (sin B)))
     (if (<= F 4.2e-22)
       (+
        (- (* x (/ 1.0 (tan B))))
        (/ (* F 1.0) (* (sin B) (sqrt (fma 2.0 x 2.0)))))
       (/ (- 1.0 t_0) (sin B))))))
double code(double F, double B, double x) {
	double t_0 = cos(B) * x;
	double tmp;
	if (F <= -1.5) {
		tmp = -((1.0 + t_0) / sin(B));
	} else if (F <= 4.2e-22) {
		tmp = -(x * (1.0 / tan(B))) + ((F * 1.0) / (sin(B) * sqrt(fma(2.0, x, 2.0))));
	} else {
		tmp = (1.0 - t_0) / sin(B);
	}
	return tmp;
}
function code(F, B, x)
	t_0 = Float64(cos(B) * x)
	tmp = 0.0
	if (F <= -1.5)
		tmp = Float64(-Float64(Float64(1.0 + t_0) / sin(B)));
	elseif (F <= 4.2e-22)
		tmp = Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(Float64(F * 1.0) / Float64(sin(B) * sqrt(fma(2.0, x, 2.0)))));
	else
		tmp = Float64(Float64(1.0 - t_0) / sin(B));
	end
	return tmp
end
code[F_, B_, x_] := Block[{t$95$0 = N[(N[Cos[B], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[F, -1.5], (-N[(N[(1.0 + t$95$0), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]), If[LessEqual[F, 4.2e-22], N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(N[(F * 1.0), $MachinePrecision] / N[(N[Sin[B], $MachinePrecision] * N[Sqrt[N[(2.0 * x + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - t$95$0), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos B \cdot x\\
\mathbf{if}\;F \leq -1.5:\\
\;\;\;\;-\frac{1 + t\_0}{\sin B}\\

\mathbf{elif}\;F \leq 4.2 \cdot 10^{-22}:\\
\;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, 2\right)}}\\

\mathbf{else}:\\
\;\;\;\;\frac{1 - t\_0}{\sin B}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if F < -1.5

    1. Initial program 58.0%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \color{blue}{-1 \cdot \left(\frac{1}{\sin B} + \frac{x \cdot \cos B}{\sin B}\right)} \]
    3. Applied rewrites99.2%

      \[\leadsto \color{blue}{-\frac{1 + \cos B \cdot x}{\sin B}} \]

    if -1.5 < F < 4.20000000000000016e-22

    1. Initial program 99.5%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Applied rewrites99.5%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}} \]
    3. Applied rewrites99.4%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}} \]
    4. Taylor expanded in F around 0

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \color{blue}{2}\right)}} \]
    5. Applied rewrites99.1%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \color{blue}{2}\right)}} \]

    if 4.20000000000000016e-22 < F

    1. Initial program 60.5%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around inf

      \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x \cdot \cos B}{\sin B}} \]
    3. Applied rewrites95.4%

      \[\leadsto \color{blue}{\frac{1 - \cos B \cdot x}{\sin B}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 6: 85.8% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\\ t_1 := -x \cdot \frac{1}{\tan B}\\ \mathbf{if}\;F \leq -1.25 \cdot 10^{+154}:\\ \;\;\;\;t\_1 + \frac{-1}{\mathsf{fma}\left(-0.16666666666666666, B \cdot B, 1\right) \cdot B}\\ \mathbf{elif}\;F \leq -2.9 \cdot 10^{-30}:\\ \;\;\;\;\frac{-x}{B} + \frac{F \cdot 1}{\sin B \cdot \sqrt{t\_0}}\\ \mathbf{elif}\;F \leq 4.2 \cdot 10^{-22}:\\ \;\;\;\;t\_1 + \frac{F}{B} \cdot \sqrt{\frac{1}{t\_0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - \cos B \cdot x}{\sin B}\\ \end{array} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (let* ((t_0 (fma 2.0 x (fma F F 2.0))) (t_1 (- (* x (/ 1.0 (tan B))))))
   (if (<= F -1.25e+154)
     (+ t_1 (/ -1.0 (* (fma -0.16666666666666666 (* B B) 1.0) B)))
     (if (<= F -2.9e-30)
       (+ (/ (- x) B) (/ (* F 1.0) (* (sin B) (sqrt t_0))))
       (if (<= F 4.2e-22)
         (+ t_1 (* (/ F B) (sqrt (/ 1.0 t_0))))
         (/ (- 1.0 (* (cos B) x)) (sin B)))))))
double code(double F, double B, double x) {
	double t_0 = fma(2.0, x, fma(F, F, 2.0));
	double t_1 = -(x * (1.0 / tan(B)));
	double tmp;
	if (F <= -1.25e+154) {
		tmp = t_1 + (-1.0 / (fma(-0.16666666666666666, (B * B), 1.0) * B));
	} else if (F <= -2.9e-30) {
		tmp = (-x / B) + ((F * 1.0) / (sin(B) * sqrt(t_0)));
	} else if (F <= 4.2e-22) {
		tmp = t_1 + ((F / B) * sqrt((1.0 / t_0)));
	} else {
		tmp = (1.0 - (cos(B) * x)) / sin(B);
	}
	return tmp;
}
function code(F, B, x)
	t_0 = fma(2.0, x, fma(F, F, 2.0))
	t_1 = Float64(-Float64(x * Float64(1.0 / tan(B))))
	tmp = 0.0
	if (F <= -1.25e+154)
		tmp = Float64(t_1 + Float64(-1.0 / Float64(fma(-0.16666666666666666, Float64(B * B), 1.0) * B)));
	elseif (F <= -2.9e-30)
		tmp = Float64(Float64(Float64(-x) / B) + Float64(Float64(F * 1.0) / Float64(sin(B) * sqrt(t_0))));
	elseif (F <= 4.2e-22)
		tmp = Float64(t_1 + Float64(Float64(F / B) * sqrt(Float64(1.0 / t_0))));
	else
		tmp = Float64(Float64(1.0 - Float64(cos(B) * x)) / sin(B));
	end
	return tmp
end
code[F_, B_, x_] := Block[{t$95$0 = N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = (-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision])}, If[LessEqual[F, -1.25e+154], N[(t$95$1 + N[(-1.0 / N[(N[(-0.16666666666666666 * N[(B * B), $MachinePrecision] + 1.0), $MachinePrecision] * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, -2.9e-30], N[(N[((-x) / B), $MachinePrecision] + N[(N[(F * 1.0), $MachinePrecision] / N[(N[Sin[B], $MachinePrecision] * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 4.2e-22], N[(t$95$1 + N[(N[(F / B), $MachinePrecision] * N[Sqrt[N[(1.0 / t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(N[Cos[B], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\\
t_1 := -x \cdot \frac{1}{\tan B}\\
\mathbf{if}\;F \leq -1.25 \cdot 10^{+154}:\\
\;\;\;\;t\_1 + \frac{-1}{\mathsf{fma}\left(-0.16666666666666666, B \cdot B, 1\right) \cdot B}\\

\mathbf{elif}\;F \leq -2.9 \cdot 10^{-30}:\\
\;\;\;\;\frac{-x}{B} + \frac{F \cdot 1}{\sin B \cdot \sqrt{t\_0}}\\

\mathbf{elif}\;F \leq 4.2 \cdot 10^{-22}:\\
\;\;\;\;t\_1 + \frac{F}{B} \cdot \sqrt{\frac{1}{t\_0}}\\

\mathbf{else}:\\
\;\;\;\;\frac{1 - \cos B \cdot x}{\sin B}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if F < -1.25000000000000001e154

    1. Initial program 30.3%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    3. Applied rewrites99.6%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B \cdot \color{blue}{\left(1 + \frac{-1}{6} \cdot {B}^{2}\right)}} \]
    5. Applied rewrites75.6%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{\mathsf{fma}\left(-0.16666666666666666, B \cdot B, 1\right) \cdot \color{blue}{B}} \]

    if -1.25000000000000001e154 < F < -2.89999999999999989e-30

    1. Initial program 91.1%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Applied rewrites99.6%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}} \]
    3. Applied rewrites99.5%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{B}} + \frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \]
    5. Applied rewrites78.9%

      \[\leadsto \color{blue}{\frac{-x}{B}} + \frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \]

    if -2.89999999999999989e-30 < F < 4.20000000000000016e-22

    1. Initial program 99.5%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in B around 0

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F}{B} \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}} \]
    3. Applied rewrites85.2%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F}{B} \cdot \sqrt{{\left(\mathsf{fma}\left(2, x, F \cdot F\right) + 2\right)}^{-1}}} \]
    4. Applied rewrites85.2%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{B} \cdot \sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \]

    if 4.20000000000000016e-22 < F

    1. Initial program 60.5%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around inf

      \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x \cdot \cos B}{\sin B}} \]
    3. Applied rewrites95.4%

      \[\leadsto \color{blue}{\frac{1 - \cos B \cdot x}{\sin B}} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 7: 91.3% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos B \cdot x\\ \mathbf{if}\;F \leq -7 \cdot 10^{-15}:\\ \;\;\;\;-\frac{1 + t\_0}{\sin B}\\ \mathbf{elif}\;F \leq 4.2 \cdot 10^{-22}:\\ \;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F \cdot 1}{B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - t\_0}{\sin B}\\ \end{array} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (let* ((t_0 (* (cos B) x)))
   (if (<= F -7e-15)
     (- (/ (+ 1.0 t_0) (sin B)))
     (if (<= F 4.2e-22)
       (+
        (- (* x (/ 1.0 (tan B))))
        (/ (* F 1.0) (* B (sqrt (fma 2.0 x (fma F F 2.0))))))
       (/ (- 1.0 t_0) (sin B))))))
double code(double F, double B, double x) {
	double t_0 = cos(B) * x;
	double tmp;
	if (F <= -7e-15) {
		tmp = -((1.0 + t_0) / sin(B));
	} else if (F <= 4.2e-22) {
		tmp = -(x * (1.0 / tan(B))) + ((F * 1.0) / (B * sqrt(fma(2.0, x, fma(F, F, 2.0)))));
	} else {
		tmp = (1.0 - t_0) / sin(B);
	}
	return tmp;
}
function code(F, B, x)
	t_0 = Float64(cos(B) * x)
	tmp = 0.0
	if (F <= -7e-15)
		tmp = Float64(-Float64(Float64(1.0 + t_0) / sin(B)));
	elseif (F <= 4.2e-22)
		tmp = Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(Float64(F * 1.0) / Float64(B * sqrt(fma(2.0, x, fma(F, F, 2.0))))));
	else
		tmp = Float64(Float64(1.0 - t_0) / sin(B));
	end
	return tmp
end
code[F_, B_, x_] := Block[{t$95$0 = N[(N[Cos[B], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[F, -7e-15], (-N[(N[(1.0 + t$95$0), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]), If[LessEqual[F, 4.2e-22], N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(N[(F * 1.0), $MachinePrecision] / N[(B * N[Sqrt[N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - t$95$0), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos B \cdot x\\
\mathbf{if}\;F \leq -7 \cdot 10^{-15}:\\
\;\;\;\;-\frac{1 + t\_0}{\sin B}\\

\mathbf{elif}\;F \leq 4.2 \cdot 10^{-22}:\\
\;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F \cdot 1}{B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}\\

\mathbf{else}:\\
\;\;\;\;\frac{1 - t\_0}{\sin B}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if F < -7.0000000000000001e-15

    1. Initial program 59.8%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \color{blue}{-1 \cdot \left(\frac{1}{\sin B} + \frac{x \cdot \cos B}{\sin B}\right)} \]
    3. Applied rewrites96.7%

      \[\leadsto \color{blue}{-\frac{1 + \cos B \cdot x}{\sin B}} \]

    if -7.0000000000000001e-15 < F < 4.20000000000000016e-22

    1. Initial program 99.5%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Applied rewrites99.5%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}} \]
    3. Applied rewrites99.4%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{F \cdot 1}{\color{blue}{B} \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \]
    5. Applied rewrites84.9%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{F \cdot 1}{\color{blue}{B} \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \]

    if 4.20000000000000016e-22 < F

    1. Initial program 60.5%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around inf

      \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x \cdot \cos B}{\sin B}} \]
    3. Applied rewrites95.4%

      \[\leadsto \color{blue}{\frac{1 - \cos B \cdot x}{\sin B}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 8: 78.8% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}\\ t_1 := \left(-x \cdot \frac{1}{\tan B}\right) + \frac{F \cdot 1}{B \cdot t\_0}\\ \mathbf{if}\;x \leq -1.08 \cdot 10^{-48}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 9.8 \cdot 10^{-27}:\\ \;\;\;\;\frac{-x}{B} + \frac{F \cdot 1}{\sin B \cdot t\_0}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (let* ((t_0 (sqrt (fma 2.0 x (fma F F 2.0))))
        (t_1 (+ (- (* x (/ 1.0 (tan B)))) (/ (* F 1.0) (* B t_0)))))
   (if (<= x -1.08e-48)
     t_1
     (if (<= x 9.8e-27) (+ (/ (- x) B) (/ (* F 1.0) (* (sin B) t_0))) t_1))))
double code(double F, double B, double x) {
	double t_0 = sqrt(fma(2.0, x, fma(F, F, 2.0)));
	double t_1 = -(x * (1.0 / tan(B))) + ((F * 1.0) / (B * t_0));
	double tmp;
	if (x <= -1.08e-48) {
		tmp = t_1;
	} else if (x <= 9.8e-27) {
		tmp = (-x / B) + ((F * 1.0) / (sin(B) * t_0));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(F, B, x)
	t_0 = sqrt(fma(2.0, x, fma(F, F, 2.0)))
	t_1 = Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(Float64(F * 1.0) / Float64(B * t_0)))
	tmp = 0.0
	if (x <= -1.08e-48)
		tmp = t_1;
	elseif (x <= 9.8e-27)
		tmp = Float64(Float64(Float64(-x) / B) + Float64(Float64(F * 1.0) / Float64(sin(B) * t_0)));
	else
		tmp = t_1;
	end
	return tmp
end
code[F_, B_, x_] := Block[{t$95$0 = N[Sqrt[N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(N[(F * 1.0), $MachinePrecision] / N[(B * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.08e-48], t$95$1, If[LessEqual[x, 9.8e-27], N[(N[((-x) / B), $MachinePrecision] + N[(N[(F * 1.0), $MachinePrecision] / N[(N[Sin[B], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}\\
t_1 := \left(-x \cdot \frac{1}{\tan B}\right) + \frac{F \cdot 1}{B \cdot t\_0}\\
\mathbf{if}\;x \leq -1.08 \cdot 10^{-48}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 9.8 \cdot 10^{-27}:\\
\;\;\;\;\frac{-x}{B} + \frac{F \cdot 1}{\sin B \cdot t\_0}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.08e-48 or 9.79999999999999952e-27 < x

    1. Initial program 80.9%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Applied rewrites95.6%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}} \]
    3. Applied rewrites95.6%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{F \cdot 1}{\color{blue}{B} \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \]
    5. Applied rewrites93.3%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{F \cdot 1}{\color{blue}{B} \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \]

    if -1.08e-48 < x < 9.79999999999999952e-27

    1. Initial program 73.4%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Applied rewrites76.7%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}} \]
    3. Applied rewrites76.7%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{B}} + \frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \]
    5. Applied rewrites65.2%

      \[\leadsto \color{blue}{\frac{-x}{B}} + \frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 77.5% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-30}:\\ \;\;\;\;\left(-\frac{x \cdot 1}{\tan B}\right) + \frac{-1}{\mathsf{fma}\left(0.008333333333333333 \cdot \left(B \cdot B\right) - 0.16666666666666666, B \cdot B, 1\right) \cdot B}\\ \mathbf{elif}\;x \leq 0.00033:\\ \;\;\;\;\frac{-x}{B} + \frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B}\\ \end{array} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (if (<= x -2e-30)
   (+
    (- (/ (* x 1.0) (tan B)))
    (/
     -1.0
     (*
      (fma
       (- (* 0.008333333333333333 (* B B)) 0.16666666666666666)
       (* B B)
       1.0)
      B)))
   (if (<= x 0.00033)
     (+ (/ (- x) B) (/ (* F 1.0) (* (sin B) (sqrt (fma 2.0 x (fma F F 2.0))))))
     (+ (- (* x (/ 1.0 (tan B)))) (/ -1.0 B)))))
double code(double F, double B, double x) {
	double tmp;
	if (x <= -2e-30) {
		tmp = -((x * 1.0) / tan(B)) + (-1.0 / (fma(((0.008333333333333333 * (B * B)) - 0.16666666666666666), (B * B), 1.0) * B));
	} else if (x <= 0.00033) {
		tmp = (-x / B) + ((F * 1.0) / (sin(B) * sqrt(fma(2.0, x, fma(F, F, 2.0)))));
	} else {
		tmp = -(x * (1.0 / tan(B))) + (-1.0 / B);
	}
	return tmp;
}
function code(F, B, x)
	tmp = 0.0
	if (x <= -2e-30)
		tmp = Float64(Float64(-Float64(Float64(x * 1.0) / tan(B))) + Float64(-1.0 / Float64(fma(Float64(Float64(0.008333333333333333 * Float64(B * B)) - 0.16666666666666666), Float64(B * B), 1.0) * B)));
	elseif (x <= 0.00033)
		tmp = Float64(Float64(Float64(-x) / B) + Float64(Float64(F * 1.0) / Float64(sin(B) * sqrt(fma(2.0, x, fma(F, F, 2.0))))));
	else
		tmp = Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(-1.0 / B));
	end
	return tmp
end
code[F_, B_, x_] := If[LessEqual[x, -2e-30], N[((-N[(N[(x * 1.0), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision]) + N[(-1.0 / N[(N[(N[(N[(0.008333333333333333 * N[(B * B), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(B * B), $MachinePrecision] + 1.0), $MachinePrecision] * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.00033], N[(N[((-x) / B), $MachinePrecision] + N[(N[(F * 1.0), $MachinePrecision] / N[(N[Sin[B], $MachinePrecision] * N[Sqrt[N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-30}:\\
\;\;\;\;\left(-\frac{x \cdot 1}{\tan B}\right) + \frac{-1}{\mathsf{fma}\left(0.008333333333333333 \cdot \left(B \cdot B\right) - 0.16666666666666666, B \cdot B, 1\right) \cdot B}\\

\mathbf{elif}\;x \leq 0.00033:\\
\;\;\;\;\frac{-x}{B} + \frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}\\

\mathbf{else}:\\
\;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2e-30

    1. Initial program 69.1%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    3. Applied rewrites82.7%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B \cdot \color{blue}{\left(1 + {B}^{2} \cdot \left(\frac{1}{120} \cdot {B}^{2} - \frac{1}{6}\right)\right)}} \]
    5. Applied rewrites84.7%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{\mathsf{fma}\left(0.008333333333333333 \cdot \left(B \cdot B\right) - 0.16666666666666666, B \cdot B, 1\right) \cdot \color{blue}{B}} \]
    6. Applied rewrites84.9%

      \[\leadsto \left(-\color{blue}{\frac{x \cdot 1}{\tan B}}\right) + \frac{-1}{\mathsf{fma}\left(0.008333333333333333 \cdot \left(B \cdot B\right) - 0.16666666666666666, B \cdot B, 1\right) \cdot B} \]

    if -2e-30 < x < 3.3e-4

    1. Initial program 73.4%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Applied rewrites76.8%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}} \]
    3. Applied rewrites76.7%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{B}} + \frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \]
    5. Applied rewrites64.6%

      \[\leadsto \color{blue}{\frac{-x}{B}} + \frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \]

    if 3.3e-4 < x

    1. Initial program 87.2%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    3. Applied rewrites96.9%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B} \]
    5. Applied rewrites97.3%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 10: 77.8% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.85 \cdot 10^{-12}:\\ \;\;\;\;\left(-\frac{x \cdot 1}{\tan B}\right) + \frac{-1}{B}\\ \mathbf{elif}\;x \leq 0.00033:\\ \;\;\;\;\frac{-x}{B} + \frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B}\\ \end{array} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (if (<= x -1.85e-12)
   (+ (- (/ (* x 1.0) (tan B))) (/ -1.0 B))
   (if (<= x 0.00033)
     (+ (/ (- x) B) (/ (* F 1.0) (* (sin B) (sqrt (fma 2.0 x (fma F F 2.0))))))
     (+ (- (* x (/ 1.0 (tan B)))) (/ -1.0 B)))))
double code(double F, double B, double x) {
	double tmp;
	if (x <= -1.85e-12) {
		tmp = -((x * 1.0) / tan(B)) + (-1.0 / B);
	} else if (x <= 0.00033) {
		tmp = (-x / B) + ((F * 1.0) / (sin(B) * sqrt(fma(2.0, x, fma(F, F, 2.0)))));
	} else {
		tmp = -(x * (1.0 / tan(B))) + (-1.0 / B);
	}
	return tmp;
}
function code(F, B, x)
	tmp = 0.0
	if (x <= -1.85e-12)
		tmp = Float64(Float64(-Float64(Float64(x * 1.0) / tan(B))) + Float64(-1.0 / B));
	elseif (x <= 0.00033)
		tmp = Float64(Float64(Float64(-x) / B) + Float64(Float64(F * 1.0) / Float64(sin(B) * sqrt(fma(2.0, x, fma(F, F, 2.0))))));
	else
		tmp = Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(-1.0 / B));
	end
	return tmp
end
code[F_, B_, x_] := If[LessEqual[x, -1.85e-12], N[((-N[(N[(x * 1.0), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision]) + N[(-1.0 / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.00033], N[(N[((-x) / B), $MachinePrecision] + N[(N[(F * 1.0), $MachinePrecision] / N[(N[Sin[B], $MachinePrecision] * N[Sqrt[N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.85 \cdot 10^{-12}:\\
\;\;\;\;\left(-\frac{x \cdot 1}{\tan B}\right) + \frac{-1}{B}\\

\mathbf{elif}\;x \leq 0.00033:\\
\;\;\;\;\frac{-x}{B} + \frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}\\

\mathbf{else}:\\
\;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.84999999999999999e-12

    1. Initial program 68.2%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    3. Applied rewrites90.9%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B \cdot \color{blue}{\left(1 + {B}^{2} \cdot \left(\frac{1}{120} \cdot {B}^{2} - \frac{1}{6}\right)\right)}} \]
    5. Applied rewrites91.7%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{\mathsf{fma}\left(0.008333333333333333 \cdot \left(B \cdot B\right) - 0.16666666666666666, B \cdot B, 1\right) \cdot \color{blue}{B}} \]
    6. Taylor expanded in B around 0

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B} \]
    7. Applied rewrites91.7%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B} \]
    8. Applied rewrites91.9%

      \[\leadsto \left(-\color{blue}{\frac{x \cdot 1}{\tan B}}\right) + \frac{-1}{B} \]

    if -1.84999999999999999e-12 < x < 3.3e-4

    1. Initial program 73.5%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Applied rewrites76.8%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}} \]
    3. Applied rewrites76.8%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{B}} + \frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \]
    5. Applied rewrites64.3%

      \[\leadsto \color{blue}{\frac{-x}{B}} + \frac{F \cdot 1}{\sin B \cdot \sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \]

    if 3.3e-4 < x

    1. Initial program 87.2%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    3. Applied rewrites96.9%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B} \]
    5. Applied rewrites97.3%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 11: 69.4% accurate, 2.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -x \cdot \frac{1}{\tan B}\\ \mathbf{if}\;x \leq -5 \cdot 10^{-48}:\\ \;\;\;\;t\_0 + \frac{-1}{\mathsf{fma}\left(0.008333333333333333 \cdot \left(B \cdot B\right), B \cdot B, 1\right) \cdot B}\\ \mathbf{elif}\;x \leq 5.4 \cdot 10^{-86}:\\ \;\;\;\;\frac{1}{\sqrt{\mathsf{fma}\left(F, F, 2\right)}} \cdot \frac{F}{\sin B}\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-9}:\\ \;\;\;\;\frac{F}{B} \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5} - \frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;t\_0 + \frac{-1}{B}\\ \end{array} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (let* ((t_0 (- (* x (/ 1.0 (tan B))))))
   (if (<= x -5e-48)
     (+ t_0 (/ -1.0 (* (fma (* 0.008333333333333333 (* B B)) (* B B) 1.0) B)))
     (if (<= x 5.4e-86)
       (* (/ 1.0 (sqrt (fma F F 2.0))) (/ F (sin B)))
       (if (<= x 1.6e-9)
         (- (* (/ F B) (pow (fma 2.0 x (fma F F 2.0)) -0.5)) (/ x B))
         (+ t_0 (/ -1.0 B)))))))
double code(double F, double B, double x) {
	double t_0 = -(x * (1.0 / tan(B)));
	double tmp;
	if (x <= -5e-48) {
		tmp = t_0 + (-1.0 / (fma((0.008333333333333333 * (B * B)), (B * B), 1.0) * B));
	} else if (x <= 5.4e-86) {
		tmp = (1.0 / sqrt(fma(F, F, 2.0))) * (F / sin(B));
	} else if (x <= 1.6e-9) {
		tmp = ((F / B) * pow(fma(2.0, x, fma(F, F, 2.0)), -0.5)) - (x / B);
	} else {
		tmp = t_0 + (-1.0 / B);
	}
	return tmp;
}
function code(F, B, x)
	t_0 = Float64(-Float64(x * Float64(1.0 / tan(B))))
	tmp = 0.0
	if (x <= -5e-48)
		tmp = Float64(t_0 + Float64(-1.0 / Float64(fma(Float64(0.008333333333333333 * Float64(B * B)), Float64(B * B), 1.0) * B)));
	elseif (x <= 5.4e-86)
		tmp = Float64(Float64(1.0 / sqrt(fma(F, F, 2.0))) * Float64(F / sin(B)));
	elseif (x <= 1.6e-9)
		tmp = Float64(Float64(Float64(F / B) * (fma(2.0, x, fma(F, F, 2.0)) ^ -0.5)) - Float64(x / B));
	else
		tmp = Float64(t_0 + Float64(-1.0 / B));
	end
	return tmp
end
code[F_, B_, x_] := Block[{t$95$0 = (-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision])}, If[LessEqual[x, -5e-48], N[(t$95$0 + N[(-1.0 / N[(N[(N[(0.008333333333333333 * N[(B * B), $MachinePrecision]), $MachinePrecision] * N[(B * B), $MachinePrecision] + 1.0), $MachinePrecision] * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.4e-86], N[(N[(1.0 / N[Sqrt[N[(F * F + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(F / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.6e-9], N[(N[(N[(F / B), $MachinePrecision] * N[Power[N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -x \cdot \frac{1}{\tan B}\\
\mathbf{if}\;x \leq -5 \cdot 10^{-48}:\\
\;\;\;\;t\_0 + \frac{-1}{\mathsf{fma}\left(0.008333333333333333 \cdot \left(B \cdot B\right), B \cdot B, 1\right) \cdot B}\\

\mathbf{elif}\;x \leq 5.4 \cdot 10^{-86}:\\
\;\;\;\;\frac{1}{\sqrt{\mathsf{fma}\left(F, F, 2\right)}} \cdot \frac{F}{\sin B}\\

\mathbf{elif}\;x \leq 1.6 \cdot 10^{-9}:\\
\;\;\;\;\frac{F}{B} \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5} - \frac{x}{B}\\

\mathbf{else}:\\
\;\;\;\;t\_0 + \frac{-1}{B}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -4.9999999999999999e-48

    1. Initial program 69.7%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    3. Applied rewrites76.2%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B \cdot \color{blue}{\left(1 + {B}^{2} \cdot \left(\frac{1}{120} \cdot {B}^{2} - \frac{1}{6}\right)\right)}} \]
    5. Applied rewrites78.9%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{\mathsf{fma}\left(0.008333333333333333 \cdot \left(B \cdot B\right) - 0.16666666666666666, B \cdot B, 1\right) \cdot \color{blue}{B}} \]
    6. Taylor expanded in B around inf

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{\mathsf{fma}\left(\frac{1}{120} \cdot {B}^{2}, B \cdot B, 1\right) \cdot B} \]
    7. Applied rewrites78.9%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{\mathsf{fma}\left(0.008333333333333333 \cdot \left(B \cdot B\right), B \cdot B, 1\right) \cdot B} \]

    if -4.9999999999999999e-48 < x < 5.39999999999999985e-86

    1. Initial program 73.6%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Applied rewrites77.0%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}} \]
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{F}{\sin B} \cdot \sqrt{\frac{1}{2 + {F}^{2}}}} \]
    4. Applied rewrites53.1%

      \[\leadsto \color{blue}{\sqrt{{\left(\mathsf{fma}\left(F, F, 2\right)\right)}^{-1}} \cdot \frac{F}{\sin B}} \]
    5. Applied rewrites53.0%

      \[\leadsto \frac{1}{\sqrt{\mathsf{fma}\left(F, F, 2\right)}} \cdot \frac{\color{blue}{F}}{\sin B} \]

    if 5.39999999999999985e-86 < x < 1.60000000000000006e-9

    1. Initial program 72.6%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in B around 0

      \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
    3. Applied rewrites39.4%

      \[\leadsto \color{blue}{\frac{\sqrt{{\left(\mathsf{fma}\left(2, x, F \cdot F\right) + 2\right)}^{-1}} \cdot F - x}{B}} \]
    4. Applied rewrites36.8%

      \[\leadsto \frac{F}{B} \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5} - \color{blue}{\frac{x}{B}} \]

    if 1.60000000000000006e-9 < x

    1. Initial program 86.9%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    3. Applied rewrites96.0%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B} \]
    5. Applied rewrites96.4%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 12: 69.4% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -x \cdot \frac{1}{\tan B}\\ \mathbf{if}\;x \leq -5 \cdot 10^{-48}:\\ \;\;\;\;t\_0 + \frac{-1}{\mathsf{fma}\left(-0.16666666666666666, B \cdot B, 1\right) \cdot B}\\ \mathbf{elif}\;x \leq 5.4 \cdot 10^{-86}:\\ \;\;\;\;\frac{1}{\sqrt{\mathsf{fma}\left(F, F, 2\right)}} \cdot \frac{F}{\sin B}\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-9}:\\ \;\;\;\;\frac{F}{B} \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5} - \frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;t\_0 + \frac{-1}{B}\\ \end{array} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (let* ((t_0 (- (* x (/ 1.0 (tan B))))))
   (if (<= x -5e-48)
     (+ t_0 (/ -1.0 (* (fma -0.16666666666666666 (* B B) 1.0) B)))
     (if (<= x 5.4e-86)
       (* (/ 1.0 (sqrt (fma F F 2.0))) (/ F (sin B)))
       (if (<= x 1.6e-9)
         (- (* (/ F B) (pow (fma 2.0 x (fma F F 2.0)) -0.5)) (/ x B))
         (+ t_0 (/ -1.0 B)))))))
double code(double F, double B, double x) {
	double t_0 = -(x * (1.0 / tan(B)));
	double tmp;
	if (x <= -5e-48) {
		tmp = t_0 + (-1.0 / (fma(-0.16666666666666666, (B * B), 1.0) * B));
	} else if (x <= 5.4e-86) {
		tmp = (1.0 / sqrt(fma(F, F, 2.0))) * (F / sin(B));
	} else if (x <= 1.6e-9) {
		tmp = ((F / B) * pow(fma(2.0, x, fma(F, F, 2.0)), -0.5)) - (x / B);
	} else {
		tmp = t_0 + (-1.0 / B);
	}
	return tmp;
}
function code(F, B, x)
	t_0 = Float64(-Float64(x * Float64(1.0 / tan(B))))
	tmp = 0.0
	if (x <= -5e-48)
		tmp = Float64(t_0 + Float64(-1.0 / Float64(fma(-0.16666666666666666, Float64(B * B), 1.0) * B)));
	elseif (x <= 5.4e-86)
		tmp = Float64(Float64(1.0 / sqrt(fma(F, F, 2.0))) * Float64(F / sin(B)));
	elseif (x <= 1.6e-9)
		tmp = Float64(Float64(Float64(F / B) * (fma(2.0, x, fma(F, F, 2.0)) ^ -0.5)) - Float64(x / B));
	else
		tmp = Float64(t_0 + Float64(-1.0 / B));
	end
	return tmp
end
code[F_, B_, x_] := Block[{t$95$0 = (-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision])}, If[LessEqual[x, -5e-48], N[(t$95$0 + N[(-1.0 / N[(N[(-0.16666666666666666 * N[(B * B), $MachinePrecision] + 1.0), $MachinePrecision] * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.4e-86], N[(N[(1.0 / N[Sqrt[N[(F * F + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(F / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.6e-9], N[(N[(N[(F / B), $MachinePrecision] * N[Power[N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -x \cdot \frac{1}{\tan B}\\
\mathbf{if}\;x \leq -5 \cdot 10^{-48}:\\
\;\;\;\;t\_0 + \frac{-1}{\mathsf{fma}\left(-0.16666666666666666, B \cdot B, 1\right) \cdot B}\\

\mathbf{elif}\;x \leq 5.4 \cdot 10^{-86}:\\
\;\;\;\;\frac{1}{\sqrt{\mathsf{fma}\left(F, F, 2\right)}} \cdot \frac{F}{\sin B}\\

\mathbf{elif}\;x \leq 1.6 \cdot 10^{-9}:\\
\;\;\;\;\frac{F}{B} \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5} - \frac{x}{B}\\

\mathbf{else}:\\
\;\;\;\;t\_0 + \frac{-1}{B}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -4.9999999999999999e-48

    1. Initial program 69.7%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    3. Applied rewrites76.2%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B \cdot \color{blue}{\left(1 + \frac{-1}{6} \cdot {B}^{2}\right)}} \]
    5. Applied rewrites78.9%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{\mathsf{fma}\left(-0.16666666666666666, B \cdot B, 1\right) \cdot \color{blue}{B}} \]

    if -4.9999999999999999e-48 < x < 5.39999999999999985e-86

    1. Initial program 73.6%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Applied rewrites77.0%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}} \]
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{F}{\sin B} \cdot \sqrt{\frac{1}{2 + {F}^{2}}}} \]
    4. Applied rewrites53.1%

      \[\leadsto \color{blue}{\sqrt{{\left(\mathsf{fma}\left(F, F, 2\right)\right)}^{-1}} \cdot \frac{F}{\sin B}} \]
    5. Applied rewrites53.0%

      \[\leadsto \frac{1}{\sqrt{\mathsf{fma}\left(F, F, 2\right)}} \cdot \frac{\color{blue}{F}}{\sin B} \]

    if 5.39999999999999985e-86 < x < 1.60000000000000006e-9

    1. Initial program 72.6%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in B around 0

      \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
    3. Applied rewrites39.4%

      \[\leadsto \color{blue}{\frac{\sqrt{{\left(\mathsf{fma}\left(2, x, F \cdot F\right) + 2\right)}^{-1}} \cdot F - x}{B}} \]
    4. Applied rewrites36.8%

      \[\leadsto \frac{F}{B} \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5} - \color{blue}{\frac{x}{B}} \]

    if 1.60000000000000006e-9 < x

    1. Initial program 86.9%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    3. Applied rewrites96.0%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B} \]
    5. Applied rewrites96.4%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 13: 69.2% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.3 \cdot 10^{-12}:\\ \;\;\;\;\left(-\frac{x \cdot 1}{\tan B}\right) + \frac{-1}{B}\\ \mathbf{elif}\;x \leq 5.4 \cdot 10^{-86}:\\ \;\;\;\;\frac{1}{\sqrt{\mathsf{fma}\left(F, F, 2\right)}} \cdot \frac{F}{\sin B}\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-9}:\\ \;\;\;\;\frac{F}{B} \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5} - \frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B}\\ \end{array} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (if (<= x -1.3e-12)
   (+ (- (/ (* x 1.0) (tan B))) (/ -1.0 B))
   (if (<= x 5.4e-86)
     (* (/ 1.0 (sqrt (fma F F 2.0))) (/ F (sin B)))
     (if (<= x 1.6e-9)
       (- (* (/ F B) (pow (fma 2.0 x (fma F F 2.0)) -0.5)) (/ x B))
       (+ (- (* x (/ 1.0 (tan B)))) (/ -1.0 B))))))
double code(double F, double B, double x) {
	double tmp;
	if (x <= -1.3e-12) {
		tmp = -((x * 1.0) / tan(B)) + (-1.0 / B);
	} else if (x <= 5.4e-86) {
		tmp = (1.0 / sqrt(fma(F, F, 2.0))) * (F / sin(B));
	} else if (x <= 1.6e-9) {
		tmp = ((F / B) * pow(fma(2.0, x, fma(F, F, 2.0)), -0.5)) - (x / B);
	} else {
		tmp = -(x * (1.0 / tan(B))) + (-1.0 / B);
	}
	return tmp;
}
function code(F, B, x)
	tmp = 0.0
	if (x <= -1.3e-12)
		tmp = Float64(Float64(-Float64(Float64(x * 1.0) / tan(B))) + Float64(-1.0 / B));
	elseif (x <= 5.4e-86)
		tmp = Float64(Float64(1.0 / sqrt(fma(F, F, 2.0))) * Float64(F / sin(B)));
	elseif (x <= 1.6e-9)
		tmp = Float64(Float64(Float64(F / B) * (fma(2.0, x, fma(F, F, 2.0)) ^ -0.5)) - Float64(x / B));
	else
		tmp = Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(-1.0 / B));
	end
	return tmp
end
code[F_, B_, x_] := If[LessEqual[x, -1.3e-12], N[((-N[(N[(x * 1.0), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision]) + N[(-1.0 / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.4e-86], N[(N[(1.0 / N[Sqrt[N[(F * F + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(F / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.6e-9], N[(N[(N[(F / B), $MachinePrecision] * N[Power[N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision], N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3 \cdot 10^{-12}:\\
\;\;\;\;\left(-\frac{x \cdot 1}{\tan B}\right) + \frac{-1}{B}\\

\mathbf{elif}\;x \leq 5.4 \cdot 10^{-86}:\\
\;\;\;\;\frac{1}{\sqrt{\mathsf{fma}\left(F, F, 2\right)}} \cdot \frac{F}{\sin B}\\

\mathbf{elif}\;x \leq 1.6 \cdot 10^{-9}:\\
\;\;\;\;\frac{F}{B} \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5} - \frac{x}{B}\\

\mathbf{else}:\\
\;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -1.29999999999999991e-12

    1. Initial program 68.2%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    3. Applied rewrites90.7%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B \cdot \color{blue}{\left(1 + {B}^{2} \cdot \left(\frac{1}{120} \cdot {B}^{2} - \frac{1}{6}\right)\right)}} \]
    5. Applied rewrites91.5%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{\mathsf{fma}\left(0.008333333333333333 \cdot \left(B \cdot B\right) - 0.16666666666666666, B \cdot B, 1\right) \cdot \color{blue}{B}} \]
    6. Taylor expanded in B around 0

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B} \]
    7. Applied rewrites91.5%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B} \]
    8. Applied rewrites91.7%

      \[\leadsto \left(-\color{blue}{\frac{x \cdot 1}{\tan B}}\right) + \frac{-1}{B} \]

    if -1.29999999999999991e-12 < x < 5.39999999999999985e-86

    1. Initial program 73.7%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Applied rewrites77.2%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}} \]
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{F}{\sin B} \cdot \sqrt{\frac{1}{2 + {F}^{2}}}} \]
    4. Applied rewrites51.2%

      \[\leadsto \color{blue}{\sqrt{{\left(\mathsf{fma}\left(F, F, 2\right)\right)}^{-1}} \cdot \frac{F}{\sin B}} \]
    5. Applied rewrites51.1%

      \[\leadsto \frac{1}{\sqrt{\mathsf{fma}\left(F, F, 2\right)}} \cdot \frac{\color{blue}{F}}{\sin B} \]

    if 5.39999999999999985e-86 < x < 1.60000000000000006e-9

    1. Initial program 72.6%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in B around 0

      \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
    3. Applied rewrites39.4%

      \[\leadsto \color{blue}{\frac{\sqrt{{\left(\mathsf{fma}\left(2, x, F \cdot F\right) + 2\right)}^{-1}} \cdot F - x}{B}} \]
    4. Applied rewrites36.8%

      \[\leadsto \frac{F}{B} \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5} - \color{blue}{\frac{x}{B}} \]

    if 1.60000000000000006e-9 < x

    1. Initial program 86.9%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    3. Applied rewrites96.0%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B} \]
    5. Applied rewrites96.4%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 14: 69.2% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.3 \cdot 10^{-12}:\\ \;\;\;\;\left(-\frac{x \cdot 1}{\tan B}\right) + \frac{-1}{B}\\ \mathbf{elif}\;x \leq 5.4 \cdot 10^{-86}:\\ \;\;\;\;\sqrt{\frac{1}{\mathsf{fma}\left(F, F, 2\right)}} \cdot \frac{F}{\sin B}\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-9}:\\ \;\;\;\;\frac{F}{B} \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5} - \frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B}\\ \end{array} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (if (<= x -1.3e-12)
   (+ (- (/ (* x 1.0) (tan B))) (/ -1.0 B))
   (if (<= x 5.4e-86)
     (* (sqrt (/ 1.0 (fma F F 2.0))) (/ F (sin B)))
     (if (<= x 1.6e-9)
       (- (* (/ F B) (pow (fma 2.0 x (fma F F 2.0)) -0.5)) (/ x B))
       (+ (- (* x (/ 1.0 (tan B)))) (/ -1.0 B))))))
double code(double F, double B, double x) {
	double tmp;
	if (x <= -1.3e-12) {
		tmp = -((x * 1.0) / tan(B)) + (-1.0 / B);
	} else if (x <= 5.4e-86) {
		tmp = sqrt((1.0 / fma(F, F, 2.0))) * (F / sin(B));
	} else if (x <= 1.6e-9) {
		tmp = ((F / B) * pow(fma(2.0, x, fma(F, F, 2.0)), -0.5)) - (x / B);
	} else {
		tmp = -(x * (1.0 / tan(B))) + (-1.0 / B);
	}
	return tmp;
}
function code(F, B, x)
	tmp = 0.0
	if (x <= -1.3e-12)
		tmp = Float64(Float64(-Float64(Float64(x * 1.0) / tan(B))) + Float64(-1.0 / B));
	elseif (x <= 5.4e-86)
		tmp = Float64(sqrt(Float64(1.0 / fma(F, F, 2.0))) * Float64(F / sin(B)));
	elseif (x <= 1.6e-9)
		tmp = Float64(Float64(Float64(F / B) * (fma(2.0, x, fma(F, F, 2.0)) ^ -0.5)) - Float64(x / B));
	else
		tmp = Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(-1.0 / B));
	end
	return tmp
end
code[F_, B_, x_] := If[LessEqual[x, -1.3e-12], N[((-N[(N[(x * 1.0), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision]) + N[(-1.0 / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.4e-86], N[(N[Sqrt[N[(1.0 / N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(F / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.6e-9], N[(N[(N[(F / B), $MachinePrecision] * N[Power[N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision], N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3 \cdot 10^{-12}:\\
\;\;\;\;\left(-\frac{x \cdot 1}{\tan B}\right) + \frac{-1}{B}\\

\mathbf{elif}\;x \leq 5.4 \cdot 10^{-86}:\\
\;\;\;\;\sqrt{\frac{1}{\mathsf{fma}\left(F, F, 2\right)}} \cdot \frac{F}{\sin B}\\

\mathbf{elif}\;x \leq 1.6 \cdot 10^{-9}:\\
\;\;\;\;\frac{F}{B} \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5} - \frac{x}{B}\\

\mathbf{else}:\\
\;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -1.29999999999999991e-12

    1. Initial program 68.2%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    3. Applied rewrites90.7%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B \cdot \color{blue}{\left(1 + {B}^{2} \cdot \left(\frac{1}{120} \cdot {B}^{2} - \frac{1}{6}\right)\right)}} \]
    5. Applied rewrites91.5%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{\mathsf{fma}\left(0.008333333333333333 \cdot \left(B \cdot B\right) - 0.16666666666666666, B \cdot B, 1\right) \cdot \color{blue}{B}} \]
    6. Taylor expanded in B around 0

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B} \]
    7. Applied rewrites91.5%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B} \]
    8. Applied rewrites91.7%

      \[\leadsto \left(-\color{blue}{\frac{x \cdot 1}{\tan B}}\right) + \frac{-1}{B} \]

    if -1.29999999999999991e-12 < x < 5.39999999999999985e-86

    1. Initial program 73.7%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Applied rewrites77.2%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}} \]
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{F}{\sin B} \cdot \sqrt{\frac{1}{2 + {F}^{2}}}} \]
    4. Applied rewrites51.2%

      \[\leadsto \color{blue}{\sqrt{{\left(\mathsf{fma}\left(F, F, 2\right)\right)}^{-1}} \cdot \frac{F}{\sin B}} \]
    5. Applied rewrites51.2%

      \[\leadsto \sqrt{\frac{1}{\mathsf{fma}\left(F, F, 2\right)}} \cdot \frac{F}{\sin B} \]

    if 5.39999999999999985e-86 < x < 1.60000000000000006e-9

    1. Initial program 72.6%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in B around 0

      \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
    3. Applied rewrites39.4%

      \[\leadsto \color{blue}{\frac{\sqrt{{\left(\mathsf{fma}\left(2, x, F \cdot F\right) + 2\right)}^{-1}} \cdot F - x}{B}} \]
    4. Applied rewrites36.8%

      \[\leadsto \frac{F}{B} \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5} - \color{blue}{\frac{x}{B}} \]

    if 1.60000000000000006e-9 < x

    1. Initial program 86.9%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    3. Applied rewrites96.0%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B} \]
    5. Applied rewrites96.4%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 15: 57.1% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;B \leq 0.17:\\ \;\;\;\;\frac{\sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \cdot F - x}{B}\\ \mathbf{else}:\\ \;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B}\\ \end{array} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (if (<= B 0.17)
   (/ (- (* (sqrt (/ 1.0 (fma 2.0 x (fma F F 2.0)))) F) x) B)
   (+ (- (* x (/ 1.0 (tan B)))) (/ -1.0 B))))
double code(double F, double B, double x) {
	double tmp;
	if (B <= 0.17) {
		tmp = ((sqrt((1.0 / fma(2.0, x, fma(F, F, 2.0)))) * F) - x) / B;
	} else {
		tmp = -(x * (1.0 / tan(B))) + (-1.0 / B);
	}
	return tmp;
}
function code(F, B, x)
	tmp = 0.0
	if (B <= 0.17)
		tmp = Float64(Float64(Float64(sqrt(Float64(1.0 / fma(2.0, x, fma(F, F, 2.0)))) * F) - x) / B);
	else
		tmp = Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(-1.0 / B));
	end
	return tmp
end
code[F_, B_, x_] := If[LessEqual[B, 0.17], N[(N[(N[(N[Sqrt[N[(1.0 / N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * F), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision], N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;B \leq 0.17:\\
\;\;\;\;\frac{\sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \cdot F - x}{B}\\

\mathbf{else}:\\
\;\;\;\;\left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if B < 0.170000000000000012

    1. Initial program 74.0%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in B around 0

      \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
    3. Applied rewrites58.4%

      \[\leadsto \color{blue}{\frac{\sqrt{{\left(\mathsf{fma}\left(2, x, F \cdot F\right) + 2\right)}^{-1}} \cdot F - x}{B}} \]
    4. Applied rewrites58.4%

      \[\leadsto \frac{\sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \cdot F - x}{B} \]

    if 0.170000000000000012 < B

    1. Initial program 86.1%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    3. Applied rewrites57.7%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B} \]
    5. Applied rewrites53.5%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{-1}{B} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 16: 57.3% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;F \leq -7 \cdot 10^{-15}:\\ \;\;\;\;\left(-\frac{x}{B}\right) + \frac{-1}{\sin B}\\ \mathbf{elif}\;F \leq 7.2 \cdot 10^{+43}:\\ \;\;\;\;\frac{\sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \cdot F - x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 - x \cdot x}{1 + x}}{B}\\ \end{array} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (if (<= F -7e-15)
   (+ (- (/ x B)) (/ -1.0 (sin B)))
   (if (<= F 7.2e+43)
     (/ (- (* (sqrt (/ 1.0 (fma 2.0 x (fma F F 2.0)))) F) x) B)
     (/ (/ (- 1.0 (* x x)) (+ 1.0 x)) B))))
double code(double F, double B, double x) {
	double tmp;
	if (F <= -7e-15) {
		tmp = -(x / B) + (-1.0 / sin(B));
	} else if (F <= 7.2e+43) {
		tmp = ((sqrt((1.0 / fma(2.0, x, fma(F, F, 2.0)))) * F) - x) / B;
	} else {
		tmp = ((1.0 - (x * x)) / (1.0 + x)) / B;
	}
	return tmp;
}
function code(F, B, x)
	tmp = 0.0
	if (F <= -7e-15)
		tmp = Float64(Float64(-Float64(x / B)) + Float64(-1.0 / sin(B)));
	elseif (F <= 7.2e+43)
		tmp = Float64(Float64(Float64(sqrt(Float64(1.0 / fma(2.0, x, fma(F, F, 2.0)))) * F) - x) / B);
	else
		tmp = Float64(Float64(Float64(1.0 - Float64(x * x)) / Float64(1.0 + x)) / B);
	end
	return tmp
end
code[F_, B_, x_] := If[LessEqual[F, -7e-15], N[((-N[(x / B), $MachinePrecision]) + N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 7.2e+43], N[(N[(N[(N[Sqrt[N[(1.0 / N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * F), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision], N[(N[(N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;F \leq -7 \cdot 10^{-15}:\\
\;\;\;\;\left(-\frac{x}{B}\right) + \frac{-1}{\sin B}\\

\mathbf{elif}\;F \leq 7.2 \cdot 10^{+43}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \cdot F - x}{B}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - x \cdot x}{1 + x}}{B}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if F < -7.0000000000000001e-15

    1. Initial program 59.8%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    3. Applied rewrites96.6%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \left(-\color{blue}{\frac{x}{B}}\right) + \frac{-1}{\sin B} \]
    5. Applied rewrites74.3%

      \[\leadsto \left(-\color{blue}{\frac{x}{B}}\right) + \frac{-1}{\sin B} \]

    if -7.0000000000000001e-15 < F < 7.2000000000000002e43

    1. Initial program 99.2%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in B around 0

      \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
    3. Applied rewrites51.6%

      \[\leadsto \color{blue}{\frac{\sqrt{{\left(\mathsf{fma}\left(2, x, F \cdot F\right) + 2\right)}^{-1}} \cdot F - x}{B}} \]
    4. Applied rewrites51.6%

      \[\leadsto \frac{\sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \cdot F - x}{B} \]

    if 7.2000000000000002e43 < F

    1. Initial program 53.1%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in B around 0

      \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
    3. Applied rewrites36.4%

      \[\leadsto \color{blue}{\frac{\sqrt{{\left(\mathsf{fma}\left(2, x, F \cdot F\right) + 2\right)}^{-1}} \cdot F - x}{B}} \]
    4. Taylor expanded in F around inf

      \[\leadsto \frac{1 - x}{B} \]
    5. Applied rewrites51.0%

      \[\leadsto \frac{1 - x}{B} \]
    6. Applied rewrites48.6%

      \[\leadsto \frac{\frac{1 - x \cdot x}{1 + x}}{B} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 17: 47.9% accurate, 3.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;B \leq 2.55 \cdot 10^{+22}:\\ \;\;\;\;\frac{\sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \cdot F - x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{\sin B}\\ \end{array} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (if (<= B 2.55e+22)
   (/ (- (* (sqrt (/ 1.0 (fma 2.0 x (fma F F 2.0)))) F) x) B)
   (/ -1.0 (sin B))))
double code(double F, double B, double x) {
	double tmp;
	if (B <= 2.55e+22) {
		tmp = ((sqrt((1.0 / fma(2.0, x, fma(F, F, 2.0)))) * F) - x) / B;
	} else {
		tmp = -1.0 / sin(B);
	}
	return tmp;
}
function code(F, B, x)
	tmp = 0.0
	if (B <= 2.55e+22)
		tmp = Float64(Float64(Float64(sqrt(Float64(1.0 / fma(2.0, x, fma(F, F, 2.0)))) * F) - x) / B);
	else
		tmp = Float64(-1.0 / sin(B));
	end
	return tmp
end
code[F_, B_, x_] := If[LessEqual[B, 2.55e+22], N[(N[(N[(N[Sqrt[N[(1.0 / N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * F), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision], N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;B \leq 2.55 \cdot 10^{+22}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \cdot F - x}{B}\\

\mathbf{else}:\\
\;\;\;\;\frac{-1}{\sin B}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if B < 2.5500000000000001e22

    1. Initial program 74.3%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in B around 0

      \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
    3. Applied rewrites57.2%

      \[\leadsto \color{blue}{\frac{\sqrt{{\left(\mathsf{fma}\left(2, x, F \cdot F\right) + 2\right)}^{-1}} \cdot F - x}{B}} \]
    4. Applied rewrites57.2%

      \[\leadsto \frac{\sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \cdot F - x}{B} \]

    if 2.5500000000000001e22 < B

    1. Initial program 86.2%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Applied rewrites86.2%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{F \cdot {\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}} \]
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{F}{\sin B} \cdot \sqrt{\frac{1}{2 + {F}^{2}}}} \]
    4. Applied rewrites30.1%

      \[\leadsto \color{blue}{\sqrt{{\left(\mathsf{fma}\left(F, F, 2\right)\right)}^{-1}} \cdot \frac{F}{\sin B}} \]
    5. Taylor expanded in F around -inf

      \[\leadsto \frac{-1}{\color{blue}{\sin B}} \]
    6. Applied rewrites17.4%

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

Alternative 18: 50.9% accurate, 5.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;F \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\left(-\frac{x}{B}\right) + \frac{-0.16666666666666666 \cdot \left(B \cdot B\right) - 1}{B}\\ \mathbf{elif}\;F \leq 7.2 \cdot 10^{+43}:\\ \;\;\;\;\frac{\sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \cdot F - x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 - x \cdot x}{1 + x}}{B}\\ \end{array} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (if (<= F -1.35e+154)
   (+ (- (/ x B)) (/ (- (* -0.16666666666666666 (* B B)) 1.0) B))
   (if (<= F 7.2e+43)
     (/ (- (* (sqrt (/ 1.0 (fma 2.0 x (fma F F 2.0)))) F) x) B)
     (/ (/ (- 1.0 (* x x)) (+ 1.0 x)) B))))
double code(double F, double B, double x) {
	double tmp;
	if (F <= -1.35e+154) {
		tmp = -(x / B) + (((-0.16666666666666666 * (B * B)) - 1.0) / B);
	} else if (F <= 7.2e+43) {
		tmp = ((sqrt((1.0 / fma(2.0, x, fma(F, F, 2.0)))) * F) - x) / B;
	} else {
		tmp = ((1.0 - (x * x)) / (1.0 + x)) / B;
	}
	return tmp;
}
function code(F, B, x)
	tmp = 0.0
	if (F <= -1.35e+154)
		tmp = Float64(Float64(-Float64(x / B)) + Float64(Float64(Float64(-0.16666666666666666 * Float64(B * B)) - 1.0) / B));
	elseif (F <= 7.2e+43)
		tmp = Float64(Float64(Float64(sqrt(Float64(1.0 / fma(2.0, x, fma(F, F, 2.0)))) * F) - x) / B);
	else
		tmp = Float64(Float64(Float64(1.0 - Float64(x * x)) / Float64(1.0 + x)) / B);
	end
	return tmp
end
code[F_, B_, x_] := If[LessEqual[F, -1.35e+154], N[((-N[(x / B), $MachinePrecision]) + N[(N[(N[(-0.16666666666666666 * N[(B * B), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 7.2e+43], N[(N[(N[(N[Sqrt[N[(1.0 / N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * F), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision], N[(N[(N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;F \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(-\frac{x}{B}\right) + \frac{-0.16666666666666666 \cdot \left(B \cdot B\right) - 1}{B}\\

\mathbf{elif}\;F \leq 7.2 \cdot 10^{+43}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \cdot F - x}{B}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - x \cdot x}{1 + x}}{B}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if F < -1.35000000000000003e154

    1. Initial program 30.3%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    3. Applied rewrites99.6%

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{-1}{\sin B}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \left(-\color{blue}{\frac{x}{B}}\right) + \frac{-1}{\sin B} \]
    5. Applied rewrites75.0%

      \[\leadsto \left(-\color{blue}{\frac{x}{B}}\right) + \frac{-1}{\sin B} \]
    6. Taylor expanded in B around 0

      \[\leadsto \left(-\frac{x}{B}\right) + \frac{\frac{-1}{6} \cdot {B}^{2} - 1}{\color{blue}{B}} \]
    7. Applied rewrites52.0%

      \[\leadsto \left(-\frac{x}{B}\right) + \frac{-0.16666666666666666 \cdot \left(B \cdot B\right) - 1}{\color{blue}{B}} \]

    if -1.35000000000000003e154 < F < 7.2000000000000002e43

    1. Initial program 97.2%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in B around 0

      \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
    3. Applied rewrites51.5%

      \[\leadsto \color{blue}{\frac{\sqrt{{\left(\mathsf{fma}\left(2, x, F \cdot F\right) + 2\right)}^{-1}} \cdot F - x}{B}} \]
    4. Applied rewrites51.5%

      \[\leadsto \frac{\sqrt{\frac{1}{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} \cdot F - x}{B} \]

    if 7.2000000000000002e43 < F

    1. Initial program 53.1%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in B around 0

      \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
    3. Applied rewrites36.4%

      \[\leadsto \color{blue}{\frac{\sqrt{{\left(\mathsf{fma}\left(2, x, F \cdot F\right) + 2\right)}^{-1}} \cdot F - x}{B}} \]
    4. Taylor expanded in F around inf

      \[\leadsto \frac{1 - x}{B} \]
    5. Applied rewrites51.0%

      \[\leadsto \frac{1 - x}{B} \]
    6. Applied rewrites48.6%

      \[\leadsto \frac{\frac{1 - x \cdot x}{1 + x}}{B} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 19: 43.7% accurate, 13.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;F \leq -8.4 \cdot 10^{-44}:\\ \;\;\;\;\frac{-1 + \left(-x\right)}{B}\\ \mathbf{elif}\;F \leq 5.8 \cdot 10^{-52}:\\ \;\;\;\;\frac{-x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - x}{B}\\ \end{array} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (if (<= F -8.4e-44)
   (/ (+ -1.0 (- x)) B)
   (if (<= F 5.8e-52) (/ (- x) B) (/ (- 1.0 x) B))))
double code(double F, double B, double x) {
	double tmp;
	if (F <= -8.4e-44) {
		tmp = (-1.0 + -x) / B;
	} else if (F <= 5.8e-52) {
		tmp = -x / B;
	} else {
		tmp = (1.0 - x) / 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(f, b, x)
use fmin_fmax_functions
    real(8), intent (in) :: f
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    real(8) :: tmp
    if (f <= (-8.4d-44)) then
        tmp = ((-1.0d0) + -x) / b
    else if (f <= 5.8d-52) then
        tmp = -x / b
    else
        tmp = (1.0d0 - x) / b
    end if
    code = tmp
end function
public static double code(double F, double B, double x) {
	double tmp;
	if (F <= -8.4e-44) {
		tmp = (-1.0 + -x) / B;
	} else if (F <= 5.8e-52) {
		tmp = -x / B;
	} else {
		tmp = (1.0 - x) / B;
	}
	return tmp;
}
def code(F, B, x):
	tmp = 0
	if F <= -8.4e-44:
		tmp = (-1.0 + -x) / B
	elif F <= 5.8e-52:
		tmp = -x / B
	else:
		tmp = (1.0 - x) / B
	return tmp
function code(F, B, x)
	tmp = 0.0
	if (F <= -8.4e-44)
		tmp = Float64(Float64(-1.0 + Float64(-x)) / B);
	elseif (F <= 5.8e-52)
		tmp = Float64(Float64(-x) / B);
	else
		tmp = Float64(Float64(1.0 - x) / B);
	end
	return tmp
end
function tmp_2 = code(F, B, x)
	tmp = 0.0;
	if (F <= -8.4e-44)
		tmp = (-1.0 + -x) / B;
	elseif (F <= 5.8e-52)
		tmp = -x / B;
	else
		tmp = (1.0 - x) / B;
	end
	tmp_2 = tmp;
end
code[F_, B_, x_] := If[LessEqual[F, -8.4e-44], N[(N[(-1.0 + (-x)), $MachinePrecision] / B), $MachinePrecision], If[LessEqual[F, 5.8e-52], N[((-x) / B), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;F \leq -8.4 \cdot 10^{-44}:\\
\;\;\;\;\frac{-1 + \left(-x\right)}{B}\\

\mathbf{elif}\;F \leq 5.8 \cdot 10^{-52}:\\
\;\;\;\;\frac{-x}{B}\\

\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{B}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if F < -8.40000000000000005e-44

    1. Initial program 62.8%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in B around 0

      \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
    3. Applied rewrites40.8%

      \[\leadsto \color{blue}{\frac{\sqrt{{\left(\mathsf{fma}\left(2, x, F \cdot F\right) + 2\right)}^{-1}} \cdot F - x}{B}} \]
    4. Taylor expanded in F around -inf

      \[\leadsto \frac{-1 \cdot \left(1 + x\right)}{B} \]
    5. Applied rewrites47.9%

      \[\leadsto \frac{-1 + \left(-x\right)}{B} \]

    if -8.40000000000000005e-44 < F < 5.8000000000000003e-52

    1. Initial program 99.5%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in B around 0

      \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
    3. Applied rewrites51.4%

      \[\leadsto \color{blue}{\frac{\sqrt{{\left(\mathsf{fma}\left(2, x, F \cdot F\right) + 2\right)}^{-1}} \cdot F - x}{B}} \]
    4. Taylor expanded in F around 0

      \[\leadsto \frac{-1 \cdot x}{B} \]
    5. Applied rewrites37.5%

      \[\leadsto \frac{-x}{B} \]

    if 5.8000000000000003e-52 < F

    1. Initial program 63.0%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in B around 0

      \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
    3. Applied rewrites40.0%

      \[\leadsto \color{blue}{\frac{\sqrt{{\left(\mathsf{fma}\left(2, x, F \cdot F\right) + 2\right)}^{-1}} \cdot F - x}{B}} \]
    4. Taylor expanded in F around inf

      \[\leadsto \frac{1 - x}{B} \]
    5. Applied rewrites47.3%

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

Alternative 20: 32.1% accurate, 14.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-x}{B}\\ \mathbf{if}\;x \leq -8 \cdot 10^{-128}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-119}:\\ \;\;\;\;\frac{1}{B}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (let* ((t_0 (/ (- x) B)))
   (if (<= x -8e-128) t_0 (if (<= x 8.2e-119) (/ 1.0 B) t_0))))
double code(double F, double B, double x) {
	double t_0 = -x / B;
	double tmp;
	if (x <= -8e-128) {
		tmp = t_0;
	} else if (x <= 8.2e-119) {
		tmp = 1.0 / B;
	} else {
		tmp = t_0;
	}
	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(f, b, x)
use fmin_fmax_functions
    real(8), intent (in) :: f
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    real(8) :: t_0
    real(8) :: tmp
    t_0 = -x / b
    if (x <= (-8d-128)) then
        tmp = t_0
    else if (x <= 8.2d-119) then
        tmp = 1.0d0 / b
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double F, double B, double x) {
	double t_0 = -x / B;
	double tmp;
	if (x <= -8e-128) {
		tmp = t_0;
	} else if (x <= 8.2e-119) {
		tmp = 1.0 / B;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(F, B, x):
	t_0 = -x / B
	tmp = 0
	if x <= -8e-128:
		tmp = t_0
	elif x <= 8.2e-119:
		tmp = 1.0 / B
	else:
		tmp = t_0
	return tmp
function code(F, B, x)
	t_0 = Float64(Float64(-x) / B)
	tmp = 0.0
	if (x <= -8e-128)
		tmp = t_0;
	elseif (x <= 8.2e-119)
		tmp = Float64(1.0 / B);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(F, B, x)
	t_0 = -x / B;
	tmp = 0.0;
	if (x <= -8e-128)
		tmp = t_0;
	elseif (x <= 8.2e-119)
		tmp = 1.0 / B;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[F_, B_, x_] := Block[{t$95$0 = N[((-x) / B), $MachinePrecision]}, If[LessEqual[x, -8e-128], t$95$0, If[LessEqual[x, 8.2e-119], N[(1.0 / B), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{-x}{B}\\
\mathbf{if}\;x \leq -8 \cdot 10^{-128}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 8.2 \cdot 10^{-119}:\\
\;\;\;\;\frac{1}{B}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -8.00000000000000043e-128 or 8.20000000000000041e-119 < x

    1. Initial program 79.0%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in B around 0

      \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
    3. Applied rewrites47.3%

      \[\leadsto \color{blue}{\frac{\sqrt{{\left(\mathsf{fma}\left(2, x, F \cdot F\right) + 2\right)}^{-1}} \cdot F - x}{B}} \]
    4. Taylor expanded in F around 0

      \[\leadsto \frac{-1 \cdot x}{B} \]
    5. Applied rewrites41.2%

      \[\leadsto \frac{-x}{B} \]

    if -8.00000000000000043e-128 < x < 8.20000000000000041e-119

    1. Initial program 73.5%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in B around 0

      \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
    3. Applied rewrites39.8%

      \[\leadsto \color{blue}{\frac{\sqrt{{\left(\mathsf{fma}\left(2, x, F \cdot F\right) + 2\right)}^{-1}} \cdot F - x}{B}} \]
    4. Taylor expanded in F around inf

      \[\leadsto \frac{1 - x}{B} \]
    5. Applied rewrites15.4%

      \[\leadsto \frac{1 - x}{B} \]
    6. Taylor expanded in x around 0

      \[\leadsto \frac{1}{B} \]
    7. Applied rewrites15.4%

      \[\leadsto \frac{1}{B} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 21: 37.1% accurate, 17.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;F \leq 5.8 \cdot 10^{-52}:\\ \;\;\;\;\frac{-x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - x}{B}\\ \end{array} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (if (<= F 5.8e-52) (/ (- x) B) (/ (- 1.0 x) B)))
double code(double F, double B, double x) {
	double tmp;
	if (F <= 5.8e-52) {
		tmp = -x / B;
	} else {
		tmp = (1.0 - x) / 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(f, b, x)
use fmin_fmax_functions
    real(8), intent (in) :: f
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    real(8) :: tmp
    if (f <= 5.8d-52) then
        tmp = -x / b
    else
        tmp = (1.0d0 - x) / b
    end if
    code = tmp
end function
public static double code(double F, double B, double x) {
	double tmp;
	if (F <= 5.8e-52) {
		tmp = -x / B;
	} else {
		tmp = (1.0 - x) / B;
	}
	return tmp;
}
def code(F, B, x):
	tmp = 0
	if F <= 5.8e-52:
		tmp = -x / B
	else:
		tmp = (1.0 - x) / B
	return tmp
function code(F, B, x)
	tmp = 0.0
	if (F <= 5.8e-52)
		tmp = Float64(Float64(-x) / B);
	else
		tmp = Float64(Float64(1.0 - x) / B);
	end
	return tmp
end
function tmp_2 = code(F, B, x)
	tmp = 0.0;
	if (F <= 5.8e-52)
		tmp = -x / B;
	else
		tmp = (1.0 - x) / B;
	end
	tmp_2 = tmp;
end
code[F_, B_, x_] := If[LessEqual[F, 5.8e-52], N[((-x) / B), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;F \leq 5.8 \cdot 10^{-52}:\\
\;\;\;\;\frac{-x}{B}\\

\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{B}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if F < 5.8000000000000003e-52

    1. Initial program 83.2%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in B around 0

      \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
    3. Applied rewrites46.7%

      \[\leadsto \color{blue}{\frac{\sqrt{{\left(\mathsf{fma}\left(2, x, F \cdot F\right) + 2\right)}^{-1}} \cdot F - x}{B}} \]
    4. Taylor expanded in F around 0

      \[\leadsto \frac{-1 \cdot x}{B} \]
    5. Applied rewrites32.6%

      \[\leadsto \frac{-x}{B} \]

    if 5.8000000000000003e-52 < F

    1. Initial program 63.0%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in B around 0

      \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
    3. Applied rewrites40.0%

      \[\leadsto \color{blue}{\frac{\sqrt{{\left(\mathsf{fma}\left(2, x, F \cdot F\right) + 2\right)}^{-1}} \cdot F - x}{B}} \]
    4. Taylor expanded in F around inf

      \[\leadsto \frac{1 - x}{B} \]
    5. Applied rewrites47.3%

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

Alternative 22: 9.7% accurate, 30.7× speedup?

\[\begin{array}{l} \\ \frac{1}{B} \end{array} \]
(FPCore (F B x) :precision binary64 (/ 1.0 B))
double code(double F, double B, double x) {
	return 1.0 / B;
}
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(f, b, x)
use fmin_fmax_functions
    real(8), intent (in) :: f
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    code = 1.0d0 / b
end function
public static double code(double F, double B, double x) {
	return 1.0 / B;
}
def code(F, B, x):
	return 1.0 / B
function code(F, B, x)
	return Float64(1.0 / B)
end
function tmp = code(F, B, x)
	tmp = 1.0 / B;
end
code[F_, B_, x_] := N[(1.0 / B), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{B}
\end{array}
Derivation
  1. Initial program 77.1%

    \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
  2. Taylor expanded in B around 0

    \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
  3. Applied rewrites44.7%

    \[\leadsto \color{blue}{\frac{\sqrt{{\left(\mathsf{fma}\left(2, x, F \cdot F\right) + 2\right)}^{-1}} \cdot F - x}{B}} \]
  4. Taylor expanded in F around inf

    \[\leadsto \frac{1 - x}{B} \]
  5. Applied rewrites29.7%

    \[\leadsto \frac{1 - x}{B} \]
  6. Taylor expanded in x around 0

    \[\leadsto \frac{1}{B} \]
  7. Applied rewrites9.7%

    \[\leadsto \frac{1}{B} \]
  8. Add Preprocessing

Reproduce

?
herbie shell --seed 2025106 
(FPCore (F B x)
  :name "VandenBroeck and Keller, Equation (23)"
  :precision binary64
  (+ (- (* x (/ 1.0 (tan B)))) (* (/ F (sin B)) (pow (+ (+ (* F F) 2.0) (* 2.0 x)) (- (/ 1.0 2.0))))))