VandenBroeck and Keller, Equation (24)

Percentage Accurate: 99.7% → 99.8%
Time: 9.2s
Alternatives: 15
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 15 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, 0.7× speedup?

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

\\
\frac{\frac{\tan B}{\sin B} - x}{\tan B}
\end{array}
Derivation
  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} \]
  3. Simplified99.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{\tan B}{\sin B} - \frac{x \cdot \sin B}{\sin B}}}{\tan B} \]
    2. sub-neg99.7%

      \[\leadsto \frac{\color{blue}{\frac{\tan B}{\sin B} + \left(-\frac{x \cdot \sin B}{\sin B}\right)}}{\tan B} \]
    3. associate-/l*99.7%

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

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

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

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

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

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

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

Alternative 2: 98.5% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 99.6%

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

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

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

        \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot 1}{\tan B}} \]
      4. *-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. Step-by-step derivation
      1. add-exp-log47.0%

        \[\leadsto \color{blue}{e^{\log \left(\frac{1}{\sin B}\right)}} - \frac{x}{\tan B} \]
      2. log-rec47.0%

        \[\leadsto e^{\color{blue}{-\log \sin B}} - \frac{x}{\tan B} \]
    5. Applied egg-rr47.0%

      \[\leadsto \color{blue}{e^{-\log \sin B}} - \frac{x}{\tan B} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt1.9%

        \[\leadsto e^{\color{blue}{\sqrt{-\log \sin B} \cdot \sqrt{-\log \sin B}}} \]
      2. sqrt-unprod1.9%

        \[\leadsto e^{\color{blue}{\sqrt{\left(-\log \sin B\right) \cdot \left(-\log \sin B\right)}}} \]
      3. sqr-neg1.9%

        \[\leadsto e^{\sqrt{\color{blue}{\log \sin B \cdot \log \sin B}}} \]
      4. sqrt-unprod0.0%

        \[\leadsto e^{\color{blue}{\sqrt{\log \sin B} \cdot \sqrt{\log \sin B}}} \]
      5. add-sqr-sqrt1.2%

        \[\leadsto e^{\color{blue}{\log \sin B}} \]
      6. add-exp-log2.9%

        \[\leadsto \color{blue}{\sin B} \]
      7. expm1-log1p-u2.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin B\right)\right)} \]
      8. expm1-udef2.6%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sin B\right)} - 1} \]
    7. Applied egg-rr98.0%

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin B\right)\right)} \]
      2. expm1-log1p2.9%

        \[\leadsto \color{blue}{\sin B} \]
    9. Simplified98.0%

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

    if -10.199999999999999 < x < 3.1e7

    1. Initial program 99.8%

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

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

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

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

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

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

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

    if 3.1e7 < x

    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} \]
    3. Simplified99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 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.7%

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

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

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

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot 1}{\tan B}} \]
    4. *-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 4: 98.5% accurate, 1.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -10.199999999999999 or 5.5e6 < 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} \]
    3. Simplified99.6%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{\tan B - x \cdot \sin B}{\sin B}}{\tan B}} \]
    6. Taylor expanded in x around inf 98.6%

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

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

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

    if -10.199999999999999 < x < 5.5e6

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

Alternative 5: 97.9% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.2 \lor \neg \left(x \leq 1.05\right):\\ \;\;\;\;\frac{-x}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B}\\ \end{array} \end{array} \]
(FPCore (B x)
 :precision binary64
 (if (or (<= x -1.2) (not (<= x 1.05))) (/ (- x) (tan B)) (/ 1.0 (sin B))))
double code(double B, double x) {
	double tmp;
	if ((x <= -1.2) || !(x <= 1.05)) {
		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.2d0)) .or. (.not. (x <= 1.05d0))) 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.2) || !(x <= 1.05)) {
		tmp = -x / Math.tan(B);
	} else {
		tmp = 1.0 / Math.sin(B);
	}
	return tmp;
}
def code(B, x):
	tmp = 0
	if (x <= -1.2) or not (x <= 1.05):
		tmp = -x / math.tan(B)
	else:
		tmp = 1.0 / math.sin(B)
	return tmp
function code(B, x)
	tmp = 0.0
	if ((x <= -1.2) || !(x <= 1.05))
		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.2) || ~((x <= 1.05)))
		tmp = -x / tan(B);
	else
		tmp = 1.0 / sin(B);
	end
	tmp_2 = tmp;
end
code[B_, x_] := If[Or[LessEqual[x, -1.2], N[Not[LessEqual[x, 1.05]], $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.2 \lor \neg \left(x \leq 1.05\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.19999999999999996 or 1.05000000000000004 < 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} \]
    3. Simplified99.6%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{\tan B - x \cdot \sin B}{\sin B}}{\tan B}} \]
    6. Taylor expanded in x around inf 97.2%

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

        \[\leadsto \frac{\color{blue}{-x}}{\tan B} \]
    8. Simplified97.2%

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

    if -1.19999999999999996 < x < 1.05000000000000004

    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} \]
    3. Simplified99.8%

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

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

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

Alternative 6: 74.9% accurate, 2.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if B < -4.2000000000000002e-4 or 1.3e14 < B

    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} \]
    3. Simplified99.5%

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

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

    if -4.2000000000000002e-4 < B < 1.3e14

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

Alternative 7: 56.1% accurate, 2.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;B \leq -1.25 \cdot 10^{+30}:\\
\;\;\;\;\sin B\\

\mathbf{elif}\;B \leq 1.4 \cdot 10^{+15}:\\
\;\;\;\;\left(\frac{1}{B} + B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right)\right) - \frac{x}{B}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if B < -1.25e30 or 1.4e15 < B

    1. Initial program 99.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
    4. Step-by-step derivation
      1. add-exp-log47.8%

        \[\leadsto \color{blue}{e^{\log \left(\frac{1}{\sin B}\right)}} - \frac{x}{\tan B} \]
      2. log-rec47.8%

        \[\leadsto e^{\color{blue}{-\log \sin B}} - \frac{x}{\tan B} \]
    5. Applied egg-rr47.8%

      \[\leadsto \color{blue}{e^{-\log \sin B}} - \frac{x}{\tan B} \]
    6. Taylor expanded in x around 0 23.0%

      \[\leadsto \color{blue}{e^{-\log \sin B}} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt23.0%

        \[\leadsto e^{\color{blue}{\sqrt{-\log \sin B} \cdot \sqrt{-\log \sin B}}} \]
      2. sqrt-unprod23.0%

        \[\leadsto e^{\color{blue}{\sqrt{\left(-\log \sin B\right) \cdot \left(-\log \sin B\right)}}} \]
      3. sqr-neg23.0%

        \[\leadsto e^{\sqrt{\color{blue}{\log \sin B \cdot \log \sin B}}} \]
      4. sqrt-unprod0.0%

        \[\leadsto e^{\color{blue}{\sqrt{\log \sin B} \cdot \sqrt{\log \sin B}}} \]
      5. add-sqr-sqrt5.3%

        \[\leadsto e^{\color{blue}{\log \sin B}} \]
      6. add-exp-log11.4%

        \[\leadsto \color{blue}{\sin B} \]
      7. expm1-log1p-u11.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin B\right)\right)} \]
      8. expm1-udef11.4%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sin B\right)} - 1} \]
    8. Applied egg-rr11.4%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sin B\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def11.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin B\right)\right)} \]
      2. expm1-log1p11.4%

        \[\leadsto \color{blue}{\sin B} \]
    10. Simplified11.4%

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

    if -1.25e30 < B < 1.4e15

    1. Initial program 99.9%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;B \leq -1.25 \cdot 10^{+30}:\\ \;\;\;\;\sin B\\ \mathbf{elif}\;B \leq 1.4 \cdot 10^{+15}:\\ \;\;\;\;\left(\frac{1}{B} + B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right)\right) - \frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;\sin B\\ \end{array} \]

Alternative 8: 52.1% accurate, 14.0× speedup?

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

\\
\left(\frac{1}{B} + B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right)\right) - \frac{x}{B}
\end{array}
Derivation
  1. Initial program 99.7%

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

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

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

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot 1}{\tan B}} \]
    4. *-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 48.1%

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

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

Alternative 9: 52.2% 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.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} \]
  3. Simplified99.7%

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 52.3% accurate, 19.1× speedup?

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

\\
\frac{1 - x}{B} + 0.3333333333333333 \cdot \left(B \cdot x\right)
\end{array}
Derivation
  1. Initial program 99.7%

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

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

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

      \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{x \cdot 1}{\tan B}} \]
    4. *-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. Step-by-step derivation
    1. add-exp-log48.4%

      \[\leadsto \color{blue}{e^{\log \left(\frac{1}{\sin B}\right)}} - \frac{x}{\tan B} \]
    2. log-rec48.4%

      \[\leadsto e^{\color{blue}{-\log \sin B}} - \frac{x}{\tan B} \]
  5. Applied egg-rr48.4%

    \[\leadsto \color{blue}{e^{-\log \sin B}} - \frac{x}{\tan B} \]
  6. Taylor expanded in B around 0 22.9%

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

      \[\leadsto \color{blue}{\left(-\frac{x}{B}\right)} + \left(0.3333333333333333 \cdot \left(B \cdot x\right) + e^{-\log B}\right) \]
    2. +-commutative22.9%

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

      \[\leadsto \color{blue}{\left(\left(-\frac{x}{B}\right) + e^{-\log B}\right) + 0.3333333333333333 \cdot \left(B \cdot x\right)} \]
    4. +-commutative22.9%

      \[\leadsto \color{blue}{\left(e^{-\log B} + \left(-\frac{x}{B}\right)\right)} + 0.3333333333333333 \cdot \left(B \cdot x\right) \]
    5. unsub-neg22.9%

      \[\leadsto \color{blue}{\left(e^{-\log B} - \frac{x}{B}\right)} + 0.3333333333333333 \cdot \left(B \cdot x\right) \]
    6. exp-neg22.9%

      \[\leadsto \left(\color{blue}{\frac{1}{e^{\log B}}} - \frac{x}{B}\right) + 0.3333333333333333 \cdot \left(B \cdot x\right) \]
    7. rem-exp-log47.9%

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

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

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

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

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

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

Alternative 11: 52.1% accurate, 19.1× speedup?

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

\\
B \cdot 0.16666666666666666 + \left(\frac{1}{B} - \frac{x}{B}\right)
\end{array}
Derivation
  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} \]
  3. Simplified99.7%

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

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

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

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

Alternative 12: 50.8% accurate, 25.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.3 \lor \neg \left(x \leq 1.4 \cdot 10^{-13}\right):\\
\;\;\;\;-\frac{x}{B}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -0.299999999999999989 or 1.4000000000000001e-13 < 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} \]
    3. Simplified99.6%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-x}{B}} \]
    9. Simplified44.2%

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

    if -0.299999999999999989 < x < 1.4000000000000001e-13

    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} \]
    3. Simplified99.8%

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

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

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

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

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

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

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

Alternative 13: 51.9% accurate, 30.0× speedup?

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

\\
\frac{1}{B} - \frac{x}{B}
\end{array}
Derivation
  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} \]
  3. Simplified99.7%

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

    \[\leadsto \color{blue}{\frac{1 + -1 \cdot x}{B}} \]
  5. Step-by-step derivation
    1. mul-1-neg47.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. Step-by-step derivation
    1. div-sub47.6%

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

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

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

Alternative 14: 51.9% 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.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} \]
  3. Simplified99.7%

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

    \[\leadsto \color{blue}{\frac{1 + -1 \cdot x}{B}} \]
  5. Step-by-step derivation
    1. mul-1-neg47.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. Final simplification47.6%

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

Alternative 15: 26.0% 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.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} \]
  3. Simplified99.7%

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

    \[\leadsto \color{blue}{\frac{1 + -1 \cdot x}{B}} \]
  5. Step-by-step derivation
    1. mul-1-neg47.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 0 24.2%

    \[\leadsto \color{blue}{\frac{1}{B}} \]
  8. Final simplification24.2%

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

Reproduce

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