VandenBroeck and Keller, Equation (23)

?

Percentage Accurate: 63.8% → 84.1%
Time: 30.2s
Precision: binary64
Cost: 79240

?

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

\mathbf{elif}\;F \leq -1.1 \cdot 10^{-296}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{F \cdot -0.25}{\sin B \cdot \sqrt{0.5}} - \frac{\cos B}{\sin B}, \mathsf{fma}\left(0.5, t_1 \cdot \frac{0.5 - {\left(\frac{-0.25}{\sqrt{0.5}}\right)}^{2}}{\frac{\sqrt{0.5}}{x \cdot x}}, \frac{F \cdot \sqrt{0.5}}{\sin B}\right)\right)\\

\mathbf{elif}\;F \leq 1850000:\\
\;\;\;\;\frac{\sqrt{0.5}}{\frac{1}{t_1}} - t_0\\

\mathbf{else}:\\
\;\;\;\;F \cdot \left(\frac{\frac{1}{\sin B}}{F} + \frac{-1 - x}{\sin B \cdot {F}^{3}}\right) - t_0\\


\end{array}

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.

Herbie found 21 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

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.

Bogosity?

Bogosity

Derivation?

  1. Split input into 4 regimes
  2. if F < -1.9000000000000001e-4

    1. Initial program 58.9%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Taylor expanded in F around -inf 96.2%

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

    if -1.9000000000000001e-4 < F < -1.10000000000000006e-296

    1. Initial program 65.2%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Simplified65.3%

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

      [Start]65.2%

      \[ \left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]

      +-commutative [=>]65.2%

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

      unsub-neg [=>]65.2%

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

      associate-*l/ [=>]65.2%

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

      associate-*r/ [<=]65.2%

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

      *-commutative [<=]65.2%

      \[ \color{blue}{\frac{{\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}}{\sin B} \cdot F} - x \cdot \frac{1}{\tan B} \]
    3. Taylor expanded in F around 0 65.1%

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

      \[\leadsto \color{blue}{x \cdot \left(-0.25 \cdot \frac{F}{\sin B \cdot \sqrt{0.5}} - \frac{\cos B}{\sin B}\right) + \left(0.5 \cdot \frac{F \cdot \left(\left(0.5 - {\left(\frac{-0.25}{\sqrt{0.5}}\right)}^{2}\right) \cdot {x}^{2}\right)}{\sqrt{0.5} \cdot \sin B} + \frac{\sqrt{0.5} \cdot F}{\sin B}\right)} \]
    5. Simplified75.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{-0.25 \cdot F}{\sin B \cdot \sqrt{0.5}} - \frac{\cos B}{\sin B}, \mathsf{fma}\left(0.5, \frac{F}{\sin B} \cdot \frac{0.5 - {\left(\frac{-0.25}{\sqrt{0.5}}\right)}^{2}}{\frac{\sqrt{0.5}}{x \cdot x}}, \frac{F \cdot \sqrt{0.5}}{\sin B}\right)\right)} \]
      Step-by-step derivation

      [Start]67.6%

      \[ x \cdot \left(-0.25 \cdot \frac{F}{\sin B \cdot \sqrt{0.5}} - \frac{\cos B}{\sin B}\right) + \left(0.5 \cdot \frac{F \cdot \left(\left(0.5 - {\left(\frac{-0.25}{\sqrt{0.5}}\right)}^{2}\right) \cdot {x}^{2}\right)}{\sqrt{0.5} \cdot \sin B} + \frac{\sqrt{0.5} \cdot F}{\sin B}\right) \]

      fma-def [=>]75.8%

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

      associate-*r/ [=>]75.8%

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

      fma-def [=>]75.8%

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

    if -1.10000000000000006e-296 < F < 1.85e6

    1. Initial program 75.6%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Simplified75.6%

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

      [Start]75.6%

      \[ \left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]

      +-commutative [=>]75.6%

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

      unsub-neg [=>]75.6%

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

      associate-*l/ [=>]75.6%

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

      associate-*r/ [<=]75.6%

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

      *-commutative [<=]75.6%

      \[ \color{blue}{\frac{{\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}}{\sin B} \cdot F} - x \cdot \frac{1}{\tan B} \]
    3. Taylor expanded in F around 0 75.6%

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

      \[\leadsto \color{blue}{\frac{\sqrt{0.5} \cdot F}{\sin B}} - \frac{x}{\tan B} \]
    5. Simplified79.1%

      \[\leadsto \color{blue}{\frac{\sqrt{0.5}}{\frac{\sin B}{F}}} - \frac{x}{\tan B} \]
      Step-by-step derivation

      [Start]79.2%

      \[ \frac{\sqrt{0.5} \cdot F}{\sin B} - \frac{x}{\tan B} \]

      associate-/l* [=>]79.1%

      \[ \color{blue}{\frac{\sqrt{0.5}}{\frac{\sin B}{F}}} - \frac{x}{\tan B} \]
    6. Applied egg-rr79.2%

      \[\leadsto \frac{\sqrt{0.5}}{\color{blue}{{\left(\frac{F}{\sin B}\right)}^{-1}}} - \frac{x}{\tan B} \]
      Step-by-step derivation

      [Start]79.1%

      \[ \frac{\sqrt{0.5}}{\frac{\sin B}{F}} - \frac{x}{\tan B} \]

      clear-num [=>]79.2%

      \[ \frac{\sqrt{0.5}}{\color{blue}{\frac{1}{\frac{F}{\sin B}}}} - \frac{x}{\tan B} \]

      inv-pow [=>]79.2%

      \[ \frac{\sqrt{0.5}}{\color{blue}{{\left(\frac{F}{\sin B}\right)}^{-1}}} - \frac{x}{\tan B} \]
    7. Simplified79.2%

      \[\leadsto \frac{\sqrt{0.5}}{\color{blue}{\frac{1}{\frac{F}{\sin B}}}} - \frac{x}{\tan B} \]
      Step-by-step derivation

      [Start]79.2%

      \[ \frac{\sqrt{0.5}}{{\left(\frac{F}{\sin B}\right)}^{-1}} - \frac{x}{\tan B} \]

      unpow-1 [=>]79.2%

      \[ \frac{\sqrt{0.5}}{\color{blue}{\frac{1}{\frac{F}{\sin B}}}} - \frac{x}{\tan B} \]

    if 1.85e6 < F

    1. Initial program 54.8%

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]
    2. Simplified69.2%

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

      [Start]54.8%

      \[ \left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)} \]

      +-commutative [=>]54.8%

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

      unsub-neg [=>]54.8%

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

      associate-*l/ [=>]69.2%

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

      associate-*r/ [<=]69.1%

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

      *-commutative [<=]69.1%

      \[ \color{blue}{\frac{{\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}}{\sin B} \cdot F} - x \cdot \frac{1}{\tan B} \]
    3. Taylor expanded in F around inf 92.3%

      \[\leadsto F \cdot \color{blue}{\left(-0.5 \cdot \frac{2 + 2 \cdot x}{\sin B \cdot {F}^{3}} + \frac{1}{\sin B \cdot F}\right)} - \frac{x}{\tan B} \]
    4. Simplified94.0%

      \[\leadsto F \cdot \color{blue}{\left(\frac{\frac{1}{\sin B}}{F} + \frac{-1 + \left(-x\right)}{{F}^{3} \cdot \sin B}\right)} - \frac{x}{\tan B} \]
      Step-by-step derivation

      [Start]92.3%

      \[ F \cdot \left(-0.5 \cdot \frac{2 + 2 \cdot x}{\sin B \cdot {F}^{3}} + \frac{1}{\sin B \cdot F}\right) - \frac{x}{\tan B} \]

      +-commutative [=>]92.3%

      \[ F \cdot \color{blue}{\left(\frac{1}{\sin B \cdot F} + -0.5 \cdot \frac{2 + 2 \cdot x}{\sin B \cdot {F}^{3}}\right)} - \frac{x}{\tan B} \]

      associate-/r* [=>]92.6%

      \[ F \cdot \left(\color{blue}{\frac{\frac{1}{\sin B}}{F}} + -0.5 \cdot \frac{2 + 2 \cdot x}{\sin B \cdot {F}^{3}}\right) - \frac{x}{\tan B} \]

      associate-*r/ [=>]92.6%

      \[ F \cdot \left(\frac{\frac{1}{\sin B}}{F} + \color{blue}{\frac{-0.5 \cdot \left(2 + 2 \cdot x\right)}{\sin B \cdot {F}^{3}}}\right) - \frac{x}{\tan B} \]

      distribute-lft-in [=>]92.6%

      \[ F \cdot \left(\frac{\frac{1}{\sin B}}{F} + \frac{\color{blue}{-0.5 \cdot 2 + -0.5 \cdot \left(2 \cdot x\right)}}{\sin B \cdot {F}^{3}}\right) - \frac{x}{\tan B} \]

      metadata-eval [=>]92.6%

      \[ F \cdot \left(\frac{\frac{1}{\sin B}}{F} + \frac{\color{blue}{-1} + -0.5 \cdot \left(2 \cdot x\right)}{\sin B \cdot {F}^{3}}\right) - \frac{x}{\tan B} \]

      associate-*r* [=>]94.0%

      \[ F \cdot \left(\frac{\frac{1}{\sin B}}{F} + \frac{-1 + \color{blue}{\left(-0.5 \cdot 2\right) \cdot x}}{\sin B \cdot {F}^{3}}\right) - \frac{x}{\tan B} \]

      metadata-eval [=>]94.0%

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

      neg-mul-1 [<=]94.0%

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

      *-commutative [=>]94.0%

      \[ F \cdot \left(\frac{\frac{1}{\sin B}}{F} + \frac{-1 + \left(-x\right)}{\color{blue}{{F}^{3} \cdot \sin B}}\right) - \frac{x}{\tan B} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification86.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \leq -0.00019:\\ \;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{-1}{\sin B}\\ \mathbf{elif}\;F \leq -1.1 \cdot 10^{-296}:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{F \cdot -0.25}{\sin B \cdot \sqrt{0.5}} - \frac{\cos B}{\sin B}, \mathsf{fma}\left(0.5, \frac{F}{\sin B} \cdot \frac{0.5 - {\left(\frac{-0.25}{\sqrt{0.5}}\right)}^{2}}{\frac{\sqrt{0.5}}{x \cdot x}}, \frac{F \cdot \sqrt{0.5}}{\sin B}\right)\right)\\ \mathbf{elif}\;F \leq 1850000:\\ \;\;\;\;\frac{\sqrt{0.5}}{\frac{1}{\frac{F}{\sin B}}} - \frac{x}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;F \cdot \left(\frac{\frac{1}{\sin B}}{F} + \frac{-1 - x}{\sin B \cdot {F}^{3}}\right) - \frac{x}{\tan B}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy84.1%
Cost79240
\[\begin{array}{l} t_0 := \frac{x}{\tan B}\\ t_1 := \frac{F}{\sin B}\\ \mathbf{if}\;F \leq -0.00019:\\ \;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{-1}{\sin B}\\ \mathbf{elif}\;F \leq -1.1 \cdot 10^{-296}:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{F \cdot -0.25}{\sin B \cdot \sqrt{0.5}} - \frac{\cos B}{\sin B}, \mathsf{fma}\left(0.5, t_1 \cdot \frac{0.5 - {\left(\frac{-0.25}{\sqrt{0.5}}\right)}^{2}}{\frac{\sqrt{0.5}}{x \cdot x}}, \frac{F \cdot \sqrt{0.5}}{\sin B}\right)\right)\\ \mathbf{elif}\;F \leq 1850000:\\ \;\;\;\;\frac{\sqrt{0.5}}{\frac{1}{t_1}} - t_0\\ \mathbf{else}:\\ \;\;\;\;F \cdot \left(\frac{\frac{1}{\sin B}}{F} + \frac{-1 - x}{\sin B \cdot {F}^{3}}\right) - t_0\\ \end{array} \]
Alternative 2
Accuracy85.5%
Cost27144
\[\begin{array}{l} t_0 := \frac{x}{\tan B}\\ \mathbf{if}\;F \leq -122000:\\ \;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{-1}{\sin B}\\ \mathbf{elif}\;F \leq 1850000:\\ \;\;\;\;\frac{\sqrt{0.5}}{\frac{1}{\frac{F}{\sin B}}} - t_0\\ \mathbf{else}:\\ \;\;\;\;F \cdot \left(\frac{\frac{1}{\sin B}}{F} + \frac{-1 - x}{\sin B \cdot {F}^{3}}\right) - t_0\\ \end{array} \]
Alternative 3
Accuracy85.5%
Cost20168
\[\begin{array}{l} t_0 := x \cdot \frac{-1}{\tan B}\\ \mathbf{if}\;F \leq -122000:\\ \;\;\;\;t_0 + \frac{-1}{\sin B}\\ \mathbf{elif}\;F \leq 1.26 \cdot 10^{-8}:\\ \;\;\;\;\frac{\sqrt{0.5}}{\frac{1}{\frac{F}{\sin B}}} - \frac{x}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;t_0 + \frac{1}{\sin B}\\ \end{array} \]
Alternative 4
Accuracy85.5%
Cost20040
\[\begin{array}{l} t_0 := x \cdot \frac{-1}{\tan B}\\ \mathbf{if}\;F \leq -122000:\\ \;\;\;\;t_0 + \frac{-1}{\sin B}\\ \mathbf{elif}\;F \leq 1.26 \cdot 10^{-8}:\\ \;\;\;\;F \cdot \frac{\sqrt{0.5}}{\sin B} - \frac{x}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;t_0 + \frac{1}{\sin B}\\ \end{array} \]
Alternative 5
Accuracy85.5%
Cost20040
\[\begin{array}{l} t_0 := x \cdot \frac{-1}{\tan B}\\ \mathbf{if}\;F \leq -122000:\\ \;\;\;\;t_0 + \frac{-1}{\sin B}\\ \mathbf{elif}\;F \leq 1.26 \cdot 10^{-8}:\\ \;\;\;\;\frac{\sqrt{0.5}}{\frac{\sin B}{F}} - \frac{x}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;t_0 + \frac{1}{\sin B}\\ \end{array} \]
Alternative 6
Accuracy78.2%
Cost14284
\[\begin{array}{l} t_0 := \frac{\sqrt{0.5}}{\frac{\sin B}{F}}\\ t_1 := x \cdot \frac{-1}{\tan B}\\ \mathbf{if}\;F \leq -0.22:\\ \;\;\;\;t_1 + \frac{-1}{\sin B}\\ \mathbf{elif}\;F \leq -7.2 \cdot 10^{-64}:\\ \;\;\;\;t_0 - \left(\frac{x}{B} + -0.3333333333333333 \cdot \left(x \cdot B\right)\right)\\ \mathbf{elif}\;F \leq 9 \cdot 10^{-112}:\\ \;\;\;\;F \cdot \left(\sqrt{\frac{1}{2 + x \cdot 2}} \cdot \frac{1}{B}\right) - \frac{x}{\tan B}\\ \mathbf{elif}\;F \leq 1.4 \cdot 10^{-14}:\\ \;\;\;\;t_0 - \frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;t_1 + \frac{1}{\sin B}\\ \end{array} \]
Alternative 7
Accuracy76.8%
Cost14024
\[\begin{array}{l} t_0 := \frac{\sqrt{0.5}}{\frac{\sin B}{F}}\\ t_1 := x \cdot \frac{-1}{\tan B}\\ \mathbf{if}\;F \leq -9.2 \cdot 10^{-5}:\\ \;\;\;\;t_1 + \frac{-1}{\sin B}\\ \mathbf{elif}\;F \leq -8.5 \cdot 10^{-174}:\\ \;\;\;\;t_0 - \left(\frac{x}{B} + -0.3333333333333333 \cdot \left(x \cdot B\right)\right)\\ \mathbf{elif}\;F \leq 9.8 \cdot 10^{-172}:\\ \;\;\;\;\frac{-x}{\tan B}\\ \mathbf{elif}\;F \leq 8.6 \cdot 10^{-15}:\\ \;\;\;\;t_0 - \frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;t_1 + \frac{1}{\sin B}\\ \end{array} \]
Alternative 8
Accuracy67.0%
Cost13904
\[\begin{array}{l} t_0 := \frac{\sqrt{0.5}}{\frac{\sin B}{F}} - \frac{x}{B}\\ \mathbf{if}\;F \leq -1.42:\\ \;\;\;\;\frac{-1}{\sin B} - \frac{x}{B}\\ \mathbf{elif}\;F \leq -8.2 \cdot 10^{-174}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;F \leq 1.8 \cdot 10^{-176}:\\ \;\;\;\;\frac{-x}{\tan B}\\ \mathbf{elif}\;F \leq 1.26 \cdot 10^{-8}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\ \end{array} \]
Alternative 9
Accuracy72.2%
Cost13904
\[\begin{array}{l} t_0 := \frac{\sqrt{0.5}}{\frac{\sin B}{F}} - \frac{x}{B}\\ \mathbf{if}\;F \leq -0.44:\\ \;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{-1}{\sin B}\\ \mathbf{elif}\;F \leq -8.5 \cdot 10^{-174}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;F \leq 1.28 \cdot 10^{-169}:\\ \;\;\;\;\frac{-x}{\tan B}\\ \mathbf{elif}\;F \leq 1.26 \cdot 10^{-8}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\ \end{array} \]
Alternative 10
Accuracy77.6%
Cost13904
\[\begin{array}{l} t_0 := \frac{\sqrt{0.5}}{\frac{\sin B}{F}} - \frac{x}{B}\\ t_1 := x \cdot \frac{-1}{\tan B}\\ \mathbf{if}\;F \leq -0.082:\\ \;\;\;\;t_1 + \frac{-1}{\sin B}\\ \mathbf{elif}\;F \leq -8.5 \cdot 10^{-174}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;F \leq 2.6 \cdot 10^{-177}:\\ \;\;\;\;\frac{-x}{\tan B}\\ \mathbf{elif}\;F \leq 1.4 \cdot 10^{-14}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1 + \frac{1}{\sin B}\\ \end{array} \]
Alternative 11
Accuracy63.7%
Cost13780
\[\begin{array}{l} t_0 := F \cdot \frac{\sqrt{0.5}}{\sin B}\\ \mathbf{if}\;F \leq -122000:\\ \;\;\;\;\frac{-1}{\sin B} - \frac{x}{B}\\ \mathbf{elif}\;F \leq -8.8 \cdot 10^{-41}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;F \leq -1.6 \cdot 10^{-56}:\\ \;\;\;\;\left|B \cdot \left(x \cdot 0.3333333333333333\right)\right| - \frac{x}{B}\\ \mathbf{elif}\;F \leq 1.04 \cdot 10^{-109}:\\ \;\;\;\;\frac{-x}{\tan B}\\ \mathbf{elif}\;F \leq 1.38 \cdot 10^{-11}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\ \end{array} \]
Alternative 12
Accuracy63.6%
Cost13780
\[\begin{array}{l} \mathbf{if}\;F \leq -122000:\\ \;\;\;\;\frac{-1}{\sin B} - \frac{x}{B}\\ \mathbf{elif}\;F \leq -1.35 \cdot 10^{-41}:\\ \;\;\;\;F \cdot \frac{\sqrt{0.5}}{\sin B}\\ \mathbf{elif}\;F \leq -1.9 \cdot 10^{-61}:\\ \;\;\;\;\left|B \cdot \left(x \cdot 0.3333333333333333\right)\right| - \frac{x}{B}\\ \mathbf{elif}\;F \leq 4 \cdot 10^{-109}:\\ \;\;\;\;\frac{-x}{\tan B}\\ \mathbf{elif}\;F \leq 4.6 \cdot 10^{-13}:\\ \;\;\;\;\frac{F \cdot \sqrt{0.5}}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\ \end{array} \]
Alternative 13
Accuracy56.2%
Cost7376
\[\begin{array}{l} t_0 := \frac{F \cdot \sqrt{0.5} - x}{B}\\ \mathbf{if}\;F \leq -92000000000:\\ \;\;\;\;B \cdot -0.16666666666666666 + \left(\frac{-1}{B} - \frac{x}{B}\right)\\ \mathbf{elif}\;F \leq -8.5 \cdot 10^{-174}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;F \leq 3.1 \cdot 10^{-161}:\\ \;\;\;\;\frac{-x}{\tan B}\\ \mathbf{elif}\;F \leq 1.55 \cdot 10^{-37}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\ \end{array} \]
Alternative 14
Accuracy62.6%
Cost7244
\[\begin{array}{l} \mathbf{if}\;F \leq -122000:\\ \;\;\;\;\frac{-1}{\sin B} - \frac{x}{B}\\ \mathbf{elif}\;F \leq 9.2 \cdot 10^{-166}:\\ \;\;\;\;\frac{-x}{\tan B}\\ \mathbf{elif}\;F \leq 1.55 \cdot 10^{-37}:\\ \;\;\;\;\frac{F \cdot \sqrt{0.5} - x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\ \end{array} \]
Alternative 15
Accuracy55.2%
Cost6980
\[\begin{array}{l} \mathbf{if}\;F \leq 5.4 \cdot 10^{+41}:\\ \;\;\;\;\frac{-x}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\ \end{array} \]
Alternative 16
Accuracy49.7%
Cost6656
\[\frac{-x}{\tan B} \]
Alternative 17
Accuracy40.8%
Cost968
\[\begin{array}{l} \mathbf{if}\;F \leq -92000000000:\\ \;\;\;\;B \cdot -0.16666666666666666 + \left(\frac{-1}{B} - \frac{x}{B}\right)\\ \mathbf{elif}\;F \leq 3.1 \cdot 10^{-88}:\\ \;\;\;\;\left(x \cdot B\right) \cdot 0.3333333333333333 - \frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{B} + B \cdot 0.16666666666666666\right) - \frac{x}{B}\\ \end{array} \]
Alternative 18
Accuracy35.5%
Cost836
\[\begin{array}{l} \mathbf{if}\;F \leq -92000000000:\\ \;\;\;\;B \cdot -0.16666666666666666 + \left(\frac{-1}{B} - \frac{x}{B}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot B\right) \cdot 0.3333333333333333 - \frac{x}{B}\\ \end{array} \]
Alternative 19
Accuracy29.8%
Cost576
\[x \cdot \left(B \cdot 0.3333333333333333 + \frac{-1}{B}\right) \]
Alternative 20
Accuracy29.8%
Cost576
\[\left(x \cdot B\right) \cdot 0.3333333333333333 - \frac{x}{B} \]
Alternative 21
Accuracy27.5%
Cost256
\[\frac{-x}{B} \]

Reproduce?

herbie shell --seed 2023255 
(FPCore (F B x)
  :name "VandenBroeck and Keller, Equation (23)"
  :precision binary64
  (+ (- (* x (/ 1.0 (tan B)))) (* (/ F (sin B)) (pow (+ (+ (* F F) 2.0) (* 2.0 x)) (- (/ 1.0 2.0))))))