VandenBroeck and Keller, Equation (24)

Percentage Accurate: 99.7% → 99.7%
Time: 9.5s
Alternatives: 11
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 11 alternatives:

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

Initial Program: 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, 1.0× speedup?

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

\\
\frac{\frac{1}{\cos B} - 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. Taylor expanded in x around 0 99.7%

    \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot \cos B}{\sin B}} \]
  5. Step-by-step derivation
    1. associate-/l*99.6%

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\frac{\sin B}{\cos B}}} \]
    2. un-div-inv99.6%

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{\cos B}} - \sin B \cdot \frac{x}{\sin B}}{\sin B \cdot \frac{1}{\cos B}} \]
    6. un-div-inv99.6%

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

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

    \[\leadsto \color{blue}{\frac{\frac{1}{\cos B} - \sin B \cdot \frac{x}{\sin B}}{\tan B}} \]
  7. Step-by-step derivation
    1. div-sub99.7%

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

      \[\leadsto \frac{\frac{1}{\cos B}}{\tan B} - \frac{\sin B \cdot \frac{x}{\sin B}}{\color{blue}{\tan B \cdot 1}} \]
    3. times-frac99.6%

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

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

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

      \[\leadsto \frac{\frac{1}{\cos B}}{\tan B} - \frac{\sin B \cdot x}{\color{blue}{\sin B \cdot \tan B}} \]
    7. times-frac99.7%

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{1}{\cos B}}{\tan B} - \frac{x}{\tan B}} \]
  9. Step-by-step derivation
    1. sub-neg99.7%

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

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

      \[\leadsto \color{blue}{\frac{1 \cdot 1}{\cos B \cdot \tan B}} + \left(-\frac{x}{\tan B}\right) \]
    4. metadata-eval99.7%

      \[\leadsto \frac{\color{blue}{1}}{\cos B \cdot \tan B} + \left(-\frac{x}{\tan B}\right) \]
  10. Applied egg-rr99.7%

    \[\leadsto \color{blue}{\frac{1}{\cos B \cdot \tan B} + \left(-\frac{x}{\tan B}\right)} \]
  11. Step-by-step derivation
    1. unsub-neg99.7%

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\cos B}}{\tan B}} - \frac{x}{\tan B} \]
    3. div-sub99.7%

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

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

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

Alternative 2: 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 3: 98.6% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -420000 \lor \neg \left(x \leq 4 \cdot 10^{-10}\right):\\ \;\;\;\;\frac{1 - x}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - x}{\sin B}\\ \end{array} \end{array} \]
(FPCore (B x)
 :precision binary64
 (if (or (<= x -420000.0) (not (<= x 4e-10)))
   (/ (- 1.0 x) (tan B))
   (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
	double tmp;
	if ((x <= -420000.0) || !(x <= 4e-10)) {
		tmp = (1.0 - 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 <= (-420000.0d0)) .or. (.not. (x <= 4d-10))) then
        tmp = (1.0d0 - 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 <= -420000.0) || !(x <= 4e-10)) {
		tmp = (1.0 - x) / Math.tan(B);
	} else {
		tmp = (1.0 - x) / Math.sin(B);
	}
	return tmp;
}
def code(B, x):
	tmp = 0
	if (x <= -420000.0) or not (x <= 4e-10):
		tmp = (1.0 - x) / math.tan(B)
	else:
		tmp = (1.0 - x) / math.sin(B)
	return tmp
function code(B, x)
	tmp = 0.0
	if ((x <= -420000.0) || !(x <= 4e-10))
		tmp = Float64(Float64(1.0 - 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 <= -420000.0) || ~((x <= 4e-10)))
		tmp = (1.0 - x) / tan(B);
	else
		tmp = (1.0 - x) / sin(B);
	end
	tmp_2 = tmp;
end
code[B_, x_] := If[Or[LessEqual[x, -420000.0], N[Not[LessEqual[x, 4e-10]], $MachinePrecision]], N[(N[(1.0 - x), $MachinePrecision] / 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 -420000 \lor \neg \left(x \leq 4 \cdot 10^{-10}\right):\\
\;\;\;\;\frac{1 - x}{\tan B}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4.2e5 or 4.00000000000000015e-10 < x

    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 x around 0 99.7%

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot \cos B}{\sin B}} \]
    5. Step-by-step derivation
      1. associate-/l*99.6%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\frac{\sin B}{\cos B}}} \]
      2. un-div-inv99.5%

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

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

        \[\leadsto \color{blue}{\frac{1 \cdot \frac{1}{\cos B} - \sin B \cdot \frac{x}{\sin B}}{\sin B \cdot \frac{1}{\cos B}}} \]
      5. *-un-lft-identity99.4%

        \[\leadsto \frac{\color{blue}{\frac{1}{\cos B}} - \sin B \cdot \frac{x}{\sin B}}{\sin B \cdot \frac{1}{\cos B}} \]
      6. un-div-inv99.5%

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\cos B} - \sin B \cdot \frac{x}{\sin B}}{\tan B}} \]
    7. Step-by-step derivation
      1. div-sub99.7%

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

        \[\leadsto \frac{\frac{1}{\cos B}}{\tan B} - \frac{\sin B \cdot \frac{x}{\sin B}}{\color{blue}{\tan B \cdot 1}} \]
      3. times-frac99.6%

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

        \[\leadsto \frac{\frac{1}{\cos B}}{\tan B} - \frac{\sin B}{\tan B} \cdot \color{blue}{\frac{x}{\sin B}} \]
      5. times-frac94.2%

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

        \[\leadsto \frac{\frac{1}{\cos B}}{\tan B} - \frac{\sin B \cdot x}{\color{blue}{\sin B \cdot \tan B}} \]
      7. times-frac99.7%

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\cos B}}{\tan B} - \frac{x}{\tan B}} \]
    9. Step-by-step derivation
      1. sub-neg99.7%

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

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

        \[\leadsto \color{blue}{\frac{1 \cdot 1}{\cos B \cdot \tan B}} + \left(-\frac{x}{\tan B}\right) \]
      4. metadata-eval99.7%

        \[\leadsto \frac{\color{blue}{1}}{\cos B \cdot \tan B} + \left(-\frac{x}{\tan B}\right) \]
    10. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{1}{\cos B \cdot \tan B} + \left(-\frac{x}{\tan B}\right)} \]
    11. Step-by-step derivation
      1. unsub-neg99.7%

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

        \[\leadsto \color{blue}{\frac{\frac{1}{\cos B}}{\tan B}} - \frac{x}{\tan B} \]
      3. div-sub99.7%

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\cos B} - x}{\tan B}} \]
    13. Taylor expanded in B around 0 99.2%

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

    if -4.2e5 < x < 4.00000000000000015e-10

    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.7%

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

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

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

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

Alternative 4: 98.6% accurate, 1.9× speedup?

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

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

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

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


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

    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. cancel-sign-sub-inv99.5%

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

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

        \[\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 B around 0 99.3%

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

    if -4.2e5 < x < 4.00000000000000015e-10

    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.7%

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

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

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

    if 4.00000000000000015e-10 < x

    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. Step-by-step derivation
      1. associate-/l*99.7%

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x}{\frac{\sin B}{\cos B}}} \]
      2. un-div-inv99.6%

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{1}{\cos B}} - \sin B \cdot \frac{x}{\sin B}}{\sin B \cdot \frac{1}{\cos B}} \]
      6. un-div-inv99.5%

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\cos B} - \sin B \cdot \frac{x}{\sin B}}{\tan B}} \]
    7. Step-by-step derivation
      1. div-sub99.7%

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

        \[\leadsto \frac{\frac{1}{\cos B}}{\tan B} - \frac{\sin B \cdot \frac{x}{\sin B}}{\color{blue}{\tan B \cdot 1}} \]
      3. times-frac99.7%

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

        \[\leadsto \frac{\frac{1}{\cos B}}{\tan B} - \frac{\sin B}{\tan B} \cdot \color{blue}{\frac{x}{\sin B}} \]
      5. times-frac94.9%

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

        \[\leadsto \frac{\frac{1}{\cos B}}{\tan B} - \frac{\sin B \cdot x}{\color{blue}{\sin B \cdot \tan B}} \]
      7. times-frac99.7%

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\cos B}}{\tan B} - \frac{x}{\tan B}} \]
    9. Step-by-step derivation
      1. sub-neg99.7%

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

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

        \[\leadsto \color{blue}{\frac{1 \cdot 1}{\cos B \cdot \tan B}} + \left(-\frac{x}{\tan B}\right) \]
      4. metadata-eval99.7%

        \[\leadsto \frac{\color{blue}{1}}{\cos B \cdot \tan B} + \left(-\frac{x}{\tan B}\right) \]
    10. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{1}{\cos B \cdot \tan B} + \left(-\frac{x}{\tan B}\right)} \]
    11. Step-by-step derivation
      1. unsub-neg99.7%

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

        \[\leadsto \color{blue}{\frac{\frac{1}{\cos B}}{\tan B}} - \frac{x}{\tan B} \]
      3. div-sub99.7%

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\cos B} - x}{\tan B}} \]
    13. Taylor expanded in B around 0 99.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -420000:\\ \;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-10}:\\ \;\;\;\;\frac{1 - x}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - x}{\tan B}\\ \end{array} \]

Alternative 5: 74.7% accurate, 2.0× speedup?

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

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

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


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

    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 x around 0 41.2%

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

    if -0.0210000000000000013 < B < 0.13

    1. Initial program 99.9%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{B} + \left(0.3333333333333333 \cdot \left(B \cdot x\right) + \frac{1}{B}\right)} \]
    6. Step-by-step derivation
      1. neg-mul-199.9%

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

        \[\leadsto \left(-\frac{x}{B}\right) + \color{blue}{\left(\frac{1}{B} + 0.3333333333333333 \cdot \left(B \cdot x\right)\right)} \]
      3. associate-+r+99.9%

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

        \[\leadsto \color{blue}{\left(\frac{1}{B} + \left(-\frac{x}{B}\right)\right)} + 0.3333333333333333 \cdot \left(B \cdot x\right) \]
      5. sub-neg99.9%

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

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

        \[\leadsto \frac{1 - x}{B} + \color{blue}{\left(B \cdot x\right) \cdot 0.3333333333333333} \]
      8. *-commutative99.9%

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

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

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

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

Alternative 6: 76.8% accurate, 2.0× speedup?

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

\\
\frac{1 - x}{\sin 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. 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.7%

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

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

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

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

Alternative 7: 51.5% accurate, 19.1× speedup?

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

\\
\frac{1 - x}{B} + x \cdot \left(B \cdot 0.3333333333333333\right)
\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 81.9%

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

    \[\leadsto \color{blue}{-1 \cdot \frac{x}{B} + \left(0.3333333333333333 \cdot \left(B \cdot x\right) + \frac{1}{B}\right)} \]
  6. Step-by-step derivation
    1. neg-mul-155.4%

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

      \[\leadsto \left(-\frac{x}{B}\right) + \color{blue}{\left(\frac{1}{B} + 0.3333333333333333 \cdot \left(B \cdot x\right)\right)} \]
    3. associate-+r+55.4%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1 - x}{B} + x \cdot \left(B \cdot 0.3333333333333333\right)} \]
  8. Final simplification55.4%

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

Alternative 8: 51.3% accurate, 23.3× speedup?

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

\\
\frac{1 - x}{B} + 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. 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 55.2%

    \[\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. +-commutative55.2%

      \[\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-neg55.2%

      \[\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-neg55.2%

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

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

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

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

    \[\leadsto \color{blue}{B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + \frac{1 - x}{B}} \]
  7. Taylor expanded in x around 0 55.3%

    \[\leadsto \color{blue}{0.16666666666666666 \cdot B} + \frac{1 - x}{B} \]
  8. Step-by-step derivation
    1. *-commutative55.3%

      \[\leadsto \color{blue}{B \cdot 0.16666666666666666} + \frac{1 - x}{B} \]
  9. Simplified55.3%

    \[\leadsto \color{blue}{B \cdot 0.16666666666666666} + \frac{1 - x}{B} \]
  10. Final simplification55.3%

    \[\leadsto \frac{1 - x}{B} + B \cdot 0.16666666666666666 \]

Alternative 9: 49.7% accurate, 25.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1.1 \cdot 10^{+15}\right):\\ \;\;\;\;\frac{-x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{B}\\ \end{array} \end{array} \]
(FPCore (B x)
 :precision binary64
 (if (or (<= x -1.0) (not (<= x 1.1e+15))) (/ (- x) B) (/ 1.0 B)))
double code(double B, double x) {
	double tmp;
	if ((x <= -1.0) || !(x <= 1.1e+15)) {
		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 <= (-1.0d0)) .or. (.not. (x <= 1.1d+15))) 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 <= -1.0) || !(x <= 1.1e+15)) {
		tmp = -x / B;
	} else {
		tmp = 1.0 / B;
	}
	return tmp;
}
def code(B, x):
	tmp = 0
	if (x <= -1.0) or not (x <= 1.1e+15):
		tmp = -x / B
	else:
		tmp = 1.0 / B
	return tmp
function code(B, x)
	tmp = 0.0
	if ((x <= -1.0) || !(x <= 1.1e+15))
		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 <= -1.0) || ~((x <= 1.1e+15)))
		tmp = -x / B;
	else
		tmp = 1.0 / B;
	end
	tmp_2 = tmp;
end
code[B_, x_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.1e+15]], $MachinePrecision]], N[((-x) / B), $MachinePrecision], N[(1.0 / B), $MachinePrecision]]
\begin{array}{l}

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

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


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

    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 51.8%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-x}{B}} \]
    9. Simplified51.4%

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

    if -1 < x < 1.1e15

    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 59.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1.1 \cdot 10^{+15}\right):\\ \;\;\;\;\frac{-x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{B}\\ \end{array} \]

Alternative 10: 51.1% 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 55.2%

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

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

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

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

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

Alternative 11: 26.2% 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 55.2%

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

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

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

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

    \[\leadsto \color{blue}{\frac{1}{B}} \]
  8. Final simplification27.7%

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

Reproduce

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