VandenBroeck and Keller, Equation (23)

Percentage Accurate: 76.8% → 84.7%
Time: 14.3s
Alternatives: 3
Speedup: 1.5×

Specification

?
\[\begin{array}{l} \\ \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)} \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))))))
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)));
}
real(8) function code(f, b, x)
    real(8), intent (in) :: f
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    code = -(x * (1.0d0 / tan(b))) + ((f / sin(b)) * ((((f * f) + 2.0d0) + (2.0d0 * x)) ** -(1.0d0 / 2.0d0)))
end function
public static double code(double F, double B, double x) {
	return -(x * (1.0 / Math.tan(B))) + ((F / Math.sin(B)) * Math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)));
}
def code(F, B, x):
	return -(x * (1.0 / math.tan(B))) + ((F / math.sin(B)) * math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)))
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 tmp = code(F, B, x)
	tmp = -(x * (1.0 / tan(B))) + ((F / sin(B)) * ((((F * F) + 2.0) + (2.0 * x)) ^ -(1.0 / 2.0)));
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]
\begin{array}{l}

\\
\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)}
\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 3 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: 76.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \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)} \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))))))
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)));
}
real(8) function code(f, b, x)
    real(8), intent (in) :: f
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    code = -(x * (1.0d0 / tan(b))) + ((f / sin(b)) * ((((f * f) + 2.0d0) + (2.0d0 * x)) ** -(1.0d0 / 2.0d0)))
end function
public static double code(double F, double B, double x) {
	return -(x * (1.0 / Math.tan(B))) + ((F / Math.sin(B)) * Math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)));
}
def code(F, B, x):
	return -(x * (1.0 / math.tan(B))) + ((F / math.sin(B)) * math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)))
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 tmp = code(F, B, x)
	tmp = -(x * (1.0 / tan(B))) + ((F / sin(B)) * ((((F * F) + 2.0) + (2.0 * x)) ^ -(1.0 / 2.0)));
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]
\begin{array}{l}

\\
\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)}
\end{array}

Alternative 1: 84.7% accurate, 1.4× speedup?

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

\\
\mathsf{fma}\left(\frac{F}{\sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}, \frac{1}{\sin B}, \frac{-x}{\tan B}\right)
\end{array}
Derivation
  1. Initial program 76.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. Add Preprocessing
  3. Step-by-step derivation
    1. +-commutativeN/A

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

      \[\leadsto \color{blue}{{\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot \frac{F}{\sin B}} + \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) \]
    3. clear-numN/A

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

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

      \[\leadsto \color{blue}{\left({\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot \frac{1}{\sin B}\right) \cdot F} + \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) \]
    6. div-invN/A

      \[\leadsto \color{blue}{\frac{{\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}{\sin B}} \cdot F + \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) \]
    7. accelerator-lowering-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{{\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}{\sin B}, F, \mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
  4. Applied egg-rr86.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{{\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}, F, -\frac{x}{\tan B}\right)} \]
  5. Step-by-step derivation
    1. clear-numN/A

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

      \[\leadsto \color{blue}{\frac{1 \cdot F}{\frac{\sin B}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{-1}{2}}}}} + \left(\mathsf{neg}\left(\frac{x}{\tan B}\right)\right) \]
    3. div-invN/A

      \[\leadsto \frac{1 \cdot F}{\color{blue}{\sin B \cdot \frac{1}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{-1}{2}}}}} + \left(\mathsf{neg}\left(\frac{x}{\tan B}\right)\right) \]
    4. times-fracN/A

      \[\leadsto \color{blue}{\frac{1}{\sin B} \cdot \frac{F}{\frac{1}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{-1}{2}}}}} + \left(\mathsf{neg}\left(\frac{x}{\tan B}\right)\right) \]
    5. accelerator-lowering-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\sin B}, \frac{F}{\frac{1}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{-1}{2}}}}, \mathsf{neg}\left(\frac{x}{\tan B}\right)\right)} \]
  6. Applied egg-rr86.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\sin B}, \frac{F}{{\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{0.5}}, -\frac{x}{\tan B}\right)} \]
  7. Step-by-step derivation
    1. associate-*l/N/A

      \[\leadsto \color{blue}{\frac{1 \cdot \frac{F}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{1}{2}}}}{\sin B}} + \left(\mathsf{neg}\left(\frac{x}{\tan B}\right)\right) \]
    2. div-invN/A

      \[\leadsto \color{blue}{\left(1 \cdot \frac{F}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{1}{2}}}\right) \cdot \frac{1}{\sin B}} + \left(\mathsf{neg}\left(\frac{x}{\tan B}\right)\right) \]
    3. accelerator-lowering-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(1 \cdot \frac{F}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{1}{2}}}, \frac{1}{\sin B}, \mathsf{neg}\left(\frac{x}{\tan B}\right)\right)} \]
    4. associate-*r/N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot F}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{1}{2}}}}, \frac{1}{\sin B}, \mathsf{neg}\left(\frac{x}{\tan B}\right)\right) \]
    5. *-lft-identityN/A

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{F}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{1}{2}}}}, \frac{1}{\sin B}, \mathsf{neg}\left(\frac{x}{\tan B}\right)\right) \]
    7. unpow1/2N/A

      \[\leadsto \mathsf{fma}\left(\frac{F}{\color{blue}{\sqrt{2 \cdot x + \left(F \cdot F + 2\right)}}}, \frac{1}{\sin B}, \mathsf{neg}\left(\frac{x}{\tan B}\right)\right) \]
    8. sqrt-lowering-sqrt.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{F}{\color{blue}{\sqrt{2 \cdot x + \left(F \cdot F + 2\right)}}}, \frac{1}{\sin B}, \mathsf{neg}\left(\frac{x}{\tan B}\right)\right) \]
    9. accelerator-lowering-fma.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{F}{\sqrt{\color{blue}{\mathsf{fma}\left(2, x, F \cdot F + 2\right)}}}, \frac{1}{\sin B}, \mathsf{neg}\left(\frac{x}{\tan B}\right)\right) \]
    10. accelerator-lowering-fma.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{F}{\sqrt{\mathsf{fma}\left(2, x, \color{blue}{\mathsf{fma}\left(F, F, 2\right)}\right)}}, \frac{1}{\sin B}, \mathsf{neg}\left(\frac{x}{\tan B}\right)\right) \]
    11. /-lowering-/.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{F}{\sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}, \color{blue}{\frac{1}{\sin B}}, \mathsf{neg}\left(\frac{x}{\tan B}\right)\right) \]
    12. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{F}{\sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}, \frac{1}{\color{blue}{\sin B}}, \mathsf{neg}\left(\frac{x}{\tan B}\right)\right) \]
    13. neg-lowering-neg.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{F}{\sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}, \frac{1}{\sin B}, \color{blue}{\mathsf{neg}\left(\frac{x}{\tan B}\right)}\right) \]
    14. /-lowering-/.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{F}{\sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}, \frac{1}{\sin B}, \mathsf{neg}\left(\color{blue}{\frac{x}{\tan B}}\right)\right) \]
    15. tan-lowering-tan.f6486.9

      \[\leadsto \mathsf{fma}\left(\frac{F}{\sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}, \frac{1}{\sin B}, -\frac{x}{\color{blue}{\tan B}}\right) \]
  8. Applied egg-rr86.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{F}{\sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}, \frac{1}{\sin B}, -\frac{x}{\tan B}\right)} \]
  9. Final simplification86.9%

    \[\leadsto \mathsf{fma}\left(\frac{F}{\sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}}, \frac{1}{\sin B}, \frac{-x}{\tan B}\right) \]
  10. Add Preprocessing

Alternative 2: 84.6% accurate, 1.5× speedup?

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

\\
\frac{\frac{F}{\sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} - x \cdot \cos B}{\sin B}
\end{array}
Derivation
  1. Initial program 76.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. Add Preprocessing
  3. Step-by-step derivation
    1. +-commutativeN/A

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

      \[\leadsto \color{blue}{{\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot \frac{F}{\sin B}} + \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) \]
    3. clear-numN/A

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

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

      \[\leadsto \color{blue}{\left({\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot \frac{1}{\sin B}\right) \cdot F} + \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) \]
    6. div-invN/A

      \[\leadsto \color{blue}{\frac{{\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}{\sin B}} \cdot F + \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) \]
    7. accelerator-lowering-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{{\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}{\sin B}, F, \mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
  4. Applied egg-rr86.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{{\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}, F, -\frac{x}{\tan B}\right)} \]
  5. Step-by-step derivation
    1. clear-numN/A

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

      \[\leadsto \color{blue}{\frac{1 \cdot F}{\frac{\sin B}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{-1}{2}}}}} + \left(\mathsf{neg}\left(\frac{x}{\tan B}\right)\right) \]
    3. div-invN/A

      \[\leadsto \frac{1 \cdot F}{\color{blue}{\sin B \cdot \frac{1}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{-1}{2}}}}} + \left(\mathsf{neg}\left(\frac{x}{\tan B}\right)\right) \]
    4. times-fracN/A

      \[\leadsto \color{blue}{\frac{1}{\sin B} \cdot \frac{F}{\frac{1}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{-1}{2}}}}} + \left(\mathsf{neg}\left(\frac{x}{\tan B}\right)\right) \]
    5. accelerator-lowering-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\sin B}, \frac{F}{\frac{1}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{-1}{2}}}}, \mathsf{neg}\left(\frac{x}{\tan B}\right)\right)} \]
  6. Applied egg-rr86.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\sin B}, \frac{F}{{\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{0.5}}, -\frac{x}{\tan B}\right)} \]
  7. Step-by-step derivation
    1. unsub-negN/A

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

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

      \[\leadsto \frac{1 \cdot \frac{F}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{1}{2}}}}{\sin B} - \frac{x}{\color{blue}{\frac{\sin B}{\cos B}}} \]
    4. associate-/r/N/A

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

      \[\leadsto \frac{1 \cdot \frac{F}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{1}{2}}}}{\sin B} - \color{blue}{\frac{x \cdot \cos B}{\sin B}} \]
    6. sub-divN/A

      \[\leadsto \color{blue}{\frac{1 \cdot \frac{F}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{1}{2}}} - x \cdot \cos B}{\sin B}} \]
  8. Applied egg-rr86.9%

    \[\leadsto \color{blue}{\frac{\frac{F}{\sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)}} - x \cdot \cos B}{\sin B}} \]
  9. Add Preprocessing

Alternative 3: 84.7% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \frac{F}{\sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)} \cdot \sin B} - \frac{x}{\tan B} \end{array} \]
(FPCore (F B x)
 :precision binary64
 (- (/ F (* (sqrt (fma 2.0 x (fma F F 2.0))) (sin B))) (/ x (tan B))))
double code(double F, double B, double x) {
	return (F / (sqrt(fma(2.0, x, fma(F, F, 2.0))) * sin(B))) - (x / tan(B));
}
function code(F, B, x)
	return Float64(Float64(F / Float64(sqrt(fma(2.0, x, fma(F, F, 2.0))) * sin(B))) - Float64(x / tan(B)))
end
code[F_, B_, x_] := N[(N[(F / N[(N[Sqrt[N[(2.0 * x + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{F}{\sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)} \cdot \sin B} - \frac{x}{\tan B}
\end{array}
Derivation
  1. Initial program 76.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. Add Preprocessing
  3. Step-by-step derivation
    1. +-commutativeN/A

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

      \[\leadsto \color{blue}{{\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot \frac{F}{\sin B}} + \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) \]
    3. clear-numN/A

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

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

      \[\leadsto \color{blue}{\left({\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot \frac{1}{\sin B}\right) \cdot F} + \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) \]
    6. div-invN/A

      \[\leadsto \color{blue}{\frac{{\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}{\sin B}} \cdot F + \left(\mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right) \]
    7. accelerator-lowering-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{{\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}{\sin B}, F, \mathsf{neg}\left(x \cdot \frac{1}{\tan B}\right)\right)} \]
  4. Applied egg-rr86.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{{\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}, F, -\frac{x}{\tan B}\right)} \]
  5. Step-by-step derivation
    1. clear-numN/A

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

      \[\leadsto \color{blue}{\frac{1 \cdot F}{\frac{\sin B}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{-1}{2}}}}} + \left(\mathsf{neg}\left(\frac{x}{\tan B}\right)\right) \]
    3. div-invN/A

      \[\leadsto \frac{1 \cdot F}{\color{blue}{\sin B \cdot \frac{1}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{-1}{2}}}}} + \left(\mathsf{neg}\left(\frac{x}{\tan B}\right)\right) \]
    4. times-fracN/A

      \[\leadsto \color{blue}{\frac{1}{\sin B} \cdot \frac{F}{\frac{1}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{-1}{2}}}}} + \left(\mathsf{neg}\left(\frac{x}{\tan B}\right)\right) \]
    5. accelerator-lowering-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\sin B}, \frac{F}{\frac{1}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{-1}{2}}}}, \mathsf{neg}\left(\frac{x}{\tan B}\right)\right)} \]
  6. Applied egg-rr86.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\sin B}, \frac{F}{{\left(\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{0.5}}, -\frac{x}{\tan B}\right)} \]
  7. Step-by-step derivation
    1. unsub-negN/A

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

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

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

      \[\leadsto \color{blue}{F} \cdot \frac{1}{\sin B \cdot {\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{1}{2}}} - \frac{x}{\tan B} \]
    5. inv-powN/A

      \[\leadsto F \cdot \color{blue}{{\left(\sin B \cdot {\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{1}{2}}\right)}^{-1}} - \frac{x}{\tan B} \]
    6. unpow-prod-downN/A

      \[\leadsto F \cdot \color{blue}{\left({\sin B}^{-1} \cdot {\left({\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{1}{2}}\right)}^{-1}\right)} - \frac{x}{\tan B} \]
    7. metadata-evalN/A

      \[\leadsto F \cdot \left({\sin B}^{-1} \cdot {\left({\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\color{blue}{\left(\mathsf{neg}\left(\frac{-1}{2}\right)\right)}}\right)}^{-1}\right) - \frac{x}{\tan B} \]
    8. pow-flipN/A

      \[\leadsto F \cdot \left({\sin B}^{-1} \cdot {\color{blue}{\left(\frac{1}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{-1}{2}}}\right)}}^{-1}\right) - \frac{x}{\tan B} \]
    9. unpow-prod-downN/A

      \[\leadsto F \cdot \color{blue}{{\left(\sin B \cdot \frac{1}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{-1}{2}}}\right)}^{-1}} - \frac{x}{\tan B} \]
    10. div-invN/A

      \[\leadsto F \cdot {\color{blue}{\left(\frac{\sin B}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{-1}{2}}}\right)}}^{-1} - \frac{x}{\tan B} \]
    11. inv-powN/A

      \[\leadsto F \cdot \color{blue}{\frac{1}{\frac{\sin B}{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{-1}{2}}}}} - \frac{x}{\tan B} \]
    12. clear-numN/A

      \[\leadsto F \cdot \color{blue}{\frac{{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}^{\frac{-1}{2}}}{\sin B}} - \frac{x}{\tan B} \]
  8. Applied egg-rr86.9%

    \[\leadsto \color{blue}{\frac{F}{\sqrt{\mathsf{fma}\left(2, x, \mathsf{fma}\left(F, F, 2\right)\right)} \cdot \sin B} - \frac{x}{\tan B}} \]
  9. Add Preprocessing

Reproduce

?
herbie shell --seed 2024208 
(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))))))