Average Error: 13.5 → 0.3
Time: 34.3s
Precision: binary64
Cost: 26696
\[\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}\\ \mathbf{if}\;F \leq -10000000000:\\ \;\;\;\;\frac{-1}{\sin B} - t_0\\ \mathbf{elif}\;F \leq 100000:\\ \;\;\;\;\frac{\sqrt{\frac{1}{\mathsf{fma}\left(F, F, 2\right)}}}{\frac{\sin B}{F}} - t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{\cos B}{\frac{\sin B}{x}}\\ \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))))
   (if (<= F -10000000000.0)
     (- (/ -1.0 (sin B)) t_0)
     (if (<= F 100000.0)
       (- (/ (sqrt (/ 1.0 (fma F F 2.0))) (/ (sin B) F)) t_0)
       (- (/ 1.0 (sin B)) (/ (cos B) (/ (sin B) x)))))))
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 tmp;
	if (F <= -10000000000.0) {
		tmp = (-1.0 / sin(B)) - t_0;
	} else if (F <= 100000.0) {
		tmp = (sqrt((1.0 / fma(F, F, 2.0))) / (sin(B) / F)) - t_0;
	} else {
		tmp = (1.0 / sin(B)) - (cos(B) / (sin(B) / x));
	}
	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))
	tmp = 0.0
	if (F <= -10000000000.0)
		tmp = Float64(Float64(-1.0 / sin(B)) - t_0);
	elseif (F <= 100000.0)
		tmp = Float64(Float64(sqrt(Float64(1.0 / fma(F, F, 2.0))) / Float64(sin(B) / F)) - t_0);
	else
		tmp = Float64(Float64(1.0 / sin(B)) - Float64(cos(B) / Float64(sin(B) / x)));
	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]}, If[LessEqual[F, -10000000000.0], N[(N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[F, 100000.0], N[(N[(N[Sqrt[N[(1.0 / N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[Sin[B], $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[B], $MachinePrecision] / N[(N[Sin[B], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $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}\\
\mathbf{if}\;F \leq -10000000000:\\
\;\;\;\;\frac{-1}{\sin B} - t_0\\

\mathbf{elif}\;F \leq 100000:\\
\;\;\;\;\frac{\sqrt{\frac{1}{\mathsf{fma}\left(F, F, 2\right)}}}{\frac{\sin B}{F}} - t_0\\

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


\end{array}

Error

Derivation

  1. Split input into 3 regimes
  2. if F < -1e10

    1. Initial program 25.0

      \[\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. Simplified19.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}} \]
    3. Applied egg-rr19.2

      \[\leadsto \color{blue}{\frac{F \cdot {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}} - \frac{x}{\tan B} \]
    4. Taylor expanded in x around 0 19.2

      \[\leadsto \frac{F \cdot \color{blue}{\sqrt{\frac{1}{{F}^{2} + 2}}}}{\sin B} - \frac{x}{\tan B} \]
    5. Simplified19.2

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

      \[\leadsto \frac{\color{blue}{\frac{F}{\sqrt{\mathsf{fma}\left(F, F, 2\right)}}}}{\sin B} - \frac{x}{\tan B} \]
    7. Taylor expanded in F around -inf 0.1

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

    if -1e10 < F < 1e5

    1. Initial program 0.4

      \[\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. Simplified0.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}} \]
    3. Applied egg-rr0.3

      \[\leadsto \color{blue}{\frac{F \cdot {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}} - \frac{x}{\tan B} \]
    4. Taylor expanded in x around 0 0.4

      \[\leadsto \frac{F \cdot \color{blue}{\sqrt{\frac{1}{{F}^{2} + 2}}}}{\sin B} - \frac{x}{\tan B} \]
    5. Simplified0.4

      \[\leadsto \frac{F \cdot \color{blue}{\sqrt{\frac{1}{\mathsf{fma}\left(F, F, 2\right)}}}}{\sin B} - \frac{x}{\tan B} \]
    6. Applied egg-rr0.4

      \[\leadsto \frac{\color{blue}{\frac{F}{\sqrt{\mathsf{fma}\left(F, F, 2\right)}}}}{\sin B} - \frac{x}{\tan B} \]
    7. Taylor expanded in B around inf 0.4

      \[\leadsto \color{blue}{\frac{F}{\sin B} \cdot \sqrt{\frac{1}{{F}^{2} + 2}}} - \frac{x}{\tan B} \]
    8. Simplified0.4

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

    if 1e5 < F

    1. Initial program 24.5

      \[\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. Simplified18.7

      \[\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}} \]
    3. Taylor expanded in F around inf 0.2

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

      \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{\cos B \cdot x}{\sin B}} \]
    5. Simplified0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \leq -10000000000:\\ \;\;\;\;\frac{-1}{\sin B} - \frac{x}{\tan B}\\ \mathbf{elif}\;F \leq 100000:\\ \;\;\;\;\frac{\sqrt{\frac{1}{\mathsf{fma}\left(F, F, 2\right)}}}{\frac{\sin B}{F}} - \frac{x}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{\cos B}{\frac{\sin B}{x}}\\ \end{array} \]

Alternatives

Alternative 1
Error0.3
Cost26568
\[\begin{array}{l} t_0 := \frac{x}{\tan B}\\ \mathbf{if}\;F \leq -6.365437042484704 \cdot 10^{+155}:\\ \;\;\;\;\frac{-1}{\sin B} - t_0\\ \mathbf{elif}\;F \leq 1.0720985426434367 \cdot 10^{+156}:\\ \;\;\;\;\frac{\frac{F}{\sqrt{\mathsf{fma}\left(F, F, 2\right)}}}{\sin B} - t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{\cos B}{\frac{\sin B}{x}}\\ \end{array} \]
Alternative 2
Error0.3
Cost20744
\[\begin{array}{l} \mathbf{if}\;F \leq -225000:\\ \;\;\;\;\frac{-1}{\sin B} - \frac{x}{\tan B}\\ \mathbf{elif}\;F \leq 1250:\\ \;\;\;\;\frac{F}{\sin B} \cdot {\left(\left(2 + F \cdot F\right) + x \cdot 2\right)}^{-0.5} + \frac{-1}{\frac{\tan B}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{\cos B}{\frac{\sin B}{x}}\\ \end{array} \]
Alternative 3
Error0.5
Cost20744
\[\begin{array}{l} \mathbf{if}\;F \leq -0.00052:\\ \;\;\;\;\frac{\frac{F}{\frac{-1}{F} - F}}{\sin B} - \frac{x}{\tan B}\\ \mathbf{elif}\;F \leq 1250:\\ \;\;\;\;x \cdot \frac{-1}{\tan B} + \frac{F}{\sin B} \cdot {\left(\left(2 + F \cdot F\right) + x \cdot 2\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{\cos B}{\frac{\sin B}{x}}\\ \end{array} \]
Alternative 4
Error0.8
Cost20040
\[\begin{array}{l} t_0 := \frac{x}{\tan B}\\ \mathbf{if}\;F \leq -100000:\\ \;\;\;\;\frac{\frac{F}{\frac{-1}{F} - F}}{\sin B} - t_0\\ \mathbf{elif}\;F \leq 0.0025:\\ \;\;\;\;\frac{\frac{F}{\sqrt{2}}}{\sin B} - t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - t_0\\ \end{array} \]
Alternative 5
Error0.8
Cost20040
\[\begin{array}{l} t_0 := \frac{x}{\tan B}\\ \mathbf{if}\;F \leq -100000:\\ \;\;\;\;\frac{\frac{F}{\frac{-1}{F} - F}}{\sin B} - t_0\\ \mathbf{elif}\;F \leq 0.0025:\\ \;\;\;\;F \cdot \frac{\sqrt{0.5}}{\sin B} - t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - t_0\\ \end{array} \]
Alternative 6
Error0.8
Cost20040
\[\begin{array}{l} t_0 := \frac{x}{\tan B}\\ \mathbf{if}\;F \leq -100000:\\ \;\;\;\;\frac{\frac{F}{\frac{-1}{F} - F}}{\sin B} - t_0\\ \mathbf{elif}\;F \leq 0.0025:\\ \;\;\;\;\frac{F \cdot \sqrt{0.5}}{\sin B} - t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - t_0\\ \end{array} \]
Alternative 7
Error0.8
Cost20040
\[\begin{array}{l} t_0 := \frac{x}{\tan B}\\ \mathbf{if}\;F \leq -100000:\\ \;\;\;\;\frac{\frac{F}{\frac{-1}{F} - F}}{\sin B} - t_0\\ \mathbf{elif}\;F \leq 100000:\\ \;\;\;\;\frac{F \cdot \sqrt{0.5}}{\sin B} - t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{\cos B}{\frac{\sin B}{x}}\\ \end{array} \]
Alternative 8
Error7.8
Cost14480
\[\begin{array}{l} t_0 := \frac{F}{\sin B} \cdot {\left(\left(2 + F \cdot F\right) + x \cdot 2\right)}^{-0.5} - \frac{x}{B}\\ t_1 := \frac{x}{\tan B}\\ \mathbf{if}\;F \leq -225000:\\ \;\;\;\;\frac{-1}{\sin B} - t_1\\ \mathbf{elif}\;F \leq -1.4 \cdot 10^{-94}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;F \leq 3.5 \cdot 10^{-137}:\\ \;\;\;\;\frac{\frac{F}{\frac{-1}{F} - F}}{\sin B} - t_1\\ \mathbf{elif}\;F \leq 1.22 \cdot 10^{-26}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{F}{F + \frac{1}{F}}}{\sin B} - t_1\\ \end{array} \]
Alternative 9
Error11.1
Cost13764
\[\begin{array}{l} t_0 := \frac{x}{\tan B}\\ \mathbf{if}\;F \leq -7.5 \cdot 10^{-65}:\\ \;\;\;\;\frac{-1}{\sin B} - t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{F}{F + \frac{1}{F}}}{\sin B} - t_0\\ \end{array} \]
Alternative 10
Error10.8
Cost13764
\[\begin{array}{l} t_0 := \frac{x}{\tan B}\\ \mathbf{if}\;F \leq 10^{-236}:\\ \;\;\;\;\frac{\frac{F}{\frac{-1}{F} - F}}{\sin B} - t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{F}{F + \frac{1}{F}}}{\sin B} - t_0\\ \end{array} \]
Alternative 11
Error11.5
Cost13512
\[\begin{array}{l} t_0 := \frac{x}{\tan B}\\ \mathbf{if}\;F \leq -7.5 \cdot 10^{-65}:\\ \;\;\;\;\frac{-1}{\sin B} - t_0\\ \mathbf{elif}\;F \leq 1.75 \cdot 10^{-83}:\\ \;\;\;\;\left(-\cos B\right) \cdot \frac{x}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - t_0\\ \end{array} \]
Alternative 12
Error16.4
Cost13448
\[\begin{array}{l} t_0 := \frac{x}{\tan B}\\ \mathbf{if}\;F \leq -7.5 \cdot 10^{-65}:\\ \;\;\;\;\frac{-1}{\sin B} - t_0\\ \mathbf{elif}\;F \leq 2.2 \cdot 10^{+30}:\\ \;\;\;\;\left(-\cos B\right) \cdot \frac{x}{\sin B}\\ \mathbf{elif}\;F \leq 1.455697109945711 \cdot 10^{+88}:\\ \;\;\;\;\frac{F}{F \cdot \sin B} - \frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{B} - t_0\\ \end{array} \]
Alternative 13
Error16.4
Cost13448
\[\begin{array}{l} t_0 := \frac{x}{\tan B}\\ \mathbf{if}\;F \leq -7.5 \cdot 10^{-65}:\\ \;\;\;\;\frac{-1}{\sin B} - t_0\\ \mathbf{elif}\;F \leq 2.2 \cdot 10^{+30}:\\ \;\;\;\;-\frac{x \cdot \cos B}{\sin B}\\ \mathbf{elif}\;F \leq 1.455697109945711 \cdot 10^{+88}:\\ \;\;\;\;\frac{F}{F \cdot \sin B} - \frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{B} - t_0\\ \end{array} \]
Alternative 14
Error26.6
Cost13316
\[\begin{array}{l} \mathbf{if}\;F \leq 2.2 \cdot 10^{+30}:\\ \;\;\;\;\left(-\cos B\right) \cdot \frac{x}{\sin B}\\ \mathbf{elif}\;F \leq 1.455697109945711 \cdot 10^{+88}:\\ \;\;\;\;\frac{F}{F \cdot \sin B} - \frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\ \end{array} \]
Alternative 15
Error32.6
Cost9104
\[\begin{array}{l} t_0 := \frac{1}{F} \cdot \frac{F}{B} - x \cdot \frac{1}{\tan B}\\ \mathbf{if}\;B \leq -8.22226974857955 \cdot 10^{-26}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;B \leq -1 \cdot 10^{-142}:\\ \;\;\;\;\frac{-x}{B}\\ \mathbf{elif}\;B \leq 10^{-260}:\\ \;\;\;\;\frac{1 - x}{B}\\ \mathbf{elif}\;B \leq 0.002389067783644144:\\ \;\;\;\;\left(B \cdot \left(x \cdot -0.16666666666666666 + x \cdot 0.5\right) + {B}^{3} \cdot \left(\left(x \cdot 0.008333333333333333 + -0.16666666666666666 \cdot \left(x \cdot -0.5 + x \cdot 0.16666666666666666\right)\right) + x \cdot -0.041666666666666664\right)\right) - \frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 16
Error32.6
Cost7760
\[\begin{array}{l} t_0 := \frac{1}{F} \cdot \frac{F}{B} - x \cdot \frac{1}{\tan B}\\ \mathbf{if}\;B \leq -8.22226974857955 \cdot 10^{-26}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;B \leq -1 \cdot 10^{-142}:\\ \;\;\;\;\frac{-x}{B}\\ \mathbf{elif}\;B \leq 10^{-260}:\\ \;\;\;\;\frac{1 - x}{B}\\ \mathbf{elif}\;B \leq 0.002389067783644144:\\ \;\;\;\;B \cdot \left(x \cdot -0.16666666666666666 + x \cdot 0.5\right) - \frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 17
Error33.2
Cost7376
\[\begin{array}{l} t_0 := \frac{1}{B} - \frac{x}{\tan B}\\ \mathbf{if}\;B \leq -6.191895160118006 \cdot 10^{-43}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;B \leq -1 \cdot 10^{-142}:\\ \;\;\;\;\frac{-x}{B}\\ \mathbf{elif}\;B \leq 10^{-260}:\\ \;\;\;\;\frac{1 - x}{B}\\ \mathbf{elif}\;B \leq 0.002389067783644144:\\ \;\;\;\;B \cdot \left(x \cdot -0.16666666666666666 + x \cdot 0.5\right) - \frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 18
Error41.0
Cost6788
\[\begin{array}{l} \mathbf{if}\;F \leq 1150000000:\\ \;\;\;\;\frac{-x}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B}\\ \end{array} \]
Alternative 19
Error42.2
Cost6724
\[\begin{array}{l} \mathbf{if}\;F \leq 1150000000:\\ \;\;\;\;B \cdot \left(x \cdot -0.16666666666666666 + x \cdot 0.5\right) - \frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B}\\ \end{array} \]
Alternative 20
Error45.0
Cost1092
\[\begin{array}{l} \mathbf{if}\;F \leq 1.75 \cdot 10^{-83}:\\ \;\;\;\;\frac{-x}{B}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{B} + B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right)\right) - \frac{x}{B}\\ \end{array} \]
Alternative 21
Error45.0
Cost452
\[\begin{array}{l} \mathbf{if}\;F \leq 7.5 \cdot 10^{-106}:\\ \;\;\;\;\frac{-x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - x}{B}\\ \end{array} \]
Alternative 22
Error47.4
Cost388
\[\begin{array}{l} \mathbf{if}\;F \leq 6.6 \cdot 10^{+28}:\\ \;\;\;\;\frac{-x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{B}\\ \end{array} \]
Alternative 23
Error57.2
Cost192
\[\frac{1}{B} \]

Error

Reproduce

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