VandenBroeck and Keller, Equation (24)

Percentage Accurate: 99.7% → 99.8%
Time: 14.7s
Alternatives: 13
Speedup: 1.0×

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.8% accurate, 1.0× speedup?

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

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

    \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
  2. Step-by-step derivation
    1. distribute-lft-neg-in99.6%

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

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

      \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
    4. *-commutative99.6%

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{1}{\tan B} \cdot x} \]
    5. *-commutative99.6%

      \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
    6. associate-*r/99.7%

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot 1}{\tan B}} \]
    7. *-rgt-identity99.7%

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

    \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
  4. Final simplification99.7%

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

Alternative 2: 98.5% accurate, 1.0× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(-\cos B\right)}{\sin B}\\


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

    1. Initial program 99.5%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Step-by-step derivation
      1. distribute-lft-neg-in99.5%

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

        \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x\right) \cdot \frac{1}{\tan B}} \]
      3. distribute-lft-neg-in99.5%

        \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right)} \]
      4. distribute-rgt-neg-in99.5%

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

      \[\leadsto \color{blue}{\frac{1}{\sin B} + x \cdot \left(-\frac{1}{\tan B}\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-neg-out99.5%

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

        \[\leadsto \frac{1}{\sin B} + \left(-\color{blue}{\frac{x}{\tan B}}\right) \]
      3. sub-neg99.8%

        \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
      4. clear-num99.5%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{1}{\frac{\tan B}{x}}} \]
      5. frac-sub87.5%

        \[\leadsto \color{blue}{\frac{1 \cdot \frac{\tan B}{x} - \sin B \cdot 1}{\sin B \cdot \frac{\tan B}{x}}} \]
      6. *-un-lft-identity87.5%

        \[\leadsto \frac{\color{blue}{\frac{\tan B}{x}} - \sin B \cdot 1}{\sin B \cdot \frac{\tan B}{x}} \]
      7. *-commutative87.5%

        \[\leadsto \frac{\frac{\tan B}{x} - \color{blue}{1 \cdot \sin B}}{\sin B \cdot \frac{\tan B}{x}} \]
      8. *-un-lft-identity87.5%

        \[\leadsto \frac{\frac{\tan B}{x} - \color{blue}{\sin B}}{\sin B \cdot \frac{\tan B}{x}} \]
    5. Applied egg-rr87.5%

      \[\leadsto \color{blue}{\frac{\frac{\tan B}{x} - \sin B}{\sin B \cdot \frac{\tan B}{x}}} \]
    6. Step-by-step derivation
      1. associate-/r*99.5%

        \[\leadsto \color{blue}{\frac{\frac{\frac{\tan B}{x} - \sin B}{\sin B}}{\frac{\tan B}{x}}} \]
      2. div-sub99.5%

        \[\leadsto \frac{\color{blue}{\frac{\frac{\tan B}{x}}{\sin B} - \frac{\sin B}{\sin B}}}{\frac{\tan B}{x}} \]
      3. *-inverses99.5%

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

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

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

    if -1.44999999999999996 < x < 1.8e9

    1. Initial program 99.7%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Step-by-step derivation
      1. distribute-lft-neg-in99.7%

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

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

        \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
      4. *-commutative99.7%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{1}{\tan B} \cdot x} \]
      5. *-commutative99.7%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
      6. associate-*r/99.7%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot 1}{\tan B}} \]
      7. *-rgt-identity99.7%

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

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

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

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

    if 1.8e9 < x

    1. Initial program 99.3%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Step-by-step derivation
      1. distribute-lft-neg-in99.3%

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

        \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x\right) \cdot \frac{1}{\tan B}} \]
      3. cancel-sign-sub-inv99.3%

        \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
      4. *-commutative99.3%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{1}{\tan B} \cdot x} \]
      5. *-commutative99.3%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
      6. associate-*r/99.6%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot 1}{\tan B}} \]
      7. *-rgt-identity99.6%

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

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

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot \cos B}{\sin B}} \]
    5. Taylor expanded in x around inf 99.7%

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot \cos B}{\sin B}} \]
    6. Step-by-step derivation
      1. mul-1-neg99.7%

        \[\leadsto \color{blue}{-\frac{x \cdot \cos B}{\sin B}} \]
      2. associate-*r/99.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.45:\\ \;\;\;\;\frac{\frac{1}{x} + -1}{\frac{\tan B}{x}}\\ \mathbf{elif}\;x \leq 1800000000:\\ \;\;\;\;\frac{1}{\sin B} - \frac{x}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(-\cos B\right)}{\sin B}\\ \end{array} \]

Alternative 3: 98.5% accurate, 1.0× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(-\cos B\right)}{\sin B}\\


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

    1. Initial program 99.5%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Step-by-step derivation
      1. distribute-lft-neg-in99.5%

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

        \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x\right) \cdot \frac{1}{\tan B}} \]
      3. distribute-lft-neg-in99.5%

        \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right)} \]
      4. distribute-rgt-neg-in99.5%

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

      \[\leadsto \color{blue}{\frac{1}{\sin B} + x \cdot \left(-\frac{1}{\tan B}\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-neg-out99.5%

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

        \[\leadsto \frac{1}{\sin B} + \left(-\color{blue}{\frac{x}{\tan B}}\right) \]
      3. sub-neg99.8%

        \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
      4. clear-num99.5%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{1}{\frac{\tan B}{x}}} \]
      5. frac-sub87.5%

        \[\leadsto \color{blue}{\frac{1 \cdot \frac{\tan B}{x} - \sin B \cdot 1}{\sin B \cdot \frac{\tan B}{x}}} \]
      6. *-un-lft-identity87.5%

        \[\leadsto \frac{\color{blue}{\frac{\tan B}{x}} - \sin B \cdot 1}{\sin B \cdot \frac{\tan B}{x}} \]
      7. *-commutative87.5%

        \[\leadsto \frac{\frac{\tan B}{x} - \color{blue}{1 \cdot \sin B}}{\sin B \cdot \frac{\tan B}{x}} \]
      8. *-un-lft-identity87.5%

        \[\leadsto \frac{\frac{\tan B}{x} - \color{blue}{\sin B}}{\sin B \cdot \frac{\tan B}{x}} \]
    5. Applied egg-rr87.5%

      \[\leadsto \color{blue}{\frac{\frac{\tan B}{x} - \sin B}{\sin B \cdot \frac{\tan B}{x}}} \]
    6. Step-by-step derivation
      1. associate-/r*99.5%

        \[\leadsto \color{blue}{\frac{\frac{\frac{\tan B}{x} - \sin B}{\sin B}}{\frac{\tan B}{x}}} \]
      2. div-sub99.5%

        \[\leadsto \frac{\color{blue}{\frac{\frac{\tan B}{x}}{\sin B} - \frac{\sin B}{\sin B}}}{\frac{\tan B}{x}} \]
      3. *-inverses99.5%

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

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

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

    if -1.3999999999999999 < x < 23000

    1. Initial program 99.7%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Step-by-step derivation
      1. distribute-lft-neg-in99.7%

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

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

        \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
      4. *-commutative99.7%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{1}{\tan B} \cdot x} \]
      5. *-commutative99.7%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
      6. associate-*r/99.7%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot 1}{\tan B}} \]
      7. *-rgt-identity99.7%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot \cos B}{\sin B} + \frac{1}{\sin B}} \]
    6. Step-by-step derivation
      1. +-commutative99.7%

        \[\leadsto \color{blue}{\frac{1}{\sin B} + -1 \cdot \frac{x \cdot \cos B}{\sin B}} \]
      2. mul-1-neg99.7%

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

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

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

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

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

    if 23000 < x

    1. Initial program 99.3%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Step-by-step derivation
      1. distribute-lft-neg-in99.3%

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

        \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x\right) \cdot \frac{1}{\tan B}} \]
      3. cancel-sign-sub-inv99.3%

        \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
      4. *-commutative99.3%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{1}{\tan B} \cdot x} \]
      5. *-commutative99.3%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
      6. associate-*r/99.6%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot 1}{\tan B}} \]
      7. *-rgt-identity99.6%

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

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

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot \cos B}{\sin B}} \]
    5. Taylor expanded in x around inf 99.7%

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot \cos B}{\sin B}} \]
    6. Step-by-step derivation
      1. mul-1-neg99.7%

        \[\leadsto \color{blue}{-\frac{x \cdot \cos B}{\sin B}} \]
      2. associate-*r/99.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.4:\\ \;\;\;\;\frac{\frac{1}{x} + -1}{\frac{\tan B}{x}}\\ \mathbf{elif}\;x \leq 23000:\\ \;\;\;\;\frac{1 - x}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(-\cos B\right)}{\sin B}\\ \end{array} \]

Alternative 4: 98.4% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -500000000 \lor \neg \left(x \leq 65000000\right):\\ \;\;\;\;\frac{-x}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} \cdot \left(1 - x\right)\\ \end{array} \end{array} \]
(FPCore (B x)
 :precision binary64
 (if (or (<= x -500000000.0) (not (<= x 65000000.0)))
   (/ (- x) (tan B))
   (* (/ 1.0 (sin B)) (- 1.0 x))))
double code(double B, double x) {
	double tmp;
	if ((x <= -500000000.0) || !(x <= 65000000.0)) {
		tmp = -x / tan(B);
	} else {
		tmp = (1.0 / sin(B)) * (1.0 - x);
	}
	return tmp;
}
real(8) function code(b, x)
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    real(8) :: tmp
    if ((x <= (-500000000.0d0)) .or. (.not. (x <= 65000000.0d0))) then
        tmp = -x / tan(b)
    else
        tmp = (1.0d0 / sin(b)) * (1.0d0 - x)
    end if
    code = tmp
end function
public static double code(double B, double x) {
	double tmp;
	if ((x <= -500000000.0) || !(x <= 65000000.0)) {
		tmp = -x / Math.tan(B);
	} else {
		tmp = (1.0 / Math.sin(B)) * (1.0 - x);
	}
	return tmp;
}
def code(B, x):
	tmp = 0
	if (x <= -500000000.0) or not (x <= 65000000.0):
		tmp = -x / math.tan(B)
	else:
		tmp = (1.0 / math.sin(B)) * (1.0 - x)
	return tmp
function code(B, x)
	tmp = 0.0
	if ((x <= -500000000.0) || !(x <= 65000000.0))
		tmp = Float64(Float64(-x) / tan(B));
	else
		tmp = Float64(Float64(1.0 / sin(B)) * Float64(1.0 - x));
	end
	return tmp
end
function tmp_2 = code(B, x)
	tmp = 0.0;
	if ((x <= -500000000.0) || ~((x <= 65000000.0)))
		tmp = -x / tan(B);
	else
		tmp = (1.0 / sin(B)) * (1.0 - x);
	end
	tmp_2 = tmp;
end
code[B_, x_] := If[Or[LessEqual[x, -500000000.0], N[Not[LessEqual[x, 65000000.0]], $MachinePrecision]], N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -500000000 \lor \neg \left(x \leq 65000000\right):\\
\;\;\;\;\frac{-x}{\tan B}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5e8 or 6.5e7 < x

    1. Initial program 99.4%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Step-by-step derivation
      1. distribute-lft-neg-in99.4%

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

        \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x\right) \cdot \frac{1}{\tan B}} \]
      3. cancel-sign-sub-inv99.4%

        \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
      4. *-commutative99.4%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{1}{\tan B} \cdot x} \]
      5. *-commutative99.4%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
      6. associate-*r/99.7%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot 1}{\tan B}} \]
      7. *-rgt-identity99.7%

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

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

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot \cos B}{\sin B}} \]
    5. Taylor expanded in x around inf 99.6%

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot \cos B}{\sin B}} \]
    6. Step-by-step derivation
      1. mul-1-neg99.6%

        \[\leadsto \color{blue}{-\frac{x \cdot \cos B}{\sin B}} \]
      2. associate-*r/99.4%

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

      \[\leadsto \color{blue}{-x \cdot \frac{\cos B}{\sin B}} \]
    8. Step-by-step derivation
      1. expm1-log1p-u50.1%

        \[\leadsto -\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x \cdot \frac{\cos B}{\sin B}\right)\right)} \]
      2. expm1-udef50.1%

        \[\leadsto -\color{blue}{\left(e^{\mathsf{log1p}\left(x \cdot \frac{\cos B}{\sin B}\right)} - 1\right)} \]
      3. clear-num50.1%

        \[\leadsto -\left(e^{\mathsf{log1p}\left(x \cdot \color{blue}{\frac{1}{\frac{\sin B}{\cos B}}}\right)} - 1\right) \]
      4. tan-quot50.1%

        \[\leadsto -\left(e^{\mathsf{log1p}\left(x \cdot \frac{1}{\color{blue}{\tan B}}\right)} - 1\right) \]
    9. Applied egg-rr50.1%

      \[\leadsto -\color{blue}{\left(e^{\mathsf{log1p}\left(x \cdot \frac{1}{\tan B}\right)} - 1\right)} \]
    10. Step-by-step derivation
      1. expm1-def50.1%

        \[\leadsto -\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
      2. expm1-log1p99.4%

        \[\leadsto -\color{blue}{x \cdot \frac{1}{\tan B}} \]
      3. associate-*r/99.7%

        \[\leadsto -\color{blue}{\frac{x \cdot 1}{\tan B}} \]
      4. *-rgt-identity99.7%

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

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

    if -5e8 < x < 6.5e7

    1. Initial program 99.7%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Step-by-step derivation
      1. distribute-lft-neg-in99.7%

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

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

        \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
      4. *-commutative99.7%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{1}{\tan B} \cdot x} \]
      5. *-commutative99.7%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
      6. associate-*r/99.7%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot 1}{\tan B}} \]
      7. *-rgt-identity99.7%

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

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

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

      \[\leadsto \frac{1}{\sin B} - \frac{\color{blue}{x}}{\sin B} \]
    6. Step-by-step derivation
      1. *-un-lft-identity96.0%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sin B}} - \frac{x}{\sin B} \]
      2. div-inv96.0%

        \[\leadsto 1 \cdot \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\sin B}} \]
      3. distribute-rgt-out--96.0%

        \[\leadsto \color{blue}{\frac{1}{\sin B} \cdot \left(1 - x\right)} \]
    7. Applied egg-rr96.0%

      \[\leadsto \color{blue}{\frac{1}{\sin B} \cdot \left(1 - x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -500000000 \lor \neg \left(x \leq 65000000\right):\\ \;\;\;\;\frac{-x}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} \cdot \left(1 - x\right)\\ \end{array} \]

Alternative 5: 98.5% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.45:\\ \;\;\;\;\frac{\frac{1}{x} + -1}{\frac{\tan B}{x}}\\ \mathbf{elif}\;x \leq 7400000:\\ \;\;\;\;\frac{1 - x}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;\frac{-x}{\tan B}\\ \end{array} \end{array} \]
(FPCore (B x)
 :precision binary64
 (if (<= x -1.45)
   (/ (+ (/ 1.0 x) -1.0) (/ (tan B) x))
   (if (<= x 7400000.0) (/ (- 1.0 x) (sin B)) (/ (- x) (tan B)))))
double code(double B, double x) {
	double tmp;
	if (x <= -1.45) {
		tmp = ((1.0 / x) + -1.0) / (tan(B) / x);
	} else if (x <= 7400000.0) {
		tmp = (1.0 - x) / sin(B);
	} else {
		tmp = -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 <= (-1.45d0)) then
        tmp = ((1.0d0 / x) + (-1.0d0)) / (tan(b) / x)
    else if (x <= 7400000.0d0) then
        tmp = (1.0d0 - x) / sin(b)
    else
        tmp = -x / tan(b)
    end if
    code = tmp
end function
public static double code(double B, double x) {
	double tmp;
	if (x <= -1.45) {
		tmp = ((1.0 / x) + -1.0) / (Math.tan(B) / x);
	} else if (x <= 7400000.0) {
		tmp = (1.0 - x) / Math.sin(B);
	} else {
		tmp = -x / Math.tan(B);
	}
	return tmp;
}
def code(B, x):
	tmp = 0
	if x <= -1.45:
		tmp = ((1.0 / x) + -1.0) / (math.tan(B) / x)
	elif x <= 7400000.0:
		tmp = (1.0 - x) / math.sin(B)
	else:
		tmp = -x / math.tan(B)
	return tmp
function code(B, x)
	tmp = 0.0
	if (x <= -1.45)
		tmp = Float64(Float64(Float64(1.0 / x) + -1.0) / Float64(tan(B) / x));
	elseif (x <= 7400000.0)
		tmp = Float64(Float64(1.0 - x) / sin(B));
	else
		tmp = Float64(Float64(-x) / tan(B));
	end
	return tmp
end
function tmp_2 = code(B, x)
	tmp = 0.0;
	if (x <= -1.45)
		tmp = ((1.0 / x) + -1.0) / (tan(B) / x);
	elseif (x <= 7400000.0)
		tmp = (1.0 - x) / sin(B);
	else
		tmp = -x / tan(B);
	end
	tmp_2 = tmp;
end
code[B_, x_] := If[LessEqual[x, -1.45], N[(N[(N[(1.0 / x), $MachinePrecision] + -1.0), $MachinePrecision] / N[(N[Tan[B], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7400000.0], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 99.5%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Step-by-step derivation
      1. distribute-lft-neg-in99.5%

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

        \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x\right) \cdot \frac{1}{\tan B}} \]
      3. distribute-lft-neg-in99.5%

        \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right)} \]
      4. distribute-rgt-neg-in99.5%

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

      \[\leadsto \color{blue}{\frac{1}{\sin B} + x \cdot \left(-\frac{1}{\tan B}\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-neg-out99.5%

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

        \[\leadsto \frac{1}{\sin B} + \left(-\color{blue}{\frac{x}{\tan B}}\right) \]
      3. sub-neg99.8%

        \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
      4. clear-num99.5%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{1}{\frac{\tan B}{x}}} \]
      5. frac-sub87.5%

        \[\leadsto \color{blue}{\frac{1 \cdot \frac{\tan B}{x} - \sin B \cdot 1}{\sin B \cdot \frac{\tan B}{x}}} \]
      6. *-un-lft-identity87.5%

        \[\leadsto \frac{\color{blue}{\frac{\tan B}{x}} - \sin B \cdot 1}{\sin B \cdot \frac{\tan B}{x}} \]
      7. *-commutative87.5%

        \[\leadsto \frac{\frac{\tan B}{x} - \color{blue}{1 \cdot \sin B}}{\sin B \cdot \frac{\tan B}{x}} \]
      8. *-un-lft-identity87.5%

        \[\leadsto \frac{\frac{\tan B}{x} - \color{blue}{\sin B}}{\sin B \cdot \frac{\tan B}{x}} \]
    5. Applied egg-rr87.5%

      \[\leadsto \color{blue}{\frac{\frac{\tan B}{x} - \sin B}{\sin B \cdot \frac{\tan B}{x}}} \]
    6. Step-by-step derivation
      1. associate-/r*99.5%

        \[\leadsto \color{blue}{\frac{\frac{\frac{\tan B}{x} - \sin B}{\sin B}}{\frac{\tan B}{x}}} \]
      2. div-sub99.5%

        \[\leadsto \frac{\color{blue}{\frac{\frac{\tan B}{x}}{\sin B} - \frac{\sin B}{\sin B}}}{\frac{\tan B}{x}} \]
      3. *-inverses99.5%

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

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

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

    if -1.44999999999999996 < x < 7.4e6

    1. Initial program 99.7%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Step-by-step derivation
      1. distribute-lft-neg-in99.7%

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

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

        \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
      4. *-commutative99.7%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{1}{\tan B} \cdot x} \]
      5. *-commutative99.7%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
      6. associate-*r/99.7%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot 1}{\tan B}} \]
      7. *-rgt-identity99.7%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot \cos B}{\sin B} + \frac{1}{\sin B}} \]
    6. Step-by-step derivation
      1. +-commutative99.7%

        \[\leadsto \color{blue}{\frac{1}{\sin B} + -1 \cdot \frac{x \cdot \cos B}{\sin B}} \]
      2. mul-1-neg99.7%

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

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

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

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

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

    if 7.4e6 < x

    1. Initial program 99.3%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Step-by-step derivation
      1. distribute-lft-neg-in99.3%

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

        \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x\right) \cdot \frac{1}{\tan B}} \]
      3. cancel-sign-sub-inv99.3%

        \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
      4. *-commutative99.3%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{1}{\tan B} \cdot x} \]
      5. *-commutative99.3%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
      6. associate-*r/99.6%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot 1}{\tan B}} \]
      7. *-rgt-identity99.6%

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

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

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot \cos B}{\sin B}} \]
    5. Taylor expanded in x around inf 99.7%

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot \cos B}{\sin B}} \]
    6. Step-by-step derivation
      1. mul-1-neg99.7%

        \[\leadsto \color{blue}{-\frac{x \cdot \cos B}{\sin B}} \]
      2. associate-*r/99.3%

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

      \[\leadsto \color{blue}{-x \cdot \frac{\cos B}{\sin B}} \]
    8. Step-by-step derivation
      1. expm1-log1p-u51.2%

        \[\leadsto -\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x \cdot \frac{\cos B}{\sin B}\right)\right)} \]
      2. expm1-udef51.2%

        \[\leadsto -\color{blue}{\left(e^{\mathsf{log1p}\left(x \cdot \frac{\cos B}{\sin B}\right)} - 1\right)} \]
      3. clear-num51.2%

        \[\leadsto -\left(e^{\mathsf{log1p}\left(x \cdot \color{blue}{\frac{1}{\frac{\sin B}{\cos B}}}\right)} - 1\right) \]
      4. tan-quot51.2%

        \[\leadsto -\left(e^{\mathsf{log1p}\left(x \cdot \frac{1}{\color{blue}{\tan B}}\right)} - 1\right) \]
    9. Applied egg-rr51.2%

      \[\leadsto -\color{blue}{\left(e^{\mathsf{log1p}\left(x \cdot \frac{1}{\tan B}\right)} - 1\right)} \]
    10. Step-by-step derivation
      1. expm1-def51.2%

        \[\leadsto -\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
      2. expm1-log1p99.3%

        \[\leadsto -\color{blue}{x \cdot \frac{1}{\tan B}} \]
      3. associate-*r/99.6%

        \[\leadsto -\color{blue}{\frac{x \cdot 1}{\tan B}} \]
      4. *-rgt-identity99.6%

        \[\leadsto -\frac{\color{blue}{x}}{\tan B} \]
    11. Simplified99.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.45:\\ \;\;\;\;\frac{\frac{1}{x} + -1}{\frac{\tan B}{x}}\\ \mathbf{elif}\;x \leq 7400000:\\ \;\;\;\;\frac{1 - x}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;\frac{-x}{\tan B}\\ \end{array} \]

Alternative 6: 98.4% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -100000000 \lor \neg \left(x \leq 240000\right):\\ \;\;\;\;\frac{-x}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - x}{\sin B}\\ \end{array} \end{array} \]
(FPCore (B x)
 :precision binary64
 (if (or (<= x -100000000.0) (not (<= x 240000.0)))
   (/ (- x) (tan B))
   (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
	double tmp;
	if ((x <= -100000000.0) || !(x <= 240000.0)) {
		tmp = -x / tan(B);
	} else {
		tmp = (1.0 - x) / sin(B);
	}
	return tmp;
}
real(8) function code(b, x)
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    real(8) :: tmp
    if ((x <= (-100000000.0d0)) .or. (.not. (x <= 240000.0d0))) then
        tmp = -x / tan(b)
    else
        tmp = (1.0d0 - x) / sin(b)
    end if
    code = tmp
end function
public static double code(double B, double x) {
	double tmp;
	if ((x <= -100000000.0) || !(x <= 240000.0)) {
		tmp = -x / Math.tan(B);
	} else {
		tmp = (1.0 - x) / Math.sin(B);
	}
	return tmp;
}
def code(B, x):
	tmp = 0
	if (x <= -100000000.0) or not (x <= 240000.0):
		tmp = -x / math.tan(B)
	else:
		tmp = (1.0 - x) / math.sin(B)
	return tmp
function code(B, x)
	tmp = 0.0
	if ((x <= -100000000.0) || !(x <= 240000.0))
		tmp = Float64(Float64(-x) / tan(B));
	else
		tmp = Float64(Float64(1.0 - x) / sin(B));
	end
	return tmp
end
function tmp_2 = code(B, x)
	tmp = 0.0;
	if ((x <= -100000000.0) || ~((x <= 240000.0)))
		tmp = -x / tan(B);
	else
		tmp = (1.0 - x) / sin(B);
	end
	tmp_2 = tmp;
end
code[B_, x_] := If[Or[LessEqual[x, -100000000.0], N[Not[LessEqual[x, 240000.0]], $MachinePrecision]], N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -100000000 \lor \neg \left(x \leq 240000\right):\\
\;\;\;\;\frac{-x}{\tan B}\\

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


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

    1. Initial program 99.4%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Step-by-step derivation
      1. distribute-lft-neg-in99.4%

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

        \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x\right) \cdot \frac{1}{\tan B}} \]
      3. cancel-sign-sub-inv99.4%

        \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
      4. *-commutative99.4%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{1}{\tan B} \cdot x} \]
      5. *-commutative99.4%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
      6. associate-*r/99.7%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot 1}{\tan B}} \]
      7. *-rgt-identity99.7%

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

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

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot \cos B}{\sin B}} \]
    5. Taylor expanded in x around inf 99.6%

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot \cos B}{\sin B}} \]
    6. Step-by-step derivation
      1. mul-1-neg99.6%

        \[\leadsto \color{blue}{-\frac{x \cdot \cos B}{\sin B}} \]
      2. associate-*r/99.4%

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

      \[\leadsto \color{blue}{-x \cdot \frac{\cos B}{\sin B}} \]
    8. Step-by-step derivation
      1. expm1-log1p-u50.1%

        \[\leadsto -\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x \cdot \frac{\cos B}{\sin B}\right)\right)} \]
      2. expm1-udef50.1%

        \[\leadsto -\color{blue}{\left(e^{\mathsf{log1p}\left(x \cdot \frac{\cos B}{\sin B}\right)} - 1\right)} \]
      3. clear-num50.1%

        \[\leadsto -\left(e^{\mathsf{log1p}\left(x \cdot \color{blue}{\frac{1}{\frac{\sin B}{\cos B}}}\right)} - 1\right) \]
      4. tan-quot50.1%

        \[\leadsto -\left(e^{\mathsf{log1p}\left(x \cdot \frac{1}{\color{blue}{\tan B}}\right)} - 1\right) \]
    9. Applied egg-rr50.1%

      \[\leadsto -\color{blue}{\left(e^{\mathsf{log1p}\left(x \cdot \frac{1}{\tan B}\right)} - 1\right)} \]
    10. Step-by-step derivation
      1. expm1-def50.1%

        \[\leadsto -\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
      2. expm1-log1p99.4%

        \[\leadsto -\color{blue}{x \cdot \frac{1}{\tan B}} \]
      3. associate-*r/99.7%

        \[\leadsto -\color{blue}{\frac{x \cdot 1}{\tan B}} \]
      4. *-rgt-identity99.7%

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

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

    if -1e8 < x < 2.4e5

    1. Initial program 99.7%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Step-by-step derivation
      1. distribute-lft-neg-in99.7%

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

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

        \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
      4. *-commutative99.7%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{1}{\tan B} \cdot x} \]
      5. *-commutative99.7%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
      6. associate-*r/99.7%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot 1}{\tan B}} \]
      7. *-rgt-identity99.7%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot \cos B}{\sin B} + \frac{1}{\sin B}} \]
    6. Step-by-step derivation
      1. +-commutative99.8%

        \[\leadsto \color{blue}{\frac{1}{\sin B} + -1 \cdot \frac{x \cdot \cos B}{\sin B}} \]
      2. mul-1-neg99.8%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -100000000 \lor \neg \left(x \leq 240000\right):\\ \;\;\;\;\frac{-x}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - x}{\sin B}\\ \end{array} \]

Alternative 7: 97.6% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.5 \lor \neg \left(x \leq 1\right):\\ \;\;\;\;\frac{-x}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B}\\ \end{array} \end{array} \]
(FPCore (B x)
 :precision binary64
 (if (or (<= x -1.5) (not (<= x 1.0))) (/ (- x) (tan B)) (/ 1.0 (sin B))))
double code(double B, double x) {
	double tmp;
	if ((x <= -1.5) || !(x <= 1.0)) {
		tmp = -x / tan(B);
	} else {
		tmp = 1.0 / sin(B);
	}
	return tmp;
}
real(8) function code(b, x)
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    real(8) :: tmp
    if ((x <= (-1.5d0)) .or. (.not. (x <= 1.0d0))) then
        tmp = -x / tan(b)
    else
        tmp = 1.0d0 / sin(b)
    end if
    code = tmp
end function
public static double code(double B, double x) {
	double tmp;
	if ((x <= -1.5) || !(x <= 1.0)) {
		tmp = -x / Math.tan(B);
	} else {
		tmp = 1.0 / Math.sin(B);
	}
	return tmp;
}
def code(B, x):
	tmp = 0
	if (x <= -1.5) or not (x <= 1.0):
		tmp = -x / math.tan(B)
	else:
		tmp = 1.0 / math.sin(B)
	return tmp
function code(B, x)
	tmp = 0.0
	if ((x <= -1.5) || !(x <= 1.0))
		tmp = Float64(Float64(-x) / tan(B));
	else
		tmp = Float64(1.0 / sin(B));
	end
	return tmp
end
function tmp_2 = code(B, x)
	tmp = 0.0;
	if ((x <= -1.5) || ~((x <= 1.0)))
		tmp = -x / tan(B);
	else
		tmp = 1.0 / sin(B);
	end
	tmp_2 = tmp;
end
code[B_, x_] := If[Or[LessEqual[x, -1.5], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-x}{\tan B}\\

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


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

    1. Initial program 99.4%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Step-by-step derivation
      1. distribute-lft-neg-in99.4%

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

        \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x\right) \cdot \frac{1}{\tan B}} \]
      3. cancel-sign-sub-inv99.4%

        \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
      4. *-commutative99.4%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{1}{\tan B} \cdot x} \]
      5. *-commutative99.4%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
      6. associate-*r/99.7%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot 1}{\tan B}} \]
      7. *-rgt-identity99.7%

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

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

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot \cos B}{\sin B}} \]
    5. Taylor expanded in x around inf 96.5%

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot \cos B}{\sin B}} \]
    6. Step-by-step derivation
      1. mul-1-neg96.5%

        \[\leadsto \color{blue}{-\frac{x \cdot \cos B}{\sin B}} \]
      2. associate-*r/96.2%

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

      \[\leadsto \color{blue}{-x \cdot \frac{\cos B}{\sin B}} \]
    8. Step-by-step derivation
      1. expm1-log1p-u48.2%

        \[\leadsto -\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x \cdot \frac{\cos B}{\sin B}\right)\right)} \]
      2. expm1-udef48.2%

        \[\leadsto -\color{blue}{\left(e^{\mathsf{log1p}\left(x \cdot \frac{\cos B}{\sin B}\right)} - 1\right)} \]
      3. clear-num48.2%

        \[\leadsto -\left(e^{\mathsf{log1p}\left(x \cdot \color{blue}{\frac{1}{\frac{\sin B}{\cos B}}}\right)} - 1\right) \]
      4. tan-quot48.2%

        \[\leadsto -\left(e^{\mathsf{log1p}\left(x \cdot \frac{1}{\color{blue}{\tan B}}\right)} - 1\right) \]
    9. Applied egg-rr48.2%

      \[\leadsto -\color{blue}{\left(e^{\mathsf{log1p}\left(x \cdot \frac{1}{\tan B}\right)} - 1\right)} \]
    10. Step-by-step derivation
      1. expm1-def48.2%

        \[\leadsto -\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
      2. expm1-log1p96.2%

        \[\leadsto -\color{blue}{x \cdot \frac{1}{\tan B}} \]
      3. associate-*r/96.5%

        \[\leadsto -\color{blue}{\frac{x \cdot 1}{\tan B}} \]
      4. *-rgt-identity96.5%

        \[\leadsto -\frac{\color{blue}{x}}{\tan B} \]
    11. Simplified96.5%

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

    if -1.5 < x < 1

    1. Initial program 99.7%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Step-by-step derivation
      1. distribute-lft-neg-in99.7%

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

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

        \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right)} \]
      4. distribute-rgt-neg-in99.7%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.5 \lor \neg \left(x \leq 1\right):\\ \;\;\;\;\frac{-x}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B}\\ \end{array} \]

Alternative 8: 74.3% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;B \leq -2.65 \cdot 10^{+20} \lor \neg \left(B \leq 0.054\right):\\ \;\;\;\;\frac{1}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + \frac{1 - x}{B}\\ \end{array} \end{array} \]
(FPCore (B x)
 :precision binary64
 (if (or (<= B -2.65e+20) (not (<= B 0.054)))
   (/ 1.0 (sin B))
   (+ (* B (+ 0.16666666666666666 (* x 0.3333333333333333))) (/ (- 1.0 x) B))))
double code(double B, double x) {
	double tmp;
	if ((B <= -2.65e+20) || !(B <= 0.054)) {
		tmp = 1.0 / sin(B);
	} else {
		tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B);
	}
	return tmp;
}
real(8) function code(b, x)
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    real(8) :: tmp
    if ((b <= (-2.65d+20)) .or. (.not. (b <= 0.054d0))) then
        tmp = 1.0d0 / sin(b)
    else
        tmp = (b * (0.16666666666666666d0 + (x * 0.3333333333333333d0))) + ((1.0d0 - x) / b)
    end if
    code = tmp
end function
public static double code(double B, double x) {
	double tmp;
	if ((B <= -2.65e+20) || !(B <= 0.054)) {
		tmp = 1.0 / Math.sin(B);
	} else {
		tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B);
	}
	return tmp;
}
def code(B, x):
	tmp = 0
	if (B <= -2.65e+20) or not (B <= 0.054):
		tmp = 1.0 / math.sin(B)
	else:
		tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B)
	return tmp
function code(B, x)
	tmp = 0.0
	if ((B <= -2.65e+20) || !(B <= 0.054))
		tmp = Float64(1.0 / sin(B));
	else
		tmp = Float64(Float64(B * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333))) + Float64(Float64(1.0 - x) / B));
	end
	return tmp
end
function tmp_2 = code(B, x)
	tmp = 0.0;
	if ((B <= -2.65e+20) || ~((B <= 0.054)))
		tmp = 1.0 / sin(B);
	else
		tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B);
	end
	tmp_2 = tmp;
end
code[B_, x_] := If[Or[LessEqual[B, -2.65e+20], N[Not[LessEqual[B, 0.054]], $MachinePrecision]], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(B * N[(0.16666666666666666 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;B \leq -2.65 \cdot 10^{+20} \lor \neg \left(B \leq 0.054\right):\\
\;\;\;\;\frac{1}{\sin B}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if B < -2.65e20 or 0.0539999999999999994 < B

    1. Initial program 99.3%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Step-by-step derivation
      1. distribute-lft-neg-in99.3%

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

        \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x\right) \cdot \frac{1}{\tan B}} \]
      3. distribute-lft-neg-in99.3%

        \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right)} \]
      4. distribute-rgt-neg-in99.3%

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

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

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

    if -2.65e20 < B < 0.0539999999999999994

    1. Initial program 99.8%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Step-by-step derivation
      1. distribute-lft-neg-in99.8%

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

        \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x\right) \cdot \frac{1}{\tan B}} \]
      3. distribute-lft-neg-in99.8%

        \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right)} \]
      4. distribute-rgt-neg-in99.8%

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{B} + \left(B \cdot \left(0.16666666666666666 + 0.3333333333333333 \cdot x\right) + \frac{1}{B}\right)} \]
    5. Step-by-step derivation
      1. +-commutative96.4%

        \[\leadsto \color{blue}{\left(B \cdot \left(0.16666666666666666 + 0.3333333333333333 \cdot x\right) + \frac{1}{B}\right) + -1 \cdot \frac{x}{B}} \]
      2. mul-1-neg96.4%

        \[\leadsto \left(B \cdot \left(0.16666666666666666 + 0.3333333333333333 \cdot x\right) + \frac{1}{B}\right) + \color{blue}{\left(-\frac{x}{B}\right)} \]
      3. sub-neg96.4%

        \[\leadsto \color{blue}{\left(B \cdot \left(0.16666666666666666 + 0.3333333333333333 \cdot x\right) + \frac{1}{B}\right) - \frac{x}{B}} \]
      4. associate--l+96.4%

        \[\leadsto \color{blue}{B \cdot \left(0.16666666666666666 + 0.3333333333333333 \cdot x\right) + \left(\frac{1}{B} - \frac{x}{B}\right)} \]
      5. *-commutative96.4%

        \[\leadsto B \cdot \left(0.16666666666666666 + \color{blue}{x \cdot 0.3333333333333333}\right) + \left(\frac{1}{B} - \frac{x}{B}\right) \]
      6. div-sub96.4%

        \[\leadsto B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + \color{blue}{\frac{1 - x}{B}} \]
    6. Simplified96.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;B \leq -2.65 \cdot 10^{+20} \lor \neg \left(B \leq 0.054\right):\\ \;\;\;\;\frac{1}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + \frac{1 - x}{B}\\ \end{array} \]

Alternative 9: 51.5% accurate, 16.2× speedup?

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

\\
B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + \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. Step-by-step derivation
    1. distribute-lft-neg-in99.6%

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

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

      \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right)} \]
    4. distribute-rgt-neg-in99.6%

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

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

    \[\leadsto \color{blue}{-1 \cdot \frac{x}{B} + \left(B \cdot \left(0.16666666666666666 + 0.3333333333333333 \cdot x\right) + \frac{1}{B}\right)} \]
  5. Step-by-step derivation
    1. +-commutative48.7%

      \[\leadsto \color{blue}{\left(B \cdot \left(0.16666666666666666 + 0.3333333333333333 \cdot x\right) + \frac{1}{B}\right) + -1 \cdot \frac{x}{B}} \]
    2. mul-1-neg48.7%

      \[\leadsto \left(B \cdot \left(0.16666666666666666 + 0.3333333333333333 \cdot x\right) + \frac{1}{B}\right) + \color{blue}{\left(-\frac{x}{B}\right)} \]
    3. sub-neg48.7%

      \[\leadsto \color{blue}{\left(B \cdot \left(0.16666666666666666 + 0.3333333333333333 \cdot x\right) + \frac{1}{B}\right) - \frac{x}{B}} \]
    4. associate--l+48.7%

      \[\leadsto \color{blue}{B \cdot \left(0.16666666666666666 + 0.3333333333333333 \cdot x\right) + \left(\frac{1}{B} - \frac{x}{B}\right)} \]
    5. *-commutative48.7%

      \[\leadsto B \cdot \left(0.16666666666666666 + \color{blue}{x \cdot 0.3333333333333333}\right) + \left(\frac{1}{B} - \frac{x}{B}\right) \]
    6. div-sub48.7%

      \[\leadsto B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + \color{blue}{\frac{1 - x}{B}} \]
  6. Simplified48.7%

    \[\leadsto \color{blue}{B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + \frac{1 - x}{B}} \]
  7. Final simplification48.7%

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

Alternative 10: 50.3% accurate, 25.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5.5 \lor \neg \left(x \leq 1\right):\\ \;\;\;\;-\frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{B}\\ \end{array} \end{array} \]
(FPCore (B x)
 :precision binary64
 (if (or (<= x -5.5) (not (<= x 1.0))) (- (/ x B)) (/ 1.0 B)))
double code(double B, double x) {
	double tmp;
	if ((x <= -5.5) || !(x <= 1.0)) {
		tmp = -(x / B);
	} else {
		tmp = 1.0 / B;
	}
	return tmp;
}
real(8) function code(b, x)
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    real(8) :: tmp
    if ((x <= (-5.5d0)) .or. (.not. (x <= 1.0d0))) then
        tmp = -(x / b)
    else
        tmp = 1.0d0 / b
    end if
    code = tmp
end function
public static double code(double B, double x) {
	double tmp;
	if ((x <= -5.5) || !(x <= 1.0)) {
		tmp = -(x / B);
	} else {
		tmp = 1.0 / B;
	}
	return tmp;
}
def code(B, x):
	tmp = 0
	if (x <= -5.5) or not (x <= 1.0):
		tmp = -(x / B)
	else:
		tmp = 1.0 / B
	return tmp
function code(B, x)
	tmp = 0.0
	if ((x <= -5.5) || !(x <= 1.0))
		tmp = Float64(-Float64(x / B));
	else
		tmp = Float64(1.0 / B);
	end
	return tmp
end
function tmp_2 = code(B, x)
	tmp = 0.0;
	if ((x <= -5.5) || ~((x <= 1.0)))
		tmp = -(x / B);
	else
		tmp = 1.0 / B;
	end
	tmp_2 = tmp;
end
code[B_, x_] := If[Or[LessEqual[x, -5.5], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], (-N[(x / B), $MachinePrecision]), N[(1.0 / B), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;-\frac{x}{B}\\

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


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

    1. Initial program 99.4%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Step-by-step derivation
      1. distribute-lft-neg-in99.4%

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

        \[\leadsto \color{blue}{\frac{1}{\sin B} + \left(-x\right) \cdot \frac{1}{\tan B}} \]
      3. distribute-lft-neg-in99.4%

        \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right)} \]
      4. distribute-rgt-neg-in99.4%

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

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

      \[\leadsto \color{blue}{\frac{1 + -1 \cdot x}{B}} \]
    5. Step-by-step derivation
      1. neg-mul-147.6%

        \[\leadsto \frac{1 + \color{blue}{\left(-x\right)}}{B} \]
      2. sub-neg47.6%

        \[\leadsto \frac{\color{blue}{1 - x}}{B} \]
    6. Simplified47.6%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{B}} \]
    8. Step-by-step derivation
      1. neg-mul-146.6%

        \[\leadsto \color{blue}{-\frac{x}{B}} \]
      2. distribute-neg-frac46.6%

        \[\leadsto \color{blue}{\frac{-x}{B}} \]
    9. Simplified46.6%

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

    if -5.5 < x < 1

    1. Initial program 99.7%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
    2. Step-by-step derivation
      1. distribute-lft-neg-in99.7%

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

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

        \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right)} \]
      4. distribute-rgt-neg-in99.7%

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

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

      \[\leadsto \color{blue}{\frac{1 + -1 \cdot x}{B}} \]
    5. Step-by-step derivation
      1. neg-mul-149.2%

        \[\leadsto \frac{1 + \color{blue}{\left(-x\right)}}{B} \]
      2. sub-neg49.2%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.5 \lor \neg \left(x \leq 1\right):\\ \;\;\;\;-\frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{B}\\ \end{array} \]

Alternative 11: 51.4% accurate, 42.0× 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. Step-by-step derivation
    1. distribute-lft-neg-in99.6%

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

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

      \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right)} \]
    4. distribute-rgt-neg-in99.6%

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

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

    \[\leadsto \color{blue}{\frac{1 + -1 \cdot x}{B}} \]
  5. Step-by-step derivation
    1. neg-mul-148.4%

      \[\leadsto \frac{1 + \color{blue}{\left(-x\right)}}{B} \]
    2. sub-neg48.4%

      \[\leadsto \frac{\color{blue}{1 - x}}{B} \]
  6. Simplified48.4%

    \[\leadsto \color{blue}{\frac{1 - x}{B}} \]
  7. Final simplification48.4%

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

Alternative 12: 3.1% accurate, 70.0× speedup?

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

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

    \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
  2. Step-by-step derivation
    1. distribute-lft-neg-in99.6%

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

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

      \[\leadsto \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]
    4. *-commutative99.6%

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{1}{\tan B} \cdot x} \]
    5. *-commutative99.6%

      \[\leadsto \frac{1}{\sin B} - \color{blue}{x \cdot \frac{1}{\tan B}} \]
    6. associate-*r/99.7%

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot 1}{\tan B}} \]
    7. *-rgt-identity99.7%

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

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

    \[\leadsto \color{blue}{\left(0.16666666666666666 \cdot B + \frac{1}{B}\right)} - \frac{x}{\tan B} \]
  5. Taylor expanded in B around inf 3.2%

    \[\leadsto \color{blue}{0.16666666666666666 \cdot B} \]
  6. Step-by-step derivation
    1. *-commutative3.2%

      \[\leadsto \color{blue}{B \cdot 0.16666666666666666} \]
  7. Simplified3.2%

    \[\leadsto \color{blue}{B \cdot 0.16666666666666666} \]
  8. Final simplification3.2%

    \[\leadsto B \cdot 0.16666666666666666 \]

Alternative 13: 26.3% accurate, 70.0× 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. Step-by-step derivation
    1. distribute-lft-neg-in99.6%

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

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

      \[\leadsto \frac{1}{\sin B} + \color{blue}{\left(-x \cdot \frac{1}{\tan B}\right)} \]
    4. distribute-rgt-neg-in99.6%

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

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

    \[\leadsto \color{blue}{\frac{1 + -1 \cdot x}{B}} \]
  5. Step-by-step derivation
    1. neg-mul-148.4%

      \[\leadsto \frac{1 + \color{blue}{\left(-x\right)}}{B} \]
    2. sub-neg48.4%

      \[\leadsto \frac{\color{blue}{1 - x}}{B} \]
  6. Simplified48.4%

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

    \[\leadsto \color{blue}{\frac{1}{B}} \]
  8. Final simplification25.6%

    \[\leadsto \frac{1}{B} \]

Reproduce

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