| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 33160 |
(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 -122000000.0)
(- (/ 1.0 (/ (/ (sin B) (/ -1.0 F)) F)) t_0)
(if (<= F 120000000.0)
(fma
(/ F (sin B))
(pow (fma x 2.0 (fma F F 2.0)) -0.5)
(/ (- x) (tan B)))
(- (/ 1.0 (sin B)) 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 tmp;
if (F <= -122000000.0) {
tmp = (1.0 / ((sin(B) / (-1.0 / F)) / F)) - t_0;
} else if (F <= 120000000.0) {
tmp = fma((F / sin(B)), pow(fma(x, 2.0, fma(F, F, 2.0)), -0.5), (-x / tan(B)));
} else {
tmp = (1.0 / sin(B)) - 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)) tmp = 0.0 if (F <= -122000000.0) tmp = Float64(Float64(1.0 / Float64(Float64(sin(B) / Float64(-1.0 / F)) / F)) - t_0); elseif (F <= 120000000.0) tmp = fma(Float64(F / sin(B)), (fma(x, 2.0, fma(F, F, 2.0)) ^ -0.5), Float64(Float64(-x) / tan(B))); else tmp = Float64(Float64(1.0 / sin(B)) - 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]}, If[LessEqual[F, -122000000.0], N[(N[(1.0 / N[(N[(N[Sin[B], $MachinePrecision] / N[(-1.0 / F), $MachinePrecision]), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[F, 120000000.0], N[(N[(F / N[Sin[B], $MachinePrecision]), $MachinePrecision] * N[Power[N[(x * 2.0 + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision] + N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sin[B], $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}\\
\mathbf{if}\;F \leq -122000000:\\
\;\;\;\;\frac{1}{\frac{\frac{\sin B}{\frac{-1}{F}}}{F}} - t_0\\
\mathbf{elif}\;F \leq 120000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{F}{\sin B}, {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}, \frac{-x}{\tan B}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - t_0\\
\end{array}
if F < -1.22e8Initial program 24.9
Simplified24.9
[Start]24.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)}
\] |
|---|---|
+-commutative [=>]24.9 | \[ \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 [=>]24.9 | \[ \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}}
\] |
+-commutative [=>]24.9 | \[ \frac{F}{\sin B} \cdot {\color{blue}{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}}^{\left(-\frac{1}{2}\right)} - x \cdot \frac{1}{\tan B}
\] |
*-commutative [=>]24.9 | \[ \frac{F}{\sin B} \cdot {\left(\color{blue}{x \cdot 2} + \left(F \cdot F + 2\right)\right)}^{\left(-\frac{1}{2}\right)} - x \cdot \frac{1}{\tan B}
\] |
fma-def [=>]24.9 | \[ \frac{F}{\sin B} \cdot {\color{blue}{\left(\mathsf{fma}\left(x, 2, F \cdot F + 2\right)\right)}}^{\left(-\frac{1}{2}\right)} - x \cdot \frac{1}{\tan B}
\] |
fma-def [=>]24.9 | \[ \frac{F}{\sin B} \cdot {\left(\mathsf{fma}\left(x, 2, \color{blue}{\mathsf{fma}\left(F, F, 2\right)}\right)\right)}^{\left(-\frac{1}{2}\right)} - x \cdot \frac{1}{\tan B}
\] |
metadata-eval [=>]24.9 | \[ \frac{F}{\sin B} \cdot {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{\left(-\color{blue}{0.5}\right)} - x \cdot \frac{1}{\tan B}
\] |
metadata-eval [=>]24.9 | \[ \frac{F}{\sin B} \cdot {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{\color{blue}{-0.5}} - x \cdot \frac{1}{\tan B}
\] |
associate-*r/ [=>]24.9 | \[ \frac{F}{\sin B} \cdot {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5} - \color{blue}{\frac{x \cdot 1}{\tan B}}
\] |
*-rgt-identity [=>]24.9 | \[ \frac{F}{\sin B} \cdot {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5} - \frac{\color{blue}{x}}{\tan B}
\] |
Applied egg-rr32.8
Simplified19.0
[Start]32.8 | \[ \left(e^{\mathsf{log1p}\left(F \cdot \frac{{\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}\right)} - 1\right) - \frac{x}{\tan B}
\] |
|---|---|
expm1-def [=>]32.8 | \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(F \cdot \frac{{\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B}\right)\right)} - \frac{x}{\tan B}
\] |
expm1-log1p [=>]19.0 | \[ \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}
\] |
Applied egg-rr19.0
Taylor expanded in F around -inf 0.3
if -1.22e8 < F < 1.2e8Initial program 0.4
Simplified0.3
[Start]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)}
\] |
|---|---|
+-commutative [=>]0.4 | \[ \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)}
\] |
fma-def [=>]0.4 | \[ \color{blue}{\mathsf{fma}\left(\frac{F}{\sin B}, {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}, -x \cdot \frac{1}{\tan B}\right)}
\] |
+-commutative [=>]0.4 | \[ \mathsf{fma}\left(\frac{F}{\sin B}, {\color{blue}{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}}^{\left(-\frac{1}{2}\right)}, -x \cdot \frac{1}{\tan B}\right)
\] |
*-commutative [=>]0.4 | \[ \mathsf{fma}\left(\frac{F}{\sin B}, {\left(\color{blue}{x \cdot 2} + \left(F \cdot F + 2\right)\right)}^{\left(-\frac{1}{2}\right)}, -x \cdot \frac{1}{\tan B}\right)
\] |
fma-def [=>]0.4 | \[ \mathsf{fma}\left(\frac{F}{\sin B}, {\color{blue}{\left(\mathsf{fma}\left(x, 2, F \cdot F + 2\right)\right)}}^{\left(-\frac{1}{2}\right)}, -x \cdot \frac{1}{\tan B}\right)
\] |
fma-def [=>]0.4 | \[ \mathsf{fma}\left(\frac{F}{\sin B}, {\left(\mathsf{fma}\left(x, 2, \color{blue}{\mathsf{fma}\left(F, F, 2\right)}\right)\right)}^{\left(-\frac{1}{2}\right)}, -x \cdot \frac{1}{\tan B}\right)
\] |
metadata-eval [=>]0.4 | \[ \mathsf{fma}\left(\frac{F}{\sin B}, {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{\left(-\color{blue}{0.5}\right)}, -x \cdot \frac{1}{\tan B}\right)
\] |
metadata-eval [=>]0.4 | \[ \mathsf{fma}\left(\frac{F}{\sin B}, {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{\color{blue}{-0.5}}, -x \cdot \frac{1}{\tan B}\right)
\] |
associate-*r/ [=>]0.3 | \[ \mathsf{fma}\left(\frac{F}{\sin B}, {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}, -\color{blue}{\frac{x \cdot 1}{\tan B}}\right)
\] |
distribute-neg-frac [=>]0.3 | \[ \mathsf{fma}\left(\frac{F}{\sin B}, {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}, \color{blue}{\frac{-x \cdot 1}{\tan B}}\right)
\] |
*-rgt-identity [=>]0.3 | \[ \mathsf{fma}\left(\frac{F}{\sin B}, {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}, \frac{-\color{blue}{x}}{\tan B}\right)
\] |
if 1.2e8 < F Initial program 25.7
Simplified25.7
[Start]25.7 | \[ \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 [=>]25.7 | \[ \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 [=>]25.7 | \[ \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}}
\] |
+-commutative [=>]25.7 | \[ \frac{F}{\sin B} \cdot {\color{blue}{\left(2 \cdot x + \left(F \cdot F + 2\right)\right)}}^{\left(-\frac{1}{2}\right)} - x \cdot \frac{1}{\tan B}
\] |
*-commutative [=>]25.7 | \[ \frac{F}{\sin B} \cdot {\left(\color{blue}{x \cdot 2} + \left(F \cdot F + 2\right)\right)}^{\left(-\frac{1}{2}\right)} - x \cdot \frac{1}{\tan B}
\] |
fma-def [=>]25.7 | \[ \frac{F}{\sin B} \cdot {\color{blue}{\left(\mathsf{fma}\left(x, 2, F \cdot F + 2\right)\right)}}^{\left(-\frac{1}{2}\right)} - x \cdot \frac{1}{\tan B}
\] |
fma-def [=>]25.7 | \[ \frac{F}{\sin B} \cdot {\left(\mathsf{fma}\left(x, 2, \color{blue}{\mathsf{fma}\left(F, F, 2\right)}\right)\right)}^{\left(-\frac{1}{2}\right)} - x \cdot \frac{1}{\tan B}
\] |
metadata-eval [=>]25.7 | \[ \frac{F}{\sin B} \cdot {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{\left(-\color{blue}{0.5}\right)} - x \cdot \frac{1}{\tan B}
\] |
metadata-eval [=>]25.7 | \[ \frac{F}{\sin B} \cdot {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{\color{blue}{-0.5}} - x \cdot \frac{1}{\tan B}
\] |
associate-*r/ [=>]25.7 | \[ \frac{F}{\sin B} \cdot {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5} - \color{blue}{\frac{x \cdot 1}{\tan B}}
\] |
*-rgt-identity [=>]25.7 | \[ \frac{F}{\sin B} \cdot {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5} - \frac{\color{blue}{x}}{\tan B}
\] |
Taylor expanded in F around inf 0.2
Final simplification0.2
| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 33160 |
| Alternative 2 | |
|---|---|
| Error | 0.2 |
| Cost | 33160 |
| Alternative 3 | |
|---|---|
| Error | 0.3 |
| Cost | 20744 |
| Alternative 4 | |
|---|---|
| Error | 0.3 |
| Cost | 20744 |
| Alternative 5 | |
|---|---|
| Error | 0.7 |
| Cost | 20424 |
| Alternative 6 | |
|---|---|
| Error | 0.7 |
| Cost | 20424 |
| Alternative 7 | |
|---|---|
| Error | 7.1 |
| Cost | 14480 |
| Alternative 8 | |
|---|---|
| Error | 7.1 |
| Cost | 14480 |
| Alternative 9 | |
|---|---|
| Error | 7.6 |
| Cost | 14288 |
| Alternative 10 | |
|---|---|
| Error | 16.2 |
| Cost | 13776 |
| Alternative 11 | |
|---|---|
| Error | 11.5 |
| Cost | 13764 |
| Alternative 12 | |
|---|---|
| Error | 22.2 |
| Cost | 13712 |
| Alternative 13 | |
|---|---|
| Error | 22.2 |
| Cost | 13712 |
| Alternative 14 | |
|---|---|
| Error | 11.5 |
| Cost | 13636 |
| Alternative 15 | |
|---|---|
| Error | 11.5 |
| Cost | 13636 |
| Alternative 16 | |
|---|---|
| Error | 26.6 |
| Cost | 8728 |
| Alternative 17 | |
|---|---|
| Error | 26.6 |
| Cost | 8344 |
| Alternative 18 | |
|---|---|
| Error | 26.7 |
| Cost | 7905 |
| Alternative 19 | |
|---|---|
| Error | 30.3 |
| Cost | 7904 |
| Alternative 20 | |
|---|---|
| Error | 27.0 |
| Cost | 7641 |
| Alternative 21 | |
|---|---|
| Error | 27.0 |
| Cost | 7641 |
| Alternative 22 | |
|---|---|
| Error | 28.1 |
| Cost | 7509 |
| Alternative 23 | |
|---|---|
| Error | 37.3 |
| Cost | 7121 |
| Alternative 24 | |
|---|---|
| Error | 38.6 |
| Cost | 6724 |
| Alternative 25 | |
|---|---|
| Error | 40.0 |
| Cost | 1096 |
| Alternative 26 | |
|---|---|
| Error | 39.9 |
| Cost | 840 |
| Alternative 27 | |
|---|---|
| Error | 46.0 |
| Cost | 785 |
| Alternative 28 | |
|---|---|
| Error | 42.8 |
| Cost | 785 |
| Alternative 29 | |
|---|---|
| Error | 40.1 |
| Cost | 584 |
| Alternative 30 | |
|---|---|
| Error | 52.1 |
| Cost | 324 |
| Alternative 31 | |
|---|---|
| Error | 57.0 |
| Cost | 192 |
herbie shell --seed 2023027
(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))))))