VandenBroeck and Keller, Equation (24)

Percentage Accurate: 99.7% → 99.7%
Time: 11.2s
Alternatives: 13
Speedup: 1.1×

Specification

?
\[\begin{array}{l} \\ \left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \end{array} \]
(FPCore (B x)
 :precision binary64
 (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))
double code(double B, double x) {
	return -(x * (1.0 / tan(B))) + (1.0 / sin(B));
}
real(8) function code(b, x)
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    code = -(x * (1.0d0 / tan(b))) + (1.0d0 / sin(b))
end function
public static double code(double B, double x) {
	return -(x * (1.0 / Math.tan(B))) + (1.0 / Math.sin(B));
}
def code(B, x):
	return -(x * (1.0 / math.tan(B))) + (1.0 / math.sin(B))
function code(B, x)
	return Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(1.0 / sin(B)))
end
function tmp = code(B, x)
	tmp = -(x * (1.0 / tan(B))) + (1.0 / sin(B));
end
code[B_, x_] := N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

\[\begin{array}{l} \\ \left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \end{array} \]
(FPCore (B x)
 :precision binary64
 (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))
double code(double B, double x) {
	return -(x * (1.0 / tan(B))) + (1.0 / sin(B));
}
real(8) function code(b, x)
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    code = -(x * (1.0d0 / tan(b))) + (1.0d0 / sin(b))
end function
public static double code(double B, double x) {
	return -(x * (1.0 / Math.tan(B))) + (1.0 / Math.sin(B));
}
def code(B, x):
	return -(x * (1.0 / math.tan(B))) + (1.0 / math.sin(B))
function code(B, x)
	return Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(1.0 / sin(B)))
end
function tmp = code(B, x)
	tmp = -(x * (1.0 / tan(B))) + (1.0 / sin(B));
end
code[B_, x_] := N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 99.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\frac{x}{\sin B}, -\cos B, \frac{1}{\sin B}\right) \end{array} \]
(FPCore (B x)
 :precision binary64
 (fma (/ x (sin B)) (- (cos B)) (/ 1.0 (sin B))))
double code(double B, double x) {
	return fma((x / sin(B)), -cos(B), (1.0 / sin(B)));
}
function code(B, x)
	return fma(Float64(x / sin(B)), Float64(-cos(B)), Float64(1.0 / sin(B)))
end
code[B_, x_] := N[(N[(x / N[Sin[B], $MachinePrecision]), $MachinePrecision] * (-N[Cos[B], $MachinePrecision]) + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\frac{x}{\sin B}, -\cos B, \frac{1}{\sin B}\right)
\end{array}
Derivation
  1. Initial program 99.6%

    \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
  2. Add Preprocessing
  3. Applied egg-rr99.8%

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

Alternative 2: 99.7% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \frac{1 - x \cdot \cos B}{\sin B} \end{array} \]
(FPCore (B x) :precision binary64 (/ (- 1.0 (* x (cos B))) (sin B)))
double code(double B, double x) {
	return (1.0 - (x * cos(B))) / sin(B);
}
real(8) function code(b, x)
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    code = (1.0d0 - (x * cos(b))) / sin(b)
end function
public static double code(double B, double x) {
	return (1.0 - (x * Math.cos(B))) / Math.sin(B);
}
def code(B, x):
	return (1.0 - (x * math.cos(B))) / math.sin(B)
function code(B, x)
	return Float64(Float64(1.0 - Float64(x * cos(B))) / sin(B))
end
function tmp = code(B, x)
	tmp = (1.0 - (x * cos(B))) / sin(B);
end
code[B_, x_] := N[(N[(1.0 - N[(x * N[Cos[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1 - x \cdot \cos B}{\sin B}
\end{array}
Derivation
  1. Initial program 99.6%

    \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
  2. Add Preprocessing
  3. Applied egg-rr99.8%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\sin B}} \cdot \cos B \]
    13. associate-*l/N/A

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot \cos B}{\sin B}} \]
    14. sub-divN/A

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

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

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

      \[\leadsto \frac{1 - \color{blue}{x \cdot \cos B}}{\sin B} \]
  5. Applied egg-rr99.8%

    \[\leadsto \color{blue}{\frac{1 - x \cdot \cos B}{\sin B}} \]
  6. Add Preprocessing

Alternative 3: 98.3% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1300:\\
\;\;\;\;\frac{-x}{\tan B}\\

\mathbf{elif}\;x \leq 2.2 \cdot 10^{-18}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\

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


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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot \cos B}{-\color{blue}{\sin B}} \]
    5. Simplified96.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{-1 \cdot \sin B}{\color{blue}{x \cdot \cos B}}} \]
      13. times-fracN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{-1}{x} \cdot \frac{\sin B}{\cos B}}} \]
      14. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{1}{\frac{-1}{x}}}{\frac{\sin B}{\cos B}}} \]
      15. clear-numN/A

        \[\leadsto \frac{\color{blue}{\frac{x}{-1}}}{\frac{\sin B}{\cos B}} \]
      16. div-invN/A

        \[\leadsto \frac{\color{blue}{x \cdot \frac{1}{-1}}}{\frac{\sin B}{\cos B}} \]
      17. metadata-evalN/A

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

        \[\leadsto \frac{\color{blue}{-1 \cdot x}}{\frac{\sin B}{\cos B}} \]
      19. neg-mul-1N/A

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

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(x\right)}{\frac{\sin B}{\color{blue}{\cos B}}} \]
      24. quot-tanN/A

        \[\leadsto \frac{\mathsf{neg}\left(x\right)}{\color{blue}{\tan B}} \]
      25. lower-tan.f6496.5

        \[\leadsto \frac{-x}{\color{blue}{\tan B}} \]
    7. Applied egg-rr96.5%

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

    if -1300 < x < 2.1999999999999998e-18

    1. Initial program 99.8%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Add Preprocessing
    3. Applied egg-rr99.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\sin B}} \cdot \cos B \]
      13. associate-*l/N/A

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot \cos B}{\sin B}} \]
      14. sub-divN/A

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

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

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

        \[\leadsto \frac{1 - \color{blue}{x \cdot \cos B}}{\sin B} \]
    5. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\frac{1 - x \cdot \cos B}{\sin B}} \]
    6. Taylor expanded in B around 0

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

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

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

    if 2.1999999999999998e-18 < x

    1. Initial program 99.5%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Add Preprocessing
    3. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
    4. Taylor expanded in B around 0

      \[\leadsto \frac{1}{\color{blue}{B \cdot \left(1 + {B}^{2} \cdot \left({B}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {B}^{2}\right) - \frac{1}{6}\right)\right)}} - \frac{x}{\tan B} \]
    5. Step-by-step derivation
      1. distribute-rgt-inN/A

        \[\leadsto \frac{1}{\color{blue}{1 \cdot B + \left({B}^{2} \cdot \left({B}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {B}^{2}\right) - \frac{1}{6}\right)\right) \cdot B}} - \frac{x}{\tan B} \]
      2. *-lft-identityN/A

        \[\leadsto \frac{1}{\color{blue}{B} + \left({B}^{2} \cdot \left({B}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {B}^{2}\right) - \frac{1}{6}\right)\right) \cdot B} - \frac{x}{\tan B} \]
      3. +-commutativeN/A

        \[\leadsto \frac{1}{\color{blue}{\left({B}^{2} \cdot \left({B}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {B}^{2}\right) - \frac{1}{6}\right)\right) \cdot B + B}} - \frac{x}{\tan B} \]
      4. *-commutativeN/A

        \[\leadsto \frac{1}{\color{blue}{\left(\left({B}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {B}^{2}\right) - \frac{1}{6}\right) \cdot {B}^{2}\right)} \cdot B + B} - \frac{x}{\tan B} \]
      5. associate-*l*N/A

        \[\leadsto \frac{1}{\color{blue}{\left({B}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {B}^{2}\right) - \frac{1}{6}\right) \cdot \left({B}^{2} \cdot B\right)} + B} - \frac{x}{\tan B} \]
      6. unpow2N/A

        \[\leadsto \frac{1}{\left({B}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {B}^{2}\right) - \frac{1}{6}\right) \cdot \left(\color{blue}{\left(B \cdot B\right)} \cdot B\right) + B} - \frac{x}{\tan B} \]
      7. unpow3N/A

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

        \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left({B}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {B}^{2}\right) - \frac{1}{6}, {B}^{3}, B\right)}} - \frac{x}{\tan B} \]
    6. Simplified97.0%

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

Alternative 4: 98.3% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1300:\\
\;\;\;\;\frac{-x}{\tan B}\\

\mathbf{elif}\;x \leq 2.2 \cdot 10^{-18}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\

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


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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot \cos B}{-\color{blue}{\sin B}} \]
    5. Simplified96.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{-1 \cdot \sin B}{\color{blue}{x \cdot \cos B}}} \]
      13. times-fracN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{-1}{x} \cdot \frac{\sin B}{\cos B}}} \]
      14. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{1}{\frac{-1}{x}}}{\frac{\sin B}{\cos B}}} \]
      15. clear-numN/A

        \[\leadsto \frac{\color{blue}{\frac{x}{-1}}}{\frac{\sin B}{\cos B}} \]
      16. div-invN/A

        \[\leadsto \frac{\color{blue}{x \cdot \frac{1}{-1}}}{\frac{\sin B}{\cos B}} \]
      17. metadata-evalN/A

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

        \[\leadsto \frac{\color{blue}{-1 \cdot x}}{\frac{\sin B}{\cos B}} \]
      19. neg-mul-1N/A

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

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(x\right)}{\frac{\sin B}{\color{blue}{\cos B}}} \]
      24. quot-tanN/A

        \[\leadsto \frac{\mathsf{neg}\left(x\right)}{\color{blue}{\tan B}} \]
      25. lower-tan.f6496.5

        \[\leadsto \frac{-x}{\color{blue}{\tan B}} \]
    7. Applied egg-rr96.5%

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

    if -1300 < x < 2.1999999999999998e-18

    1. Initial program 99.8%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Add Preprocessing
    3. Applied egg-rr99.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\sin B}} \cdot \cos B \]
      13. associate-*l/N/A

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot \cos B}{\sin B}} \]
      14. sub-divN/A

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

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

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

        \[\leadsto \frac{1 - \color{blue}{x \cdot \cos B}}{\sin B} \]
    5. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\frac{1 - x \cdot \cos B}{\sin B}} \]
    6. Taylor expanded in B around 0

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

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

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

    if 2.1999999999999998e-18 < x

    1. Initial program 99.5%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Add Preprocessing
    3. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
    4. Taylor expanded in B around 0

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

        \[\leadsto \frac{1}{B \cdot \color{blue}{\left({B}^{2} \cdot \left(\frac{1}{120} \cdot {B}^{2} - \frac{1}{6}\right) + 1\right)}} - \frac{x}{\tan B} \]
      2. distribute-rgt-inN/A

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

        \[\leadsto \frac{1}{\color{blue}{{B}^{2} \cdot \left(\left(\frac{1}{120} \cdot {B}^{2} - \frac{1}{6}\right) \cdot B\right)} + 1 \cdot B} - \frac{x}{\tan B} \]
      4. *-lft-identityN/A

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\mathsf{fma}\left(B \cdot B, \left(\color{blue}{\left(B \cdot B\right)} \cdot \frac{1}{120} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right)\right) \cdot B, B\right)} - \frac{x}{\tan B} \]
      12. associate-*l*N/A

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

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

        \[\leadsto \frac{1}{\mathsf{fma}\left(B \cdot B, \color{blue}{\mathsf{fma}\left(B, B \cdot \frac{1}{120}, \frac{-1}{6}\right)} \cdot B, B\right)} - \frac{x}{\tan B} \]
      15. lower-*.f6496.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1300:\\ \;\;\;\;\frac{-x}{\tan B}\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{-18}:\\ \;\;\;\;\frac{1 - x}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(B \cdot B, B \cdot \mathsf{fma}\left(B, B \cdot 0.008333333333333333, -0.16666666666666666\right), B\right)} - \frac{x}{\tan B}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 98.3% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1300:\\
\;\;\;\;\frac{-x}{\tan B}\\

\mathbf{elif}\;x \leq 2.2 \cdot 10^{-18}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\

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


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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot \cos B}{-\color{blue}{\sin B}} \]
    5. Simplified96.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{-1 \cdot \sin B}{\color{blue}{x \cdot \cos B}}} \]
      13. times-fracN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{-1}{x} \cdot \frac{\sin B}{\cos B}}} \]
      14. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{1}{\frac{-1}{x}}}{\frac{\sin B}{\cos B}}} \]
      15. clear-numN/A

        \[\leadsto \frac{\color{blue}{\frac{x}{-1}}}{\frac{\sin B}{\cos B}} \]
      16. div-invN/A

        \[\leadsto \frac{\color{blue}{x \cdot \frac{1}{-1}}}{\frac{\sin B}{\cos B}} \]
      17. metadata-evalN/A

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

        \[\leadsto \frac{\color{blue}{-1 \cdot x}}{\frac{\sin B}{\cos B}} \]
      19. neg-mul-1N/A

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

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(x\right)}{\frac{\sin B}{\color{blue}{\cos B}}} \]
      24. quot-tanN/A

        \[\leadsto \frac{\mathsf{neg}\left(x\right)}{\color{blue}{\tan B}} \]
      25. lower-tan.f6496.5

        \[\leadsto \frac{-x}{\color{blue}{\tan B}} \]
    7. Applied egg-rr96.5%

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

    if -1300 < x < 2.1999999999999998e-18

    1. Initial program 99.8%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Add Preprocessing
    3. Applied egg-rr99.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\sin B}} \cdot \cos B \]
      13. associate-*l/N/A

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot \cos B}{\sin B}} \]
      14. sub-divN/A

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

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

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

        \[\leadsto \frac{1 - \color{blue}{x \cdot \cos B}}{\sin B} \]
    5. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\frac{1 - x \cdot \cos B}{\sin B}} \]
    6. Taylor expanded in B around 0

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

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

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

    if 2.1999999999999998e-18 < x

    1. Initial program 99.5%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Add Preprocessing
    3. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
    4. Taylor expanded in B around 0

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

        \[\leadsto \frac{1}{B \cdot \color{blue}{\left(\frac{-1}{6} \cdot {B}^{2} + 1\right)}} - \frac{x}{\tan B} \]
      2. distribute-lft-inN/A

        \[\leadsto \frac{1}{\color{blue}{B \cdot \left(\frac{-1}{6} \cdot {B}^{2}\right) + B \cdot 1}} - \frac{x}{\tan B} \]
      3. *-rgt-identityN/A

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

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

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

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

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

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

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

Alternative 6: 98.3% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1300:\\ \;\;\;\;\frac{-x}{\tan B}\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{-18}:\\ \;\;\;\;\frac{1 - x}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\ \end{array} \end{array} \]
(FPCore (B x)
 :precision binary64
 (if (<= x -1300.0)
   (/ (- x) (tan B))
   (if (<= x 2.2e-18) (/ (- 1.0 x) (sin B)) (- (/ 1.0 B) (/ x (tan B))))))
double code(double B, double x) {
	double tmp;
	if (x <= -1300.0) {
		tmp = -x / tan(B);
	} else if (x <= 2.2e-18) {
		tmp = (1.0 - x) / sin(B);
	} else {
		tmp = (1.0 / B) - (x / tan(B));
	}
	return tmp;
}
real(8) function code(b, x)
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-1300.0d0)) then
        tmp = -x / tan(b)
    else if (x <= 2.2d-18) then
        tmp = (1.0d0 - x) / sin(b)
    else
        tmp = (1.0d0 / b) - (x / tan(b))
    end if
    code = tmp
end function
public static double code(double B, double x) {
	double tmp;
	if (x <= -1300.0) {
		tmp = -x / Math.tan(B);
	} else if (x <= 2.2e-18) {
		tmp = (1.0 - x) / Math.sin(B);
	} else {
		tmp = (1.0 / B) - (x / Math.tan(B));
	}
	return tmp;
}
def code(B, x):
	tmp = 0
	if x <= -1300.0:
		tmp = -x / math.tan(B)
	elif x <= 2.2e-18:
		tmp = (1.0 - x) / math.sin(B)
	else:
		tmp = (1.0 / B) - (x / math.tan(B))
	return tmp
function code(B, x)
	tmp = 0.0
	if (x <= -1300.0)
		tmp = Float64(Float64(-x) / tan(B));
	elseif (x <= 2.2e-18)
		tmp = Float64(Float64(1.0 - x) / sin(B));
	else
		tmp = Float64(Float64(1.0 / B) - Float64(x / tan(B)));
	end
	return tmp
end
function tmp_2 = code(B, x)
	tmp = 0.0;
	if (x <= -1300.0)
		tmp = -x / tan(B);
	elseif (x <= 2.2e-18)
		tmp = (1.0 - x) / sin(B);
	else
		tmp = (1.0 / B) - (x / tan(B));
	end
	tmp_2 = tmp;
end
code[B_, x_] := If[LessEqual[x, -1300.0], N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.2e-18], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / B), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1300:\\
\;\;\;\;\frac{-x}{\tan B}\\

\mathbf{elif}\;x \leq 2.2 \cdot 10^{-18}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\

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


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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot \cos B}{-\color{blue}{\sin B}} \]
    5. Simplified96.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{-1 \cdot \sin B}{\color{blue}{x \cdot \cos B}}} \]
      13. times-fracN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{-1}{x} \cdot \frac{\sin B}{\cos B}}} \]
      14. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{1}{\frac{-1}{x}}}{\frac{\sin B}{\cos B}}} \]
      15. clear-numN/A

        \[\leadsto \frac{\color{blue}{\frac{x}{-1}}}{\frac{\sin B}{\cos B}} \]
      16. div-invN/A

        \[\leadsto \frac{\color{blue}{x \cdot \frac{1}{-1}}}{\frac{\sin B}{\cos B}} \]
      17. metadata-evalN/A

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

        \[\leadsto \frac{\color{blue}{-1 \cdot x}}{\frac{\sin B}{\cos B}} \]
      19. neg-mul-1N/A

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

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(x\right)}{\frac{\sin B}{\color{blue}{\cos B}}} \]
      24. quot-tanN/A

        \[\leadsto \frac{\mathsf{neg}\left(x\right)}{\color{blue}{\tan B}} \]
      25. lower-tan.f6496.5

        \[\leadsto \frac{-x}{\color{blue}{\tan B}} \]
    7. Applied egg-rr96.5%

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

    if -1300 < x < 2.1999999999999998e-18

    1. Initial program 99.8%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Add Preprocessing
    3. Applied egg-rr99.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\sin B}} \cdot \cos B \]
      13. associate-*l/N/A

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot \cos B}{\sin B}} \]
      14. sub-divN/A

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

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

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

        \[\leadsto \frac{1 - \color{blue}{x \cdot \cos B}}{\sin B} \]
    5. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\frac{1 - x \cdot \cos B}{\sin B}} \]
    6. Taylor expanded in B around 0

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

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

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

    if 2.1999999999999998e-18 < x

    1. Initial program 99.5%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    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{1}{B}} \]
    4. Step-by-step derivation
      1. lower-/.f6496.5

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

      \[\leadsto \left(-x \cdot \frac{1}{\tan B}\right) + \color{blue}{\frac{1}{B}} \]
    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{1}{B} \]
      2. lift-/.f64N/A

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{B} - x \cdot \frac{1}{\tan B}} \]
      9. lower--.f6496.5

        \[\leadsto \color{blue}{\frac{1}{B} - x \cdot \frac{1}{\tan B}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
      11. lift-/.f64N/A

        \[\leadsto \frac{1}{B} - x \cdot \color{blue}{\frac{1}{\tan B}} \]
      12. un-div-invN/A

        \[\leadsto \frac{1}{B} - \color{blue}{\frac{x}{\tan B}} \]
      13. lower-/.f6496.7

        \[\leadsto \frac{1}{B} - \color{blue}{\frac{x}{\tan B}} \]
    7. Applied egg-rr96.7%

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

Alternative 7: 98.4% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-x}{\tan B}\\ \mathbf{if}\;x \leq -1300:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 35:\\ \;\;\;\;\frac{1 - x}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (B x)
 :precision binary64
 (let* ((t_0 (/ (- x) (tan B))))
   (if (<= x -1300.0) t_0 (if (<= x 35.0) (/ (- 1.0 x) (sin B)) t_0))))
double code(double B, double x) {
	double t_0 = -x / tan(B);
	double tmp;
	if (x <= -1300.0) {
		tmp = t_0;
	} else if (x <= 35.0) {
		tmp = (1.0 - x) / sin(B);
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(b, x)
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    real(8) :: t_0
    real(8) :: tmp
    t_0 = -x / tan(b)
    if (x <= (-1300.0d0)) then
        tmp = t_0
    else if (x <= 35.0d0) then
        tmp = (1.0d0 - x) / sin(b)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double B, double x) {
	double t_0 = -x / Math.tan(B);
	double tmp;
	if (x <= -1300.0) {
		tmp = t_0;
	} else if (x <= 35.0) {
		tmp = (1.0 - x) / Math.sin(B);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(B, x):
	t_0 = -x / math.tan(B)
	tmp = 0
	if x <= -1300.0:
		tmp = t_0
	elif x <= 35.0:
		tmp = (1.0 - x) / math.sin(B)
	else:
		tmp = t_0
	return tmp
function code(B, x)
	t_0 = Float64(Float64(-x) / tan(B))
	tmp = 0.0
	if (x <= -1300.0)
		tmp = t_0;
	elseif (x <= 35.0)
		tmp = Float64(Float64(1.0 - x) / sin(B));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(B, x)
	t_0 = -x / tan(B);
	tmp = 0.0;
	if (x <= -1300.0)
		tmp = t_0;
	elseif (x <= 35.0)
		tmp = (1.0 - x) / sin(B);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[B_, x_] := Block[{t$95$0 = N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1300.0], t$95$0, If[LessEqual[x, 35.0], N[(N[(1.0 - 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 -1300:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 35:\\
\;\;\;\;\frac{1 - x}{\sin B}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1300 or 35 < x

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot \cos B}{-\color{blue}{\sin B}} \]
    5. Simplified96.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{-1 \cdot \sin B}{\color{blue}{x \cdot \cos B}}} \]
      13. times-fracN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{-1}{x} \cdot \frac{\sin B}{\cos B}}} \]
      14. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{1}{\frac{-1}{x}}}{\frac{\sin B}{\cos B}}} \]
      15. clear-numN/A

        \[\leadsto \frac{\color{blue}{\frac{x}{-1}}}{\frac{\sin B}{\cos B}} \]
      16. div-invN/A

        \[\leadsto \frac{\color{blue}{x \cdot \frac{1}{-1}}}{\frac{\sin B}{\cos B}} \]
      17. metadata-evalN/A

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

        \[\leadsto \frac{\color{blue}{-1 \cdot x}}{\frac{\sin B}{\cos B}} \]
      19. neg-mul-1N/A

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

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(x\right)}{\frac{\sin B}{\color{blue}{\cos B}}} \]
      24. quot-tanN/A

        \[\leadsto \frac{\mathsf{neg}\left(x\right)}{\color{blue}{\tan B}} \]
      25. lower-tan.f6496.2

        \[\leadsto \frac{-x}{\color{blue}{\tan B}} \]
    7. Applied egg-rr96.2%

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

    if -1300 < x < 35

    1. Initial program 99.8%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Add Preprocessing
    3. Applied egg-rr99.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\sin B}} \cdot \cos B \]
      13. associate-*l/N/A

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot \cos B}{\sin B}} \]
      14. sub-divN/A

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

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

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

        \[\leadsto \frac{1 - \color{blue}{x \cdot \cos B}}{\sin B} \]
    5. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\frac{1 - x \cdot \cos B}{\sin B}} \]
    6. Taylor expanded in B around 0

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

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

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

Alternative 8: 97.7% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-x}{\tan B}\\ \mathbf{if}\;x \leq -1.8:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\frac{1}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (B x)
 :precision binary64
 (let* ((t_0 (/ (- x) (tan B))))
   (if (<= x -1.8) t_0 (if (<= x 1.0) (/ 1.0 (sin B)) t_0))))
double code(double B, double x) {
	double t_0 = -x / tan(B);
	double tmp;
	if (x <= -1.8) {
		tmp = t_0;
	} else if (x <= 1.0) {
		tmp = 1.0 / sin(B);
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(b, x)
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    real(8) :: t_0
    real(8) :: tmp
    t_0 = -x / tan(b)
    if (x <= (-1.8d0)) then
        tmp = t_0
    else if (x <= 1.0d0) then
        tmp = 1.0d0 / sin(b)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double B, double x) {
	double t_0 = -x / Math.tan(B);
	double tmp;
	if (x <= -1.8) {
		tmp = t_0;
	} else if (x <= 1.0) {
		tmp = 1.0 / Math.sin(B);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(B, x):
	t_0 = -x / math.tan(B)
	tmp = 0
	if x <= -1.8:
		tmp = t_0
	elif x <= 1.0:
		tmp = 1.0 / math.sin(B)
	else:
		tmp = t_0
	return tmp
function code(B, x)
	t_0 = Float64(Float64(-x) / tan(B))
	tmp = 0.0
	if (x <= -1.8)
		tmp = t_0;
	elseif (x <= 1.0)
		tmp = Float64(1.0 / sin(B));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(B, x)
	t_0 = -x / tan(B);
	tmp = 0.0;
	if (x <= -1.8)
		tmp = t_0;
	elseif (x <= 1.0)
		tmp = 1.0 / sin(B);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[B_, x_] := Block[{t$95$0 = N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.8], t$95$0, If[LessEqual[x, 1.0], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{1}{\sin B}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.80000000000000004 or 1 < x

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot \cos B}{-\color{blue}{\sin B}} \]
    5. Simplified96.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{-1 \cdot \sin B}{\color{blue}{x \cdot \cos B}}} \]
      13. times-fracN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{-1}{x} \cdot \frac{\sin B}{\cos B}}} \]
      14. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{1}{\frac{-1}{x}}}{\frac{\sin B}{\cos B}}} \]
      15. clear-numN/A

        \[\leadsto \frac{\color{blue}{\frac{x}{-1}}}{\frac{\sin B}{\cos B}} \]
      16. div-invN/A

        \[\leadsto \frac{\color{blue}{x \cdot \frac{1}{-1}}}{\frac{\sin B}{\cos B}} \]
      17. metadata-evalN/A

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

        \[\leadsto \frac{\color{blue}{-1 \cdot x}}{\frac{\sin B}{\cos B}} \]
      19. neg-mul-1N/A

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

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(x\right)}{\frac{\sin B}{\color{blue}{\cos B}}} \]
      24. quot-tanN/A

        \[\leadsto \frac{\mathsf{neg}\left(x\right)}{\color{blue}{\tan B}} \]
      25. lower-tan.f6496.2

        \[\leadsto \frac{-x}{\color{blue}{\tan B}} \]
    7. Applied egg-rr96.2%

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

    if -1.80000000000000004 < x < 1

    1. Initial program 99.8%

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

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

        \[\leadsto \color{blue}{\frac{1}{\sin B}} \]
      2. lower-sin.f6498.4

        \[\leadsto \frac{1}{\color{blue}{\sin B}} \]
    5. Simplified98.4%

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

Alternative 9: 63.5% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;B \leq 1:\\ \;\;\;\;\frac{\mathsf{fma}\left(B \cdot B, \mathsf{fma}\left(x, 0.3333333333333333, \mathsf{fma}\left(B \cdot B, \mathsf{fma}\left(B, B \cdot \mathsf{fma}\left(x, 0.0021164021164021165, 0.00205026455026455\right), \mathsf{fma}\left(x, 0.022222222222222223, 0.019444444444444445\right)\right), 0.16666666666666666\right)\right), 1 - x\right)}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B}\\ \end{array} \end{array} \]
(FPCore (B x)
 :precision binary64
 (if (<= B 1.0)
   (/
    (fma
     (* B B)
     (fma
      x
      0.3333333333333333
      (fma
       (* B B)
       (fma
        B
        (* B (fma x 0.0021164021164021165 0.00205026455026455))
        (fma x 0.022222222222222223 0.019444444444444445))
       0.16666666666666666))
     (- 1.0 x))
    B)
   (/ 1.0 (sin B))))
double code(double B, double x) {
	double tmp;
	if (B <= 1.0) {
		tmp = fma((B * B), fma(x, 0.3333333333333333, fma((B * B), fma(B, (B * fma(x, 0.0021164021164021165, 0.00205026455026455)), fma(x, 0.022222222222222223, 0.019444444444444445)), 0.16666666666666666)), (1.0 - x)) / B;
	} else {
		tmp = 1.0 / sin(B);
	}
	return tmp;
}
function code(B, x)
	tmp = 0.0
	if (B <= 1.0)
		tmp = Float64(fma(Float64(B * B), fma(x, 0.3333333333333333, fma(Float64(B * B), fma(B, Float64(B * fma(x, 0.0021164021164021165, 0.00205026455026455)), fma(x, 0.022222222222222223, 0.019444444444444445)), 0.16666666666666666)), Float64(1.0 - x)) / B);
	else
		tmp = Float64(1.0 / sin(B));
	end
	return tmp
end
code[B_, x_] := If[LessEqual[B, 1.0], N[(N[(N[(B * B), $MachinePrecision] * N[(x * 0.3333333333333333 + N[(N[(B * B), $MachinePrecision] * N[(B * N[(B * N[(x * 0.0021164021164021165 + 0.00205026455026455), $MachinePrecision]), $MachinePrecision] + N[(x * 0.022222222222222223 + 0.019444444444444445), $MachinePrecision]), $MachinePrecision] + 0.16666666666666666), $MachinePrecision]), $MachinePrecision] + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;B \leq 1:\\
\;\;\;\;\frac{\mathsf{fma}\left(B \cdot B, \mathsf{fma}\left(x, 0.3333333333333333, \mathsf{fma}\left(B \cdot B, \mathsf{fma}\left(B, B \cdot \mathsf{fma}\left(x, 0.0021164021164021165, 0.00205026455026455\right), \mathsf{fma}\left(x, 0.022222222222222223, 0.019444444444444445\right)\right), 0.16666666666666666\right)\right), 1 - x\right)}{B}\\

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


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

    1. Initial program 99.7%

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

      \[\leadsto \color{blue}{\frac{\left(1 + {B}^{2} \cdot \left(\frac{1}{6} + \left(\frac{1}{3} \cdot x + {B}^{2} \cdot \left(\frac{7}{360} + \left(\frac{-1}{9} \cdot x + \left(\frac{2}{15} \cdot x + {B}^{2} \cdot \left(\frac{31}{15120} + \left(\frac{-1}{3} \cdot \left(\frac{-1}{9} \cdot x + \frac{2}{15} \cdot x\right) + \left(\frac{-2}{45} \cdot x + \frac{17}{315} \cdot x\right)\right)\right)\right)\right)\right)\right)\right)\right) - x}{B}} \]
    4. Simplified69.4%

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

    if 1 < B

    1. Initial program 99.3%

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\sin B}} \]
    5. Simplified39.7%

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

Alternative 10: 51.5% accurate, 8.0× speedup?

\[\begin{array}{l} \\ \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(B \cdot B, 0.3333333333333333, -1\right), 1\right)}{B} \end{array} \]
(FPCore (B x)
 :precision binary64
 (/ (fma x (fma (* B B) 0.3333333333333333 -1.0) 1.0) B))
double code(double B, double x) {
	return fma(x, fma((B * B), 0.3333333333333333, -1.0), 1.0) / B;
}
function code(B, x)
	return Float64(fma(x, fma(Float64(B * B), 0.3333333333333333, -1.0), 1.0) / B)
end
code[B_, x_] := N[(N[(x * N[(N[(B * B), $MachinePrecision] * 0.3333333333333333 + -1.0), $MachinePrecision] + 1.0), $MachinePrecision] / B), $MachinePrecision]
\begin{array}{l}

\\
\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(B \cdot B, 0.3333333333333333, -1\right), 1\right)}{B}
\end{array}
Derivation
  1. Initial program 99.6%

    \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
  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{1}{B}} \]
  4. Step-by-step derivation
    1. lower-/.f6479.1

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\left(\left(\frac{1}{3} \cdot {B}^{2}\right) \cdot x + \color{blue}{-1 \cdot x}\right) + 1}{B} \]
    7. distribute-rgt-outN/A

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

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

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

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

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

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

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

Alternative 11: 50.3% accurate, 9.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -\frac{x}{B}\\ \mathbf{if}\;x \leq -1:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 9000000:\\ \;\;\;\;\frac{1}{B}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (B x)
 :precision binary64
 (let* ((t_0 (- (/ x B))))
   (if (<= x -1.0) t_0 (if (<= x 9000000.0) (/ 1.0 B) t_0))))
double code(double B, double x) {
	double t_0 = -(x / B);
	double tmp;
	if (x <= -1.0) {
		tmp = t_0;
	} else if (x <= 9000000.0) {
		tmp = 1.0 / B;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(b, x)
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    real(8) :: t_0
    real(8) :: tmp
    t_0 = -(x / b)
    if (x <= (-1.0d0)) then
        tmp = t_0
    else if (x <= 9000000.0d0) then
        tmp = 1.0d0 / b
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double B, double x) {
	double t_0 = -(x / B);
	double tmp;
	if (x <= -1.0) {
		tmp = t_0;
	} else if (x <= 9000000.0) {
		tmp = 1.0 / B;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(B, x):
	t_0 = -(x / B)
	tmp = 0
	if x <= -1.0:
		tmp = t_0
	elif x <= 9000000.0:
		tmp = 1.0 / B
	else:
		tmp = t_0
	return tmp
function code(B, x)
	t_0 = Float64(-Float64(x / B))
	tmp = 0.0
	if (x <= -1.0)
		tmp = t_0;
	elseif (x <= 9000000.0)
		tmp = Float64(1.0 / B);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(B, x)
	t_0 = -(x / B);
	tmp = 0.0;
	if (x <= -1.0)
		tmp = t_0;
	elseif (x <= 9000000.0)
		tmp = 1.0 / B;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[B_, x_] := Block[{t$95$0 = (-N[(x / B), $MachinePrecision])}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, 9000000.0], N[(1.0 / B), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 9000000:\\
\;\;\;\;\frac{1}{B}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1 or 9e6 < x

    1. Initial program 99.5%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(x\right)}}{B} \]
      2. lower-neg.f6449.6

        \[\leadsto \frac{\color{blue}{-x}}{B} \]
    8. Simplified49.6%

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

    if -1 < x < 9e6

    1. Initial program 99.8%

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

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

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

        \[\leadsto \frac{\color{blue}{1 - x}}{B} \]
    5. Simplified58.0%

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

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

        \[\leadsto \color{blue}{\frac{1}{B}} \]
    8. Simplified57.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;-\frac{x}{B}\\ \mathbf{elif}\;x \leq 9000000:\\ \;\;\;\;\frac{1}{B}\\ \mathbf{else}:\\ \;\;\;\;-\frac{x}{B}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 51.5% accurate, 15.5× speedup?

\[\begin{array}{l} \\ \frac{1 - x}{B} \end{array} \]
(FPCore (B x) :precision binary64 (/ (- 1.0 x) B))
double code(double B, double x) {
	return (1.0 - x) / B;
}
real(8) function code(b, x)
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    code = (1.0d0 - x) / b
end function
public static double code(double B, double x) {
	return (1.0 - x) / B;
}
def code(B, x):
	return (1.0 - x) / B
function code(B, x)
	return Float64(Float64(1.0 - x) / B)
end
function tmp = code(B, x)
	tmp = (1.0 - x) / B;
end
code[B_, x_] := N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]
\begin{array}{l}

\\
\frac{1 - x}{B}
\end{array}
Derivation
  1. Initial program 99.6%

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

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

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

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

    \[\leadsto \color{blue}{\frac{1 - x}{B}} \]
  6. Add Preprocessing

Alternative 13: 26.4% accurate, 19.4× speedup?

\[\begin{array}{l} \\ \frac{1}{B} \end{array} \]
(FPCore (B x) :precision binary64 (/ 1.0 B))
double code(double B, double x) {
	return 1.0 / B;
}
real(8) function code(b, x)
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    code = 1.0d0 / b
end function
public static double code(double B, double x) {
	return 1.0 / B;
}
def code(B, x):
	return 1.0 / B
function code(B, x)
	return Float64(1.0 / B)
end
function tmp = code(B, x)
	tmp = 1.0 / B;
end
code[B_, x_] := N[(1.0 / B), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{B}} \]
  8. Simplified28.9%

    \[\leadsto \color{blue}{\frac{1}{B}} \]
  9. Add Preprocessing

Reproduce

?
herbie shell --seed 2024208 
(FPCore (B x)
  :name "VandenBroeck and Keller, Equation (24)"
  :precision binary64
  (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))