VandenBroeck and Keller, Equation (23)

Percentage Accurate: 76.6% → 98.9%
Time: 16.5s
Alternatives: 19
Speedup: 2.2×

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)));
}
real(8) function code(f, b, x)
    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}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 19 alternatives:

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

Initial Program: 76.6% 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)));
}
real(8) function code(f, b, x)
    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: 98.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x}{\tan B}\\
\mathbf{if}\;F \leq -1.6 \cdot 10^{+54}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-x}{\sin B}, \cos B, \frac{-1}{\sin B}\right)\\

\mathbf{elif}\;F \leq 6 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left({\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}, \frac{F}{\sin B}, -t\_0\right)\\

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


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

    1. Initial program 54.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. Add Preprocessing
    3. Taylor expanded in F around -inf

      \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \frac{F}{\sin B} \cdot \color{blue}{\frac{-1}{F}} \]
    4. Step-by-step derivation
      1. lower-/.f6472.6

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

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot \color{blue}{\frac{-1}{F}} \]
    6. Step-by-step derivation
      1. lift-tan.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\color{blue}{\tan B}}\right)\right) + \frac{F}{\sin B} \cdot \frac{-1}{F} \]
      2. clear-numN/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \color{blue}{\frac{1}{\frac{\tan B}{1}}}\right)\right) + \frac{F}{\sin B} \cdot \frac{-1}{F} \]
      3. un-div-invN/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\frac{x}{\frac{\tan B}{1}}}\right)\right) + \frac{F}{\sin B} \cdot \frac{-1}{F} \]
      4. /-rgt-identityN/A

        \[\leadsto \left(\mathsf{neg}\left(\frac{x}{\color{blue}{\tan B}}\right)\right) + \frac{F}{\sin B} \cdot \frac{-1}{F} \]
      5. distribute-frac-negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x\right)}{\tan B}} + \frac{F}{\sin B} \cdot \frac{-1}{F} \]
      6. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(x\right)}}{\tan B} + \frac{F}{\sin B} \cdot \frac{-1}{F} \]
      7. lift-tan.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(x\right)}{\color{blue}{\tan B}} + \frac{F}{\sin B} \cdot \frac{-1}{F} \]
      8. tan-quotN/A

        \[\leadsto \frac{\mathsf{neg}\left(x\right)}{\color{blue}{\frac{\sin B}{\cos B}}} + \frac{F}{\sin B} \cdot \frac{-1}{F} \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(x\right)}{\frac{\color{blue}{\sin B}}{\cos B}} + \frac{F}{\sin B} \cdot \frac{-1}{F} \]
      10. associate-/r/N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x\right)}{\sin B} \cdot \cos B} + \frac{F}{\sin B} \cdot \frac{-1}{F} \]
      11. lift-sin.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(x\right)}{\sin B} \cdot \cos B + \frac{F}{\color{blue}{\sin B}} \cdot \frac{-1}{F} \]
      12. lift-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(x\right)}{\sin B} \cdot \cos B + \frac{F}{\sin B} \cdot \color{blue}{\frac{-1}{F}} \]
      13. lift-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(x\right)}{\sin B} \cdot \cos B + \color{blue}{\frac{F}{\sin B}} \cdot \frac{-1}{F} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(x\right)}{\sin B} \cdot \cos B + \color{blue}{\frac{F}{\sin B} \cdot \frac{-1}{F}} \]
      15. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\mathsf{neg}\left(x\right)}{\sin B}, \cos B, \frac{F}{\sin B} \cdot \frac{-1}{F}\right)} \]
      16. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\mathsf{neg}\left(x\right)}{\sin B}}, \cos B, \frac{F}{\sin B} \cdot \frac{-1}{F}\right) \]
      17. lower-cos.f6472.7

        \[\leadsto \mathsf{fma}\left(\frac{-x}{\sin B}, \color{blue}{\cos B}, \frac{F}{\sin B} \cdot \frac{-1}{F}\right) \]
      18. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(x\right)}{\sin B}, \cos B, \color{blue}{\frac{F}{\sin B} \cdot \frac{-1}{F}}\right) \]
    7. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-x}{\sin B}, \cos B, \frac{1}{-\sin B}\right)} \]

    if -1.6e54 < F < 6e-11

    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. Add Preprocessing
    3. Applied egg-rr99.7%

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

    if 6e-11 < F

    1. Initial program 51.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. Add Preprocessing
    3. Applied egg-rr64.8%

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

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

      \[\leadsto \color{blue}{\frac{1}{\sin B}} - \frac{x}{\tan B} \]
    6. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\sin B}} - \frac{x}{\tan B} \]
      2. lower-sin.f6499.9

        \[\leadsto \frac{1}{\color{blue}{\sin B}} - \frac{x}{\tan B} \]
    7. Simplified99.9%

      \[\leadsto \color{blue}{\frac{1}{\sin B}} - \frac{x}{\tan B} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \leq -1.6 \cdot 10^{+54}:\\ \;\;\;\;\mathsf{fma}\left(\frac{-x}{\sin B}, \cos B, \frac{-1}{\sin B}\right)\\ \mathbf{elif}\;F \leq 6 \cdot 10^{-11}:\\ \;\;\;\;\mathsf{fma}\left({\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}, \frac{F}{\sin B}, -\frac{x}{\tan B}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{x}{\tan B}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 78.4% accurate, 0.3× speedup?

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

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

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

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+300}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (+.f64 (neg.f64 (*.f64 x (/.f64 #s(literal 1 binary64) (tan.f64 B)))) (*.f64 (/.f64 F (sin.f64 B)) (pow.f64 (+.f64 (+.f64 (*.f64 F F) #s(literal 2 binary64)) (*.f64 #s(literal 2 binary64) x)) (neg.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))))) < -1e3 or 4e6 < (+.f64 (neg.f64 (*.f64 x (/.f64 #s(literal 1 binary64) (tan.f64 B)))) (*.f64 (/.f64 F (sin.f64 B)) (pow.f64 (+.f64 (+.f64 (*.f64 F F) #s(literal 2 binary64)) (*.f64 #s(literal 2 binary64) x)) (neg.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))))) < 5.00000000000000026e300

    1. Initial program 97.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. Add Preprocessing
    3. Taylor expanded in B around 0

      \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\frac{F}{B} \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} \cdot \frac{F}{B}} \]
      2. lower-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} \cdot \frac{F}{B}} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}} \cdot \frac{F}{B} \]
      4. lower-/.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}} \cdot \frac{F}{B} \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\color{blue}{\left(2 \cdot x + {F}^{2}\right) + 2}}} \cdot \frac{F}{B} \]
      6. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\color{blue}{2 \cdot x + \left({F}^{2} + 2\right)}}} \cdot \frac{F}{B} \]
      7. *-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\color{blue}{x \cdot 2} + \left({F}^{2} + 2\right)}} \cdot \frac{F}{B} \]
      8. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{x \cdot 2 + \color{blue}{\left(2 + {F}^{2}\right)}}} \cdot \frac{F}{B} \]
      9. lower-fma.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(x, 2, 2 + {F}^{2}\right)}}} \cdot \frac{F}{B} \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{{F}^{2} + 2}\right)}} \cdot \frac{F}{B} \]
      11. unpow2N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{F \cdot F} + 2\right)}} \cdot \frac{F}{B} \]
      12. lower-fma.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{\mathsf{fma}\left(F, F, 2\right)}\right)}} \cdot \frac{F}{B} \]
      13. lower-/.f6497.5

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

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

    if -1e3 < (+.f64 (neg.f64 (*.f64 x (/.f64 #s(literal 1 binary64) (tan.f64 B)))) (*.f64 (/.f64 F (sin.f64 B)) (pow.f64 (+.f64 (+.f64 (*.f64 F F) #s(literal 2 binary64)) (*.f64 #s(literal 2 binary64) x)) (neg.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))))) < 4e6

    1. Initial program 74.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. Add Preprocessing
    3. Applied egg-rr74.7%

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

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

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

      \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}}{\sin B} \]
    7. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + \left(\mathsf{neg}\left(x\right)\right)}}{\sin B} \]
      2. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}}{\sin B} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      4. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      5. lower-+.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(\color{blue}{x \cdot 2} + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      7. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \color{blue}{\mathsf{fma}\left(x, 2, {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      8. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \mathsf{fma}\left(x, 2, \color{blue}{F \cdot F}\right)}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      9. lower-*.f64N/A

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

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

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

    if 5.00000000000000026e300 < (+.f64 (neg.f64 (*.f64 x (/.f64 #s(literal 1 binary64) (tan.f64 B)))) (*.f64 (/.f64 F (sin.f64 B)) (pow.f64 (+.f64 (+.f64 (*.f64 F F) #s(literal 2 binary64)) (*.f64 #s(literal 2 binary64) x)) (neg.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))))))

    1. Initial program 16.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. Add Preprocessing
    3. 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}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
      2. sub-negN/A

        \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
      3. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}}{B} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      6. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\left(2 \cdot x + {F}^{2}\right) + 2}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      7. associate-+l+N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{2 \cdot x + \left({F}^{2} + 2\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{x \cdot 2} + \left({F}^{2} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{x \cdot 2 + \color{blue}{\left(2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      10. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(x, 2, 2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      11. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{{F}^{2} + 2}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      12. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{F \cdot F} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{\mathsf{fma}\left(F, F, 2\right)}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      14. lower-neg.f6463.2

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

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

      \[\leadsto \color{blue}{\frac{1 - x}{B}} \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1 - x}{B}} \]
      2. lower--.f6488.9

        \[\leadsto \frac{\color{blue}{1 - x}}{B} \]
    8. Simplified88.9%

      \[\leadsto \color{blue}{\frac{1 - x}{B}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification81.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \frac{-1}{\tan B} + \frac{F}{\sin B} \cdot {\left(\left(2 + F \cdot F\right) + x \cdot 2\right)}^{\left(\frac{-1}{2}\right)} \leq -1000:\\ \;\;\;\;\sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}} \cdot \frac{F}{B} - x \cdot \frac{1}{\tan B}\\ \mathbf{elif}\;x \cdot \frac{-1}{\tan B} + \frac{F}{\sin B} \cdot {\left(\left(2 + F \cdot F\right) + x \cdot 2\right)}^{\left(\frac{-1}{2}\right)} \leq 4000000:\\ \;\;\;\;\frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \mathsf{fma}\left(x, 2, F \cdot F\right)}}, -x\right)}{\sin B}\\ \mathbf{elif}\;x \cdot \frac{-1}{\tan B} + \frac{F}{\sin B} \cdot {\left(\left(2 + F \cdot F\right) + x \cdot 2\right)}^{\left(\frac{-1}{2}\right)} \leq 5 \cdot 10^{+300}:\\ \;\;\;\;\sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}} \cdot \frac{F}{B} - x \cdot \frac{1}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - x}{B}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 96.8% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x}{\tan B}\\
\mathbf{if}\;F \leq -1.08 \cdot 10^{+198}:\\
\;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{-1}{\sin B}\\

\mathbf{elif}\;F \leq 6 \cdot 10^{-11}:\\
\;\;\;\;\frac{\frac{F}{\sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}}{\sin B} - t\_0\\

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


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

    1. Initial program 29.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. Add Preprocessing
    3. Taylor expanded in F around -inf

      \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\frac{-1}{\sin B}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\frac{-1}{\sin B}} \]
      2. lower-sin.f6499.7

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

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

    if -1.08e198 < F < 6e-11

    1. Initial program 95.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. Add Preprocessing
    3. Applied egg-rr99.6%

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

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

    if 6e-11 < F

    1. Initial program 51.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. Add Preprocessing
    3. Applied egg-rr64.8%

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

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

      \[\leadsto \color{blue}{\frac{1}{\sin B}} - \frac{x}{\tan B} \]
    6. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\sin B}} - \frac{x}{\tan B} \]
      2. lower-sin.f6499.9

        \[\leadsto \frac{1}{\color{blue}{\sin B}} - \frac{x}{\tan B} \]
    7. Simplified99.9%

      \[\leadsto \color{blue}{\frac{1}{\sin B}} - \frac{x}{\tan B} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \leq -1.08 \cdot 10^{+198}:\\ \;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{-1}{\sin B}\\ \mathbf{elif}\;F \leq 6 \cdot 10^{-11}:\\ \;\;\;\;\frac{\frac{F}{\sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}}{\sin B} - \frac{x}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{x}{\tan B}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 97.5% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;F \leq -1.08 \cdot 10^{+198}:\\
\;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{-1}{\sin B}\\

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

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


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

    1. Initial program 29.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. Add Preprocessing
    3. Taylor expanded in F around -inf

      \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\frac{-1}{\sin B}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\frac{-1}{\sin B}} \]
      2. lower-sin.f6499.7

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

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

    if -1.08e198 < F < 1e19

    1. Initial program 95.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. Add Preprocessing
    3. Applied egg-rr99.6%

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

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

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

    if 1e19 < F

    1. Initial program 48.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. Add Preprocessing
    3. Applied egg-rr62.1%

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

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

      \[\leadsto \color{blue}{\frac{1}{\sin B}} - \frac{x}{\tan B} \]
    6. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\sin B}} - \frac{x}{\tan B} \]
      2. lower-sin.f6499.9

        \[\leadsto \frac{1}{\color{blue}{\sin B}} - \frac{x}{\tan B} \]
    7. Simplified99.9%

      \[\leadsto \color{blue}{\frac{1}{\sin B}} - \frac{x}{\tan B} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \leq -1.08 \cdot 10^{+198}:\\ \;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{-1}{\sin B}\\ \mathbf{elif}\;F \leq 10^{+19}:\\ \;\;\;\;\frac{\frac{F}{\sqrt{\mathsf{fma}\left(F, F, \mathsf{fma}\left(2, x, 2\right)\right)}} - x \cdot \cos B}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{x}{\tan B}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 98.7% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;F \leq -1.45:\\
\;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{-1}{\sin B}\\

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

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


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

    1. Initial program 61.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. Add Preprocessing
    3. Taylor expanded in F around -inf

      \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\frac{-1}{\sin B}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\frac{-1}{\sin B}} \]
      2. lower-sin.f6499.8

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

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

    if -1.44999999999999996 < F < 6e-11

    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. Add Preprocessing
    3. Applied egg-rr99.6%

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

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

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

      \[\leadsto \frac{\frac{F}{\color{blue}{\sqrt{2 + 2 \cdot x}}} - x \cdot \cos B}{\sin B} \]
    7. Step-by-step derivation
      1. lower-sqrt.f64N/A

        \[\leadsto \frac{\frac{F}{\color{blue}{\sqrt{2 + 2 \cdot x}}} - x \cdot \cos B}{\sin B} \]
      2. +-commutativeN/A

        \[\leadsto \frac{\frac{F}{\sqrt{\color{blue}{2 \cdot x + 2}}} - x \cdot \cos B}{\sin B} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\frac{F}{\sqrt{\color{blue}{x \cdot 2} + 2}} - x \cdot \cos B}{\sin B} \]
      4. lower-fma.f6499.3

        \[\leadsto \frac{\frac{F}{\sqrt{\color{blue}{\mathsf{fma}\left(x, 2, 2\right)}}} - x \cdot \cos B}{\sin B} \]
    8. Simplified99.3%

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

    if 6e-11 < F

    1. Initial program 51.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. Add Preprocessing
    3. Applied egg-rr64.8%

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

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

      \[\leadsto \color{blue}{\frac{1}{\sin B}} - \frac{x}{\tan B} \]
    6. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\sin B}} - \frac{x}{\tan B} \]
      2. lower-sin.f6499.9

        \[\leadsto \frac{1}{\color{blue}{\sin B}} - \frac{x}{\tan B} \]
    7. Simplified99.9%

      \[\leadsto \color{blue}{\frac{1}{\sin B}} - \frac{x}{\tan B} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \leq -1.45:\\ \;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{-1}{\sin B}\\ \mathbf{elif}\;F \leq 6 \cdot 10^{-11}:\\ \;\;\;\;\frac{\frac{F}{\sqrt{\mathsf{fma}\left(x, 2, 2\right)}} - x \cdot \cos B}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{x}{\tan B}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 85.6% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;F \leq -8 \cdot 10^{+151}:\\
\;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{-1}{B}\\

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

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

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


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

    1. Initial program 37.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. Add Preprocessing
    3. Taylor expanded in F around -inf

      \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \frac{F}{\sin B} \cdot \color{blue}{\frac{-1}{F}} \]
    4. Step-by-step derivation
      1. lower-/.f6467.7

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

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

      \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\frac{-1}{B}} \]
    7. Step-by-step derivation
      1. lower-/.f6481.8

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

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

    if -8.00000000000000014e151 < F < -1.35e-116

    1. Initial program 92.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. Add Preprocessing
    3. Applied egg-rr99.6%

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

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

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

      \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}}{\sin B} \]
    7. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + \left(\mathsf{neg}\left(x\right)\right)}}{\sin B} \]
      2. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}}{\sin B} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      4. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      5. lower-+.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(\color{blue}{x \cdot 2} + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      7. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \color{blue}{\mathsf{fma}\left(x, 2, {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      8. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \mathsf{fma}\left(x, 2, \color{blue}{F \cdot F}\right)}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      9. lower-*.f64N/A

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

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

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

    if -1.35e-116 < F < 6e-11

    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. Add Preprocessing
    3. Taylor expanded in B around 0

      \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\frac{F}{B} \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} \cdot \frac{F}{B}} \]
      2. lower-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} \cdot \frac{F}{B}} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}} \cdot \frac{F}{B} \]
      4. lower-/.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}} \cdot \frac{F}{B} \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\color{blue}{\left(2 \cdot x + {F}^{2}\right) + 2}}} \cdot \frac{F}{B} \]
      6. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\color{blue}{2 \cdot x + \left({F}^{2} + 2\right)}}} \cdot \frac{F}{B} \]
      7. *-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\color{blue}{x \cdot 2} + \left({F}^{2} + 2\right)}} \cdot \frac{F}{B} \]
      8. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{x \cdot 2 + \color{blue}{\left(2 + {F}^{2}\right)}}} \cdot \frac{F}{B} \]
      9. lower-fma.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(x, 2, 2 + {F}^{2}\right)}}} \cdot \frac{F}{B} \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{{F}^{2} + 2}\right)}} \cdot \frac{F}{B} \]
      11. unpow2N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{F \cdot F} + 2\right)}} \cdot \frac{F}{B} \]
      12. lower-fma.f64N/A

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

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

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

    if 6e-11 < F

    1. Initial program 51.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. Add Preprocessing
    3. Applied egg-rr64.8%

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

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

      \[\leadsto \color{blue}{\frac{1}{\sin B}} - \frac{x}{\tan B} \]
    6. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\sin B}} - \frac{x}{\tan B} \]
      2. lower-sin.f6499.9

        \[\leadsto \frac{1}{\color{blue}{\sin B}} - \frac{x}{\tan B} \]
    7. Simplified99.9%

      \[\leadsto \color{blue}{\frac{1}{\sin B}} - \frac{x}{\tan B} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification92.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \leq -8 \cdot 10^{+151}:\\ \;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{-1}{B}\\ \mathbf{elif}\;F \leq -1.35 \cdot 10^{-116}:\\ \;\;\;\;\frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \mathsf{fma}\left(x, 2, F \cdot F\right)}}, -x\right)}{\sin B}\\ \mathbf{elif}\;F \leq 6 \cdot 10^{-11}:\\ \;\;\;\;\sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}} \cdot \frac{F}{B} - x \cdot \frac{1}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{x}{\tan B}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 85.6% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;F \leq -8 \cdot 10^{+151}:\\
\;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{-1}{B}\\

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

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

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


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

    1. Initial program 37.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. Add Preprocessing
    3. Taylor expanded in F around -inf

      \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \frac{F}{\sin B} \cdot \color{blue}{\frac{-1}{F}} \]
    4. Step-by-step derivation
      1. lower-/.f6467.7

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

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

      \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\frac{-1}{B}} \]
    7. Step-by-step derivation
      1. lower-/.f6481.8

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

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

    if -8.00000000000000014e151 < F < -1.35e-116

    1. Initial program 92.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. Add Preprocessing
    3. Applied egg-rr99.6%

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

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

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

      \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}}{\sin B} \]
    7. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + \left(\mathsf{neg}\left(x\right)\right)}}{\sin B} \]
      2. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}}{\sin B} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      4. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      5. lower-+.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(\color{blue}{x \cdot 2} + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      7. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \color{blue}{\mathsf{fma}\left(x, 2, {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      8. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \mathsf{fma}\left(x, 2, \color{blue}{F \cdot F}\right)}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      9. lower-*.f64N/A

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

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

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

    if -1.35e-116 < F < 6e-11

    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. Add Preprocessing
    3. Taylor expanded in B around 0

      \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\frac{F}{B} \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} \cdot \frac{F}{B}} \]
      2. lower-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} \cdot \frac{F}{B}} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}} \cdot \frac{F}{B} \]
      4. lower-/.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}} \cdot \frac{F}{B} \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\color{blue}{\left(2 \cdot x + {F}^{2}\right) + 2}}} \cdot \frac{F}{B} \]
      6. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\color{blue}{2 \cdot x + \left({F}^{2} + 2\right)}}} \cdot \frac{F}{B} \]
      7. *-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\color{blue}{x \cdot 2} + \left({F}^{2} + 2\right)}} \cdot \frac{F}{B} \]
      8. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{x \cdot 2 + \color{blue}{\left(2 + {F}^{2}\right)}}} \cdot \frac{F}{B} \]
      9. lower-fma.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(x, 2, 2 + {F}^{2}\right)}}} \cdot \frac{F}{B} \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{{F}^{2} + 2}\right)}} \cdot \frac{F}{B} \]
      11. unpow2N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{F \cdot F} + 2\right)}} \cdot \frac{F}{B} \]
      12. lower-fma.f64N/A

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

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

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

    if 6e-11 < F

    1. Initial program 51.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. Add Preprocessing
    3. Applied egg-rr64.8%

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

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

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

      \[\leadsto \color{blue}{\frac{1 - x \cdot \cos B}{\sin B}} \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1 - x \cdot \cos B}{\sin B}} \]
      2. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{1 - x \cdot \cos B}}{\sin B} \]
      3. lower-*.f64N/A

        \[\leadsto \frac{1 - \color{blue}{x \cdot \cos B}}{\sin B} \]
      4. lower-cos.f64N/A

        \[\leadsto \frac{1 - x \cdot \color{blue}{\cos B}}{\sin B} \]
      5. lower-sin.f6499.8

        \[\leadsto \frac{1 - x \cdot \cos B}{\color{blue}{\sin B}} \]
    8. Simplified99.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \leq -8 \cdot 10^{+151}:\\ \;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{-1}{B}\\ \mathbf{elif}\;F \leq -1.35 \cdot 10^{-116}:\\ \;\;\;\;\frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \mathsf{fma}\left(x, 2, F \cdot F\right)}}, -x\right)}{\sin B}\\ \mathbf{elif}\;F \leq 6 \cdot 10^{-11}:\\ \;\;\;\;\sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}} \cdot \frac{F}{B} - x \cdot \frac{1}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - x \cdot \cos B}{\sin B}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 91.7% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;F \leq -3700:\\
\;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{-1}{\sin B}\\

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

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


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

    1. Initial program 61.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. Add Preprocessing
    3. Taylor expanded in F around -inf

      \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\frac{-1}{\sin B}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\frac{-1}{\sin B}} \]
      2. lower-sin.f6499.8

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

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

    if -3700 < F < 6e-11

    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. Add Preprocessing
    3. Taylor expanded in B around 0

      \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\frac{F}{B} \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} \cdot \frac{F}{B}} \]
      2. lower-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} \cdot \frac{F}{B}} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}} \cdot \frac{F}{B} \]
      4. lower-/.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}} \cdot \frac{F}{B} \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\color{blue}{\left(2 \cdot x + {F}^{2}\right) + 2}}} \cdot \frac{F}{B} \]
      6. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\color{blue}{2 \cdot x + \left({F}^{2} + 2\right)}}} \cdot \frac{F}{B} \]
      7. *-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\color{blue}{x \cdot 2} + \left({F}^{2} + 2\right)}} \cdot \frac{F}{B} \]
      8. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{x \cdot 2 + \color{blue}{\left(2 + {F}^{2}\right)}}} \cdot \frac{F}{B} \]
      9. lower-fma.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(x, 2, 2 + {F}^{2}\right)}}} \cdot \frac{F}{B} \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{{F}^{2} + 2}\right)}} \cdot \frac{F}{B} \]
      11. unpow2N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{F \cdot F} + 2\right)}} \cdot \frac{F}{B} \]
      12. lower-fma.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{\mathsf{fma}\left(F, F, 2\right)}\right)}} \cdot \frac{F}{B} \]
      13. lower-/.f6488.0

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

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

    if 6e-11 < F

    1. Initial program 51.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. Add Preprocessing
    3. Applied egg-rr64.8%

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

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

      \[\leadsto \color{blue}{\frac{1}{\sin B}} - \frac{x}{\tan B} \]
    6. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\sin B}} - \frac{x}{\tan B} \]
      2. lower-sin.f6499.9

        \[\leadsto \frac{1}{\color{blue}{\sin B}} - \frac{x}{\tan B} \]
    7. Simplified99.9%

      \[\leadsto \color{blue}{\frac{1}{\sin B}} - \frac{x}{\tan B} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification94.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \leq -3700:\\ \;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{-1}{\sin B}\\ \mathbf{elif}\;F \leq 6 \cdot 10^{-11}:\\ \;\;\;\;\sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}} \cdot \frac{F}{B} - x \cdot \frac{1}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{x}{\tan B}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 77.7% accurate, 2.2× speedup?

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

\\
\begin{array}{l}
t_0 := -\frac{x}{\tan B}\\
\mathbf{if}\;x \leq -0.118:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -0.11799999999999999 or 5.9999999999999998e-22 < x

    1. Initial program 82.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. Add Preprocessing
    3. Applied egg-rr98.4%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot \cos B}{\sin B}} \]
    5. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{x \cdot \cos B}{\sin B}\right)} \]
      2. associate-/l*N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{x \cdot \frac{\cos B}{\sin B}}\right) \]
      3. distribute-lft-neg-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \frac{\cos B}{\sin B}} \]
      4. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \frac{\cos B}{\sin B}} \]
      5. lower-neg.f64N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \frac{\cos B}{\sin B} \]
      6. lower-/.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\frac{\cos B}{\sin B}} \]
      7. lower-cos.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \frac{\color{blue}{\cos B}}{\sin B} \]
      8. lower-sin.f6498.0

        \[\leadsto \left(-x\right) \cdot \frac{\cos B}{\color{blue}{\sin B}} \]
    6. Simplified98.0%

      \[\leadsto \color{blue}{\left(-x\right) \cdot \frac{\cos B}{\sin B}} \]
    7. Step-by-step derivation
      1. lift-neg.f64N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \frac{\cos B}{\sin B} \]
      2. lift-cos.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \frac{\color{blue}{\cos B}}{\sin B} \]
      3. lift-sin.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \frac{\cos B}{\color{blue}{\sin B}} \]
      4. clear-numN/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\frac{1}{\frac{\sin B}{\cos B}}} \]
      5. lift-sin.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \frac{1}{\frac{\color{blue}{\sin B}}{\cos B}} \]
      6. lift-cos.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \frac{1}{\frac{\sin B}{\color{blue}{\cos B}}} \]
      7. tan-quotN/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \frac{1}{\color{blue}{\tan B}} \]
      8. lift-tan.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \frac{1}{\color{blue}{\tan B}} \]
      9. un-div-invN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x\right)}{\tan B}} \]
      10. lower-/.f6498.4

        \[\leadsto \color{blue}{\frac{-x}{\tan B}} \]
    8. Applied egg-rr98.4%

      \[\leadsto \color{blue}{\frac{-x}{\tan B}} \]

    if -0.11799999999999999 < x < 5.9999999999999998e-22

    1. Initial program 69.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. Add Preprocessing
    3. Applied egg-rr73.5%

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

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

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

      \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}}{\sin B} \]
    7. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + \left(\mathsf{neg}\left(x\right)\right)}}{\sin B} \]
      2. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}}{\sin B} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      4. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      5. lower-+.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(\color{blue}{x \cdot 2} + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      7. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \color{blue}{\mathsf{fma}\left(x, 2, {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      8. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \mathsf{fma}\left(x, 2, \color{blue}{F \cdot F}\right)}}, \mathsf{neg}\left(x\right)\right)}{\sin B} \]
      9. lower-*.f64N/A

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.118:\\ \;\;\;\;-\frac{x}{\tan B}\\ \mathbf{elif}\;x \leq 6 \cdot 10^{-22}:\\ \;\;\;\;\frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \mathsf{fma}\left(x, 2, F \cdot F\right)}}, -x\right)}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;-\frac{x}{\tan B}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 57.0% accurate, 3.1× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{fma}\left(F, F, \mathsf{fma}\left(2, x, 2\right)\right)}\\
\mathbf{if}\;B \leq 0.00024:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(F, \frac{0.16666666666666666}{t\_0}, x \cdot 0.3333333333333333\right), B \cdot B, \frac{F}{t\_0} - x\right)}{B}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if B < 2.40000000000000006e-4

    1. Initial program 74.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. Add Preprocessing
    3. Applied egg-rr86.8%

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

      \[\leadsto \color{blue}{\frac{-1 \cdot x + \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + {B}^{2} \cdot \left(\frac{1}{6} \cdot \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}\right) + \frac{1}{3} \cdot x\right)\right)}{B}} \]
    5. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} + \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + {B}^{2} \cdot \left(\frac{1}{6} \cdot \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}\right) + \frac{1}{3} \cdot x\right)\right)}{B} \]
      2. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + {B}^{2} \cdot \left(\frac{1}{6} \cdot \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}\right) + \frac{1}{3} \cdot x\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
      3. sub-negN/A

        \[\leadsto \frac{\color{blue}{\left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + {B}^{2} \cdot \left(\frac{1}{6} \cdot \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}\right) + \frac{1}{3} \cdot x\right)\right) - x}}{B} \]
      4. lower-/.f64N/A

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(B \cdot B, \mathsf{fma}\left(F \cdot 0.16666666666666666, \sqrt{\frac{1}{2 + \mathsf{fma}\left(x, 2, F \cdot F\right)}}, x \cdot 0.3333333333333333\right), F \cdot \sqrt{\frac{1}{2 + \mathsf{fma}\left(x, 2, F \cdot F\right)}}\right) - x}{B}} \]
    7. Applied egg-rr59.2%

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

    if 2.40000000000000006e-4 < B

    1. Initial program 78.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. Add Preprocessing
    3. Applied egg-rr78.9%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot \cos B}{\sin B}} \]
    5. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{x \cdot \cos B}{\sin B}\right)} \]
      2. associate-/l*N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{x \cdot \frac{\cos B}{\sin B}}\right) \]
      3. distribute-lft-neg-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \frac{\cos B}{\sin B}} \]
      4. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \frac{\cos B}{\sin B}} \]
      5. lower-neg.f64N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \frac{\cos B}{\sin B} \]
      6. lower-/.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\frac{\cos B}{\sin B}} \]
      7. lower-cos.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \frac{\color{blue}{\cos B}}{\sin B} \]
      8. lower-sin.f6460.6

        \[\leadsto \left(-x\right) \cdot \frac{\cos B}{\color{blue}{\sin B}} \]
    6. Simplified60.6%

      \[\leadsto \color{blue}{\left(-x\right) \cdot \frac{\cos B}{\sin B}} \]
    7. Step-by-step derivation
      1. lift-neg.f64N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \frac{\cos B}{\sin B} \]
      2. lift-cos.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \frac{\color{blue}{\cos B}}{\sin B} \]
      3. lift-sin.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \frac{\cos B}{\color{blue}{\sin B}} \]
      4. clear-numN/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\frac{1}{\frac{\sin B}{\cos B}}} \]
      5. lift-sin.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \frac{1}{\frac{\color{blue}{\sin B}}{\cos B}} \]
      6. lift-cos.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \frac{1}{\frac{\sin B}{\color{blue}{\cos B}}} \]
      7. tan-quotN/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \frac{1}{\color{blue}{\tan B}} \]
      8. lift-tan.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \frac{1}{\color{blue}{\tan B}} \]
      9. un-div-invN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x\right)}{\tan B}} \]
      10. lower-/.f6460.9

        \[\leadsto \color{blue}{\frac{-x}{\tan B}} \]
    8. Applied egg-rr60.9%

      \[\leadsto \color{blue}{\frac{-x}{\tan B}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification59.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;B \leq 0.00024:\\ \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(F, \frac{0.16666666666666666}{\sqrt{\mathsf{fma}\left(F, F, \mathsf{fma}\left(2, x, 2\right)\right)}}, x \cdot 0.3333333333333333\right), B \cdot B, \frac{F}{\sqrt{\mathsf{fma}\left(F, F, \mathsf{fma}\left(2, x, 2\right)\right)}} - x\right)}{B}\\ \mathbf{else}:\\ \;\;\;\;-\frac{x}{\tan B}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 49.2% accurate, 5.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;F \leq -1.3 \cdot 10^{+247}:\\
\;\;\;\;\frac{\mathsf{fma}\left(B \cdot B, \mathsf{fma}\left(x, 0.3333333333333333, -0.16666666666666666\right), -1\right) - x}{B}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(B \cdot B, \mathsf{fma}\left(x, 0.3333333333333333, 0.16666666666666666\right), 1\right) - x}{B}\\


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

    1. Initial program 29.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. Add Preprocessing
    3. Taylor expanded in F around -inf

      \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \frac{F}{\sin B} \cdot \color{blue}{\frac{-1}{F}} \]
    4. Step-by-step derivation
      1. lower-/.f6448.8

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

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

      \[\leadsto \color{blue}{\frac{{B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) - \left(1 + x\right)}{B}} \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{{B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) - \left(1 + x\right)}{B}} \]
      2. associate--r+N/A

        \[\leadsto \frac{\color{blue}{\left({B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) - 1\right) - x}}{B} \]
      3. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{\left({B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) - 1\right) - x}}{B} \]
      4. sub-negN/A

        \[\leadsto \frac{\color{blue}{\left({B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} - x}{B} \]
      5. metadata-evalN/A

        \[\leadsto \frac{\left({B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) + \color{blue}{-1}\right) - x}{B} \]
      6. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left({B}^{2}, \frac{1}{3} \cdot x - \frac{1}{6}, -1\right)} - x}{B} \]
      7. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{B \cdot B}, \frac{1}{3} \cdot x - \frac{1}{6}, -1\right) - x}{B} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{B \cdot B}, \frac{1}{3} \cdot x - \frac{1}{6}, -1\right) - x}{B} \]
      9. sub-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{\frac{1}{3} \cdot x + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right)}, -1\right) - x}{B} \]
      10. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{x \cdot \frac{1}{3}} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right), -1\right) - x}{B} \]
      11. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, x \cdot \frac{1}{3} + \color{blue}{\frac{-1}{6}}, -1\right) - x}{B} \]
      12. lower-fma.f6460.3

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{\mathsf{fma}\left(x, 0.3333333333333333, -0.16666666666666666\right)}, -1\right) - x}{B} \]
    8. Simplified60.3%

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

    if -1.29999999999999995e247 < F < 5.6000000000000001e131

    1. Initial program 94.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. Add Preprocessing
    3. 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}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
      2. sub-negN/A

        \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
      3. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}}{B} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      6. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\left(2 \cdot x + {F}^{2}\right) + 2}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      7. associate-+l+N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{2 \cdot x + \left({F}^{2} + 2\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{x \cdot 2} + \left({F}^{2} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{x \cdot 2 + \color{blue}{\left(2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      10. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(x, 2, 2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      11. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{{F}^{2} + 2}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      12. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{F \cdot F} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{\mathsf{fma}\left(F, F, 2\right)}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      14. lower-neg.f6452.8

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}}, \color{blue}{-x}\right)}{B} \]
    5. Simplified52.8%

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

    if 5.6000000000000001e131 < F

    1. Initial program 28.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. Add Preprocessing
    3. Applied egg-rr46.6%

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

      \[\leadsto \color{blue}{\frac{-1 \cdot x + \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + {B}^{2} \cdot \left(\frac{1}{6} \cdot \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}\right) + \frac{1}{3} \cdot x\right)\right)}{B}} \]
    5. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} + \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + {B}^{2} \cdot \left(\frac{1}{6} \cdot \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}\right) + \frac{1}{3} \cdot x\right)\right)}{B} \]
      2. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + {B}^{2} \cdot \left(\frac{1}{6} \cdot \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}\right) + \frac{1}{3} \cdot x\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
      3. sub-negN/A

        \[\leadsto \frac{\color{blue}{\left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + {B}^{2} \cdot \left(\frac{1}{6} \cdot \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}\right) + \frac{1}{3} \cdot x\right)\right) - x}}{B} \]
      4. lower-/.f64N/A

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

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

      \[\leadsto \frac{\color{blue}{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right)} - x}{B} \]
    8. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left({B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right) + 1\right)} - x}{B} \]
      2. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left({B}^{2}, \frac{1}{6} + \frac{1}{3} \cdot x, 1\right)} - x}{B} \]
      3. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{B \cdot B}, \frac{1}{6} + \frac{1}{3} \cdot x, 1\right) - x}{B} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{B \cdot B}, \frac{1}{6} + \frac{1}{3} \cdot x, 1\right) - x}{B} \]
      5. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{\frac{1}{3} \cdot x + \frac{1}{6}}, 1\right) - x}{B} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{x \cdot \frac{1}{3}} + \frac{1}{6}, 1\right) - x}{B} \]
      7. lower-fma.f6450.0

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{\mathsf{fma}\left(x, 0.3333333333333333, 0.16666666666666666\right)}, 1\right) - x}{B} \]
    9. Simplified50.0%

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

Alternative 12: 49.2% accurate, 6.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;F \leq -1.3 \cdot 10^{+247}:\\
\;\;\;\;\frac{\mathsf{fma}\left(B \cdot B, \mathsf{fma}\left(x, 0.3333333333333333, -0.16666666666666666\right), -1\right) - x}{B}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(B \cdot B, \mathsf{fma}\left(x, 0.3333333333333333, 0.16666666666666666\right), 1\right) - x}{B}\\


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

    1. Initial program 29.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. Add Preprocessing
    3. Taylor expanded in F around -inf

      \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \frac{F}{\sin B} \cdot \color{blue}{\frac{-1}{F}} \]
    4. Step-by-step derivation
      1. lower-/.f6448.8

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

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

      \[\leadsto \color{blue}{\frac{{B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) - \left(1 + x\right)}{B}} \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{{B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) - \left(1 + x\right)}{B}} \]
      2. associate--r+N/A

        \[\leadsto \frac{\color{blue}{\left({B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) - 1\right) - x}}{B} \]
      3. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{\left({B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) - 1\right) - x}}{B} \]
      4. sub-negN/A

        \[\leadsto \frac{\color{blue}{\left({B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} - x}{B} \]
      5. metadata-evalN/A

        \[\leadsto \frac{\left({B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) + \color{blue}{-1}\right) - x}{B} \]
      6. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left({B}^{2}, \frac{1}{3} \cdot x - \frac{1}{6}, -1\right)} - x}{B} \]
      7. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{B \cdot B}, \frac{1}{3} \cdot x - \frac{1}{6}, -1\right) - x}{B} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{B \cdot B}, \frac{1}{3} \cdot x - \frac{1}{6}, -1\right) - x}{B} \]
      9. sub-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{\frac{1}{3} \cdot x + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right)}, -1\right) - x}{B} \]
      10. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{x \cdot \frac{1}{3}} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right), -1\right) - x}{B} \]
      11. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, x \cdot \frac{1}{3} + \color{blue}{\frac{-1}{6}}, -1\right) - x}{B} \]
      12. lower-fma.f6460.3

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{\mathsf{fma}\left(x, 0.3333333333333333, -0.16666666666666666\right)}, -1\right) - x}{B} \]
    8. Simplified60.3%

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

    if -1.29999999999999995e247 < F < 5.6000000000000001e131

    1. Initial program 94.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. Add Preprocessing
    3. 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}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
      2. sub-negN/A

        \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
      3. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}}{B} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      6. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\left(2 \cdot x + {F}^{2}\right) + 2}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      7. associate-+l+N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{2 \cdot x + \left({F}^{2} + 2\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{x \cdot 2} + \left({F}^{2} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{x \cdot 2 + \color{blue}{\left(2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      10. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(x, 2, 2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      11. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{{F}^{2} + 2}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      12. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{F \cdot F} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{\mathsf{fma}\left(F, F, 2\right)}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      14. lower-neg.f6452.8

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}}, \color{blue}{-x}\right)}{B} \]
    5. Simplified52.8%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}}, -x\right)}{B}} \]
    6. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto \frac{F \cdot \sqrt{\frac{1}{x \cdot 2 + \color{blue}{\mathsf{fma}\left(F, F, 2\right)}}} + \left(\mathsf{neg}\left(x\right)\right)}{B} \]
      2. lift-fma.f64N/A

        \[\leadsto \frac{F \cdot \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}}} + \left(\mathsf{neg}\left(x\right)\right)}{B} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{F \cdot \sqrt{\color{blue}{\frac{1}{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}}} + \left(\mathsf{neg}\left(x\right)\right)}{B} \]
      4. lift-sqrt.f64N/A

        \[\leadsto \frac{F \cdot \color{blue}{\sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}}} + \left(\mathsf{neg}\left(x\right)\right)}{B} \]
      5. lift-neg.f64N/A

        \[\leadsto \frac{F \cdot \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}} + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}}{B} \]
      6. lift-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}}, \mathsf{neg}\left(x\right)\right)}}{B} \]
      7. lift-/.f6452.8

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}}, -x\right)}{B}} \]
    7. Applied egg-rr52.8%

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

    if 5.6000000000000001e131 < F

    1. Initial program 28.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. Add Preprocessing
    3. Applied egg-rr46.6%

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

      \[\leadsto \color{blue}{\frac{-1 \cdot x + \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + {B}^{2} \cdot \left(\frac{1}{6} \cdot \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}\right) + \frac{1}{3} \cdot x\right)\right)}{B}} \]
    5. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} + \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + {B}^{2} \cdot \left(\frac{1}{6} \cdot \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}\right) + \frac{1}{3} \cdot x\right)\right)}{B} \]
      2. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + {B}^{2} \cdot \left(\frac{1}{6} \cdot \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}\right) + \frac{1}{3} \cdot x\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
      3. sub-negN/A

        \[\leadsto \frac{\color{blue}{\left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + {B}^{2} \cdot \left(\frac{1}{6} \cdot \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}\right) + \frac{1}{3} \cdot x\right)\right) - x}}{B} \]
      4. lower-/.f64N/A

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

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

      \[\leadsto \frac{\color{blue}{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right)} - x}{B} \]
    8. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left({B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right) + 1\right)} - x}{B} \]
      2. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left({B}^{2}, \frac{1}{6} + \frac{1}{3} \cdot x, 1\right)} - x}{B} \]
      3. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{B \cdot B}, \frac{1}{6} + \frac{1}{3} \cdot x, 1\right) - x}{B} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{B \cdot B}, \frac{1}{6} + \frac{1}{3} \cdot x, 1\right) - x}{B} \]
      5. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{\frac{1}{3} \cdot x + \frac{1}{6}}, 1\right) - x}{B} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{x \cdot \frac{1}{3}} + \frac{1}{6}, 1\right) - x}{B} \]
      7. lower-fma.f6450.0

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{\mathsf{fma}\left(x, 0.3333333333333333, 0.16666666666666666\right)}, 1\right) - x}{B} \]
    9. Simplified50.0%

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

Alternative 13: 49.8% accurate, 6.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;F \leq -7.8 \cdot 10^{+36}:\\
\;\;\;\;\frac{\mathsf{fma}\left(B \cdot B, \mathsf{fma}\left(x, 0.3333333333333333, -0.16666666666666666\right), -1\right) - x}{B}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(B \cdot B, \mathsf{fma}\left(x, 0.3333333333333333, 0.16666666666666666\right), 1\right) - x}{B}\\


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

    1. Initial program 58.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. Add Preprocessing
    3. Taylor expanded in F around -inf

      \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \frac{F}{\sin B} \cdot \color{blue}{\frac{-1}{F}} \]
    4. Step-by-step derivation
      1. lower-/.f6474.8

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

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

      \[\leadsto \color{blue}{\frac{{B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) - \left(1 + x\right)}{B}} \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{{B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) - \left(1 + x\right)}{B}} \]
      2. associate--r+N/A

        \[\leadsto \frac{\color{blue}{\left({B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) - 1\right) - x}}{B} \]
      3. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{\left({B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) - 1\right) - x}}{B} \]
      4. sub-negN/A

        \[\leadsto \frac{\color{blue}{\left({B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} - x}{B} \]
      5. metadata-evalN/A

        \[\leadsto \frac{\left({B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) + \color{blue}{-1}\right) - x}{B} \]
      6. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left({B}^{2}, \frac{1}{3} \cdot x - \frac{1}{6}, -1\right)} - x}{B} \]
      7. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{B \cdot B}, \frac{1}{3} \cdot x - \frac{1}{6}, -1\right) - x}{B} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{B \cdot B}, \frac{1}{3} \cdot x - \frac{1}{6}, -1\right) - x}{B} \]
      9. sub-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{\frac{1}{3} \cdot x + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right)}, -1\right) - x}{B} \]
      10. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{x \cdot \frac{1}{3}} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right), -1\right) - x}{B} \]
      11. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, x \cdot \frac{1}{3} + \color{blue}{\frac{-1}{6}}, -1\right) - x}{B} \]
      12. lower-fma.f6459.5

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{\mathsf{fma}\left(x, 0.3333333333333333, -0.16666666666666666\right)}, -1\right) - x}{B} \]
    8. Simplified59.5%

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

    if -7.80000000000000042e36 < F < 7e18

    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. Add Preprocessing
    3. 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}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
      2. sub-negN/A

        \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
      3. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}}{B} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      6. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\left(2 \cdot x + {F}^{2}\right) + 2}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      7. associate-+l+N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{2 \cdot x + \left({F}^{2} + 2\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{x \cdot 2} + \left({F}^{2} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{x \cdot 2 + \color{blue}{\left(2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      10. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(x, 2, 2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      11. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{{F}^{2} + 2}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      12. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{F \cdot F} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{\mathsf{fma}\left(F, F, 2\right)}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      14. lower-neg.f6451.6

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

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

      \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + 2 \cdot x}} - x}}{B} \]
    7. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + 2 \cdot x}} + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
      2. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + 2 \cdot x}}, \mathsf{neg}\left(x\right)\right)}}{B} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \color{blue}{\sqrt{\frac{1}{2 + 2 \cdot x}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      4. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\color{blue}{\frac{1}{2 + 2 \cdot x}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      5. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{2 \cdot x + 2}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{x \cdot 2} + 2}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      7. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(x, 2, 2\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      8. lower-neg.f6451.4

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

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

    if 7e18 < F

    1. Initial program 48.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. Add Preprocessing
    3. Applied egg-rr62.1%

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

      \[\leadsto \color{blue}{\frac{-1 \cdot x + \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + {B}^{2} \cdot \left(\frac{1}{6} \cdot \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}\right) + \frac{1}{3} \cdot x\right)\right)}{B}} \]
    5. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} + \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + {B}^{2} \cdot \left(\frac{1}{6} \cdot \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}\right) + \frac{1}{3} \cdot x\right)\right)}{B} \]
      2. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + {B}^{2} \cdot \left(\frac{1}{6} \cdot \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}\right) + \frac{1}{3} \cdot x\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
      3. sub-negN/A

        \[\leadsto \frac{\color{blue}{\left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + {B}^{2} \cdot \left(\frac{1}{6} \cdot \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}\right) + \frac{1}{3} \cdot x\right)\right) - x}}{B} \]
      4. lower-/.f64N/A

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

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

      \[\leadsto \frac{\color{blue}{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right)} - x}{B} \]
    8. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left({B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right) + 1\right)} - x}{B} \]
      2. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left({B}^{2}, \frac{1}{6} + \frac{1}{3} \cdot x, 1\right)} - x}{B} \]
      3. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{B \cdot B}, \frac{1}{6} + \frac{1}{3} \cdot x, 1\right) - x}{B} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{B \cdot B}, \frac{1}{6} + \frac{1}{3} \cdot x, 1\right) - x}{B} \]
      5. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{\frac{1}{3} \cdot x + \frac{1}{6}}, 1\right) - x}{B} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{x \cdot \frac{1}{3}} + \frac{1}{6}, 1\right) - x}{B} \]
      7. lower-fma.f6449.9

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{\mathsf{fma}\left(x, 0.3333333333333333, 0.16666666666666666\right)}, 1\right) - x}{B} \]
    9. Simplified49.9%

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

Alternative 14: 43.4% accurate, 8.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;F \leq -2.05 \cdot 10^{-7}:\\
\;\;\;\;\frac{\mathsf{fma}\left(B \cdot B, \mathsf{fma}\left(x, 0.3333333333333333, -0.16666666666666666\right), -1\right) - x}{B}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(B \cdot B, \mathsf{fma}\left(x, 0.3333333333333333, 0.16666666666666666\right), 1\right) - x}{B}\\


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

    1. Initial program 62.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. Add Preprocessing
    3. Taylor expanded in F around -inf

      \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \frac{F}{\sin B} \cdot \color{blue}{\frac{-1}{F}} \]
    4. Step-by-step derivation
      1. lower-/.f6475.9

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

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

      \[\leadsto \color{blue}{\frac{{B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) - \left(1 + x\right)}{B}} \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{{B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) - \left(1 + x\right)}{B}} \]
      2. associate--r+N/A

        \[\leadsto \frac{\color{blue}{\left({B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) - 1\right) - x}}{B} \]
      3. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{\left({B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) - 1\right) - x}}{B} \]
      4. sub-negN/A

        \[\leadsto \frac{\color{blue}{\left({B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} - x}{B} \]
      5. metadata-evalN/A

        \[\leadsto \frac{\left({B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) + \color{blue}{-1}\right) - x}{B} \]
      6. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left({B}^{2}, \frac{1}{3} \cdot x - \frac{1}{6}, -1\right)} - x}{B} \]
      7. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{B \cdot B}, \frac{1}{3} \cdot x - \frac{1}{6}, -1\right) - x}{B} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{B \cdot B}, \frac{1}{3} \cdot x - \frac{1}{6}, -1\right) - x}{B} \]
      9. sub-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{\frac{1}{3} \cdot x + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right)}, -1\right) - x}{B} \]
      10. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{x \cdot \frac{1}{3}} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right), -1\right) - x}{B} \]
      11. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, x \cdot \frac{1}{3} + \color{blue}{\frac{-1}{6}}, -1\right) - x}{B} \]
      12. lower-fma.f6457.1

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{\mathsf{fma}\left(x, 0.3333333333333333, -0.16666666666666666\right)}, -1\right) - x}{B} \]
    8. Simplified57.1%

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

    if -2.05e-7 < F < 5.19999999999999973e-45

    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. Add Preprocessing
    3. 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}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
      2. sub-negN/A

        \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
      3. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}}{B} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      6. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\left(2 \cdot x + {F}^{2}\right) + 2}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      7. associate-+l+N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{2 \cdot x + \left({F}^{2} + 2\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{x \cdot 2} + \left({F}^{2} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{x \cdot 2 + \color{blue}{\left(2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      10. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(x, 2, 2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      11. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{{F}^{2} + 2}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      12. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{F \cdot F} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{\mathsf{fma}\left(F, F, 2\right)}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      14. lower-neg.f6452.4

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{B}} \]
    7. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{-1 \cdot x}{B}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(x\right)}}{B} \]
      3. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x\right)}{B}} \]
      4. lower-neg.f6435.9

        \[\leadsto \frac{\color{blue}{-x}}{B} \]
    8. Simplified35.9%

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

    if 5.19999999999999973e-45 < F

    1. Initial program 54.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. Add Preprocessing
    3. Applied egg-rr67.0%

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

      \[\leadsto \color{blue}{\frac{-1 \cdot x + \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + {B}^{2} \cdot \left(\frac{1}{6} \cdot \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}\right) + \frac{1}{3} \cdot x\right)\right)}{B}} \]
    5. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} + \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + {B}^{2} \cdot \left(\frac{1}{6} \cdot \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}\right) + \frac{1}{3} \cdot x\right)\right)}{B} \]
      2. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + {B}^{2} \cdot \left(\frac{1}{6} \cdot \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}\right) + \frac{1}{3} \cdot x\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
      3. sub-negN/A

        \[\leadsto \frac{\color{blue}{\left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + {B}^{2} \cdot \left(\frac{1}{6} \cdot \left(F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}\right) + \frac{1}{3} \cdot x\right)\right) - x}}{B} \]
      4. lower-/.f64N/A

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

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

      \[\leadsto \frac{\color{blue}{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right)\right)} - x}{B} \]
    8. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left({B}^{2} \cdot \left(\frac{1}{6} + \frac{1}{3} \cdot x\right) + 1\right)} - x}{B} \]
      2. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left({B}^{2}, \frac{1}{6} + \frac{1}{3} \cdot x, 1\right)} - x}{B} \]
      3. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{B \cdot B}, \frac{1}{6} + \frac{1}{3} \cdot x, 1\right) - x}{B} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{B \cdot B}, \frac{1}{6} + \frac{1}{3} \cdot x, 1\right) - x}{B} \]
      5. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{\frac{1}{3} \cdot x + \frac{1}{6}}, 1\right) - x}{B} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{x \cdot \frac{1}{3}} + \frac{1}{6}, 1\right) - x}{B} \]
      7. lower-fma.f6446.0

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{\mathsf{fma}\left(x, 0.3333333333333333, 0.16666666666666666\right)}, 1\right) - x}{B} \]
    9. Simplified46.0%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(B \cdot B, \mathsf{fma}\left(x, 0.3333333333333333, 0.16666666666666666\right), 1\right)} - x}{B} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification44.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \leq -2.05 \cdot 10^{-7}:\\ \;\;\;\;\frac{\mathsf{fma}\left(B \cdot B, \mathsf{fma}\left(x, 0.3333333333333333, -0.16666666666666666\right), -1\right) - x}{B}\\ \mathbf{elif}\;F \leq 5.2 \cdot 10^{-45}:\\ \;\;\;\;-\frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(B \cdot B, \mathsf{fma}\left(x, 0.3333333333333333, 0.16666666666666666\right), 1\right) - x}{B}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 43.4% accurate, 9.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;F \leq -2.05 \cdot 10^{-7}:\\
\;\;\;\;\frac{\mathsf{fma}\left(B \cdot B, \mathsf{fma}\left(x, 0.3333333333333333, -0.16666666666666666\right), -1\right) - x}{B}\\

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

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


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

    1. Initial program 62.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. Add Preprocessing
    3. Taylor expanded in F around -inf

      \[\leadsto \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) + \frac{F}{\sin B} \cdot \color{blue}{\frac{-1}{F}} \]
    4. Step-by-step derivation
      1. lower-/.f6475.9

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

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

      \[\leadsto \color{blue}{\frac{{B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) - \left(1 + x\right)}{B}} \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{{B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) - \left(1 + x\right)}{B}} \]
      2. associate--r+N/A

        \[\leadsto \frac{\color{blue}{\left({B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) - 1\right) - x}}{B} \]
      3. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{\left({B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) - 1\right) - x}}{B} \]
      4. sub-negN/A

        \[\leadsto \frac{\color{blue}{\left({B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} - x}{B} \]
      5. metadata-evalN/A

        \[\leadsto \frac{\left({B}^{2} \cdot \left(\frac{1}{3} \cdot x - \frac{1}{6}\right) + \color{blue}{-1}\right) - x}{B} \]
      6. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left({B}^{2}, \frac{1}{3} \cdot x - \frac{1}{6}, -1\right)} - x}{B} \]
      7. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{B \cdot B}, \frac{1}{3} \cdot x - \frac{1}{6}, -1\right) - x}{B} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{B \cdot B}, \frac{1}{3} \cdot x - \frac{1}{6}, -1\right) - x}{B} \]
      9. sub-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{\frac{1}{3} \cdot x + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right)}, -1\right) - x}{B} \]
      10. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{x \cdot \frac{1}{3}} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right), -1\right) - x}{B} \]
      11. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, x \cdot \frac{1}{3} + \color{blue}{\frac{-1}{6}}, -1\right) - x}{B} \]
      12. lower-fma.f6457.1

        \[\leadsto \frac{\mathsf{fma}\left(B \cdot B, \color{blue}{\mathsf{fma}\left(x, 0.3333333333333333, -0.16666666666666666\right)}, -1\right) - x}{B} \]
    8. Simplified57.1%

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

    if -2.05e-7 < F < 8.9999999999999997e-45

    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. Add Preprocessing
    3. 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}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
      2. sub-negN/A

        \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
      3. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}}{B} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      6. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\left(2 \cdot x + {F}^{2}\right) + 2}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      7. associate-+l+N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{2 \cdot x + \left({F}^{2} + 2\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{x \cdot 2} + \left({F}^{2} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{x \cdot 2 + \color{blue}{\left(2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      10. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(x, 2, 2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      11. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{{F}^{2} + 2}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      12. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{F \cdot F} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{\mathsf{fma}\left(F, F, 2\right)}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      14. lower-neg.f6452.4

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{B}} \]
    7. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{-1 \cdot x}{B}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(x\right)}}{B} \]
      3. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x\right)}{B}} \]
      4. lower-neg.f6435.9

        \[\leadsto \frac{\color{blue}{-x}}{B} \]
    8. Simplified35.9%

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

    if 8.9999999999999997e-45 < F

    1. Initial program 54.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. Add Preprocessing
    3. 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}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
      2. sub-negN/A

        \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
      3. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}}{B} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      6. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\left(2 \cdot x + {F}^{2}\right) + 2}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      7. associate-+l+N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{2 \cdot x + \left({F}^{2} + 2\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{x \cdot 2} + \left({F}^{2} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{x \cdot 2 + \color{blue}{\left(2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      10. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(x, 2, 2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      11. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{{F}^{2} + 2}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      12. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{F \cdot F} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{\mathsf{fma}\left(F, F, 2\right)}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      14. lower-neg.f6431.4

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

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

      \[\leadsto \color{blue}{\frac{1 - x}{B}} \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1 - x}{B}} \]
      2. lower--.f6445.7

        \[\leadsto \frac{\color{blue}{1 - x}}{B} \]
    8. Simplified45.7%

      \[\leadsto \color{blue}{\frac{1 - x}{B}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification44.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \leq -2.05 \cdot 10^{-7}:\\ \;\;\;\;\frac{\mathsf{fma}\left(B \cdot B, \mathsf{fma}\left(x, 0.3333333333333333, -0.16666666666666666\right), -1\right) - x}{B}\\ \mathbf{elif}\;F \leq 9 \cdot 10^{-45}:\\ \;\;\;\;-\frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - x}{B}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 43.4% accurate, 13.6× speedup?

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

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

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

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


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

    1. Initial program 62.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. Add Preprocessing
    3. 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}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
      2. sub-negN/A

        \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
      3. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}}{B} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      6. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\left(2 \cdot x + {F}^{2}\right) + 2}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      7. associate-+l+N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{2 \cdot x + \left({F}^{2} + 2\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{x \cdot 2} + \left({F}^{2} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{x \cdot 2 + \color{blue}{\left(2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      10. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(x, 2, 2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      11. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{{F}^{2} + 2}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      12. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{F \cdot F} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{\mathsf{fma}\left(F, F, 2\right)}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      14. lower-neg.f6451.1

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{1 + x}{B}} \]
    7. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(1 + x\right)}{B}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\left(1 + x\right)\right)}}{B} \]
      3. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(1 + x\right)\right)}{B}} \]
      4. distribute-neg-inN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(1\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
      5. metadata-evalN/A

        \[\leadsto \frac{\color{blue}{-1} + \left(\mathsf{neg}\left(x\right)\right)}{B} \]
      6. unsub-negN/A

        \[\leadsto \frac{\color{blue}{-1 - x}}{B} \]
      7. lower--.f6456.3

        \[\leadsto \frac{\color{blue}{-1 - x}}{B} \]
    8. Simplified56.3%

      \[\leadsto \color{blue}{\frac{-1 - x}{B}} \]

    if -4.60000000000000014e-10 < F < 8.9999999999999997e-45

    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. Add Preprocessing
    3. 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}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
      2. sub-negN/A

        \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
      3. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}}{B} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      6. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\left(2 \cdot x + {F}^{2}\right) + 2}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      7. associate-+l+N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{2 \cdot x + \left({F}^{2} + 2\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{x \cdot 2} + \left({F}^{2} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{x \cdot 2 + \color{blue}{\left(2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      10. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(x, 2, 2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      11. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{{F}^{2} + 2}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      12. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{F \cdot F} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{\mathsf{fma}\left(F, F, 2\right)}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      14. lower-neg.f6452.4

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{B}} \]
    7. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{-1 \cdot x}{B}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(x\right)}}{B} \]
      3. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x\right)}{B}} \]
      4. lower-neg.f6435.9

        \[\leadsto \frac{\color{blue}{-x}}{B} \]
    8. Simplified35.9%

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

    if 8.9999999999999997e-45 < F

    1. Initial program 54.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. Add Preprocessing
    3. 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}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
      2. sub-negN/A

        \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
      3. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}}{B} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      6. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\left(2 \cdot x + {F}^{2}\right) + 2}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      7. associate-+l+N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{2 \cdot x + \left({F}^{2} + 2\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{x \cdot 2} + \left({F}^{2} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{x \cdot 2 + \color{blue}{\left(2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      10. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(x, 2, 2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      11. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{{F}^{2} + 2}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      12. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{F \cdot F} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{\mathsf{fma}\left(F, F, 2\right)}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      14. lower-neg.f6431.4

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

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

      \[\leadsto \color{blue}{\frac{1 - x}{B}} \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1 - x}{B}} \]
      2. lower--.f6445.7

        \[\leadsto \frac{\color{blue}{1 - x}}{B} \]
    8. Simplified45.7%

      \[\leadsto \color{blue}{\frac{1 - x}{B}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification43.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \leq -4.6 \cdot 10^{-10}:\\ \;\;\;\;\frac{-1 - x}{B}\\ \mathbf{elif}\;F \leq 9 \cdot 10^{-45}:\\ \;\;\;\;-\frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - x}{B}\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 36.1% accurate, 17.5× speedup?

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

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

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


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

    1. Initial program 62.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. Add Preprocessing
    3. 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}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
      2. sub-negN/A

        \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
      3. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}}{B} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      6. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\left(2 \cdot x + {F}^{2}\right) + 2}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      7. associate-+l+N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{2 \cdot x + \left({F}^{2} + 2\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{x \cdot 2} + \left({F}^{2} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{x \cdot 2 + \color{blue}{\left(2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      10. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(x, 2, 2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      11. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{{F}^{2} + 2}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      12. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{F \cdot F} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{\mathsf{fma}\left(F, F, 2\right)}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      14. lower-neg.f6451.1

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{1 + x}{B}} \]
    7. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(1 + x\right)}{B}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\left(1 + x\right)\right)}}{B} \]
      3. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(1 + x\right)\right)}{B}} \]
      4. distribute-neg-inN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(1\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
      5. metadata-evalN/A

        \[\leadsto \frac{\color{blue}{-1} + \left(\mathsf{neg}\left(x\right)\right)}{B} \]
      6. unsub-negN/A

        \[\leadsto \frac{\color{blue}{-1 - x}}{B} \]
      7. lower--.f6456.3

        \[\leadsto \frac{\color{blue}{-1 - x}}{B} \]
    8. Simplified56.3%

      \[\leadsto \color{blue}{\frac{-1 - x}{B}} \]

    if -4.60000000000000014e-10 < F

    1. Initial program 79.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. Add Preprocessing
    3. 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}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
      2. sub-negN/A

        \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
      3. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}}{B} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      6. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\left(2 \cdot x + {F}^{2}\right) + 2}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      7. associate-+l+N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{2 \cdot x + \left({F}^{2} + 2\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{x \cdot 2} + \left({F}^{2} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{x \cdot 2 + \color{blue}{\left(2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      10. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(x, 2, 2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      11. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{{F}^{2} + 2}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      12. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{F \cdot F} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      13. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{\mathsf{fma}\left(F, F, 2\right)}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
      14. lower-neg.f6442.8

        \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}}, \color{blue}{-x}\right)}{B} \]
    5. Simplified42.8%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{B}} \]
    7. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{-1 \cdot x}{B}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(x\right)}}{B} \]
      3. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x\right)}{B}} \]
      4. lower-neg.f6428.5

        \[\leadsto \frac{\color{blue}{-x}}{B} \]
    8. Simplified28.5%

      \[\leadsto \color{blue}{\frac{-x}{B}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification34.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \leq -4.6 \cdot 10^{-10}:\\ \;\;\;\;\frac{-1 - x}{B}\\ \mathbf{else}:\\ \;\;\;\;-\frac{x}{B}\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 29.1% accurate, 26.3× speedup?

\[\begin{array}{l} \\ -\frac{x}{B} \end{array} \]
(FPCore (F B x) :precision binary64 (- (/ x B)))
double code(double F, double B, double x) {
	return -(x / B);
}
real(8) function code(f, b, x)
    real(8), intent (in) :: f
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    code = -(x / b)
end function
public static double code(double F, double B, double x) {
	return -(x / B);
}
def code(F, B, x):
	return -(x / B)
function code(F, B, x)
	return Float64(-Float64(x / B))
end
function tmp = code(F, B, x)
	tmp = -(x / B);
end
code[F_, B_, x_] := (-N[(x / B), $MachinePrecision])
\begin{array}{l}

\\
-\frac{x}{B}
\end{array}
Derivation
  1. Initial program 75.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. Add Preprocessing
  3. 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}} \]
  4. Step-by-step derivation
    1. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
    2. sub-negN/A

      \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
    3. lower-fma.f64N/A

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}}{B} \]
    4. lower-sqrt.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(F, \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
    5. lower-/.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
    6. +-commutativeN/A

      \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\left(2 \cdot x + {F}^{2}\right) + 2}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
    7. associate-+l+N/A

      \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{2 \cdot x + \left({F}^{2} + 2\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
    8. *-commutativeN/A

      \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{x \cdot 2} + \left({F}^{2} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
    9. +-commutativeN/A

      \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{x \cdot 2 + \color{blue}{\left(2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
    10. lower-fma.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(x, 2, 2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
    11. +-commutativeN/A

      \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{{F}^{2} + 2}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
    12. unpow2N/A

      \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{F \cdot F} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
    13. lower-fma.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{\mathsf{fma}\left(F, F, 2\right)}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
    14. lower-neg.f6444.6

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

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

    \[\leadsto \color{blue}{-1 \cdot \frac{x}{B}} \]
  7. Step-by-step derivation
    1. associate-*r/N/A

      \[\leadsto \color{blue}{\frac{-1 \cdot x}{B}} \]
    2. mul-1-negN/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(x\right)}}{B} \]
    3. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x\right)}{B}} \]
    4. lower-neg.f6430.4

      \[\leadsto \frac{\color{blue}{-x}}{B} \]
  8. Simplified30.4%

    \[\leadsto \color{blue}{\frac{-x}{B}} \]
  9. Final simplification30.4%

    \[\leadsto -\frac{x}{B} \]
  10. Add Preprocessing

Alternative 19: 10.2% 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;
}
real(8) function code(f, b, x)
    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 75.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. Add Preprocessing
  3. 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}} \]
  4. Step-by-step derivation
    1. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} - x}{B}} \]
    2. sub-negN/A

      \[\leadsto \frac{\color{blue}{F \cdot \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}} + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
    3. lower-fma.f64N/A

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(F, \sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}, \mathsf{neg}\left(x\right)\right)}}{B} \]
    4. lower-sqrt.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(F, \color{blue}{\sqrt{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
    5. lower-/.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\color{blue}{\frac{1}{2 + \left(2 \cdot x + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
    6. +-commutativeN/A

      \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\left(2 \cdot x + {F}^{2}\right) + 2}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
    7. associate-+l+N/A

      \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{2 \cdot x + \left({F}^{2} + 2\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
    8. *-commutativeN/A

      \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{x \cdot 2} + \left({F}^{2} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
    9. +-commutativeN/A

      \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{x \cdot 2 + \color{blue}{\left(2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
    10. lower-fma.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(x, 2, 2 + {F}^{2}\right)}}}, \mathsf{neg}\left(x\right)\right)}{B} \]
    11. +-commutativeN/A

      \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{{F}^{2} + 2}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
    12. unpow2N/A

      \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{F \cdot F} + 2\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
    13. lower-fma.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(F, \sqrt{\frac{1}{\mathsf{fma}\left(x, 2, \color{blue}{\mathsf{fma}\left(F, F, 2\right)}\right)}}, \mathsf{neg}\left(x\right)\right)}{B} \]
    14. lower-neg.f6444.6

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

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

    \[\leadsto \color{blue}{-1 \cdot \frac{1 + x}{B}} \]
  7. Step-by-step derivation
    1. associate-*r/N/A

      \[\leadsto \color{blue}{\frac{-1 \cdot \left(1 + x\right)}{B}} \]
    2. mul-1-negN/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\left(1 + x\right)\right)}}{B} \]
    3. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(1 + x\right)\right)}{B}} \]
    4. distribute-neg-inN/A

      \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(1\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}}{B} \]
    5. metadata-evalN/A

      \[\leadsto \frac{\color{blue}{-1} + \left(\mathsf{neg}\left(x\right)\right)}{B} \]
    6. unsub-negN/A

      \[\leadsto \frac{\color{blue}{-1 - x}}{B} \]
    7. lower--.f6427.4

      \[\leadsto \frac{\color{blue}{-1 - x}}{B} \]
  8. Simplified27.4%

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

    \[\leadsto \color{blue}{\frac{-1}{B}} \]
  10. Step-by-step derivation
    1. lower-/.f647.7

      \[\leadsto \color{blue}{\frac{-1}{B}} \]
  11. Simplified7.7%

    \[\leadsto \color{blue}{\frac{-1}{B}} \]
  12. Add Preprocessing

Reproduce

?
herbie shell --seed 2024210 
(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))))))