| Alternative 1 | |
|---|---|
| Error | 0.2 |
| 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 -2.25e+25)
(- (/ -1.0 (sin B)) t_0)
(if (<= F 100000000.0)
(- (/ (pow (fma x 2.0 (fma F F 2.0)) -0.5) (* (sin B) (/ 1.0 F))) t_0)
(- (/ 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 <= -2.25e+25) {
tmp = (-1.0 / sin(B)) - t_0;
} else if (F <= 100000000.0) {
tmp = (pow(fma(x, 2.0, fma(F, F, 2.0)), -0.5) / (sin(B) * (1.0 / F))) - t_0;
} 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 <= -2.25e+25) tmp = Float64(Float64(-1.0 / sin(B)) - t_0); elseif (F <= 100000000.0) tmp = Float64(Float64((fma(x, 2.0, fma(F, F, 2.0)) ^ -0.5) / Float64(sin(B) * Float64(1.0 / F))) - t_0); 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, -2.25e+25], N[(N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[F, 100000000.0], N[(N[(N[Power[N[(x * 2.0 + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision] / N[(N[Sin[B], $MachinePrecision] * N[(1.0 / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $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 -2.25 \cdot 10^{+25}:\\
\;\;\;\;\frac{-1}{\sin B} - t_0\\
\mathbf{elif}\;F \leq 100000000:\\
\;\;\;\;\frac{{\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B \cdot \frac{1}{F}} - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - t_0\\
\end{array}
if F < -2.25000000000000015e25Initial program 25.9
Simplified25.9
[Start]25.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 [=>]25.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 [=>]25.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 [=>]25.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 [=>]25.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 [=>]25.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 [=>]25.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 [=>]25.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 [=>]25.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/ [=>]25.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 [=>]25.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}
\] |
Taylor expanded in F around -inf 0.2
if -2.25000000000000015e25 < F < 1e8Initial 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)}
\] |
unsub-neg [=>]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)} - x \cdot \frac{1}{\tan B}}
\] |
+-commutative [=>]0.4 | \[ \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 [=>]0.4 | \[ \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 [=>]0.4 | \[ \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 [=>]0.4 | \[ \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 [=>]0.4 | \[ \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 [=>]0.4 | \[ \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/ [=>]0.3 | \[ \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 [=>]0.3 | \[ \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-rr0.3
Applied egg-rr0.3
if 1e8 < F Initial program 24.8
Simplified24.8
[Start]24.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 [=>]24.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 [=>]24.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}}
\] |
+-commutative [=>]24.8 | \[ \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.8 | \[ \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.8 | \[ \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.8 | \[ \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.8 | \[ \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.8 | \[ \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.8 | \[ \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.8 | \[ \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.2 |
| Cost | 33160 |
| Alternative 2 | |
|---|---|
| Error | 0.2 |
| Cost | 33160 |
| Alternative 3 | |
|---|---|
| Error | 0.2 |
| Cost | 20616 |
| Alternative 4 | |
|---|---|
| Error | 1.1 |
| Cost | 20552 |
| Alternative 5 | |
|---|---|
| Error | 1.1 |
| Cost | 20552 |
| Alternative 6 | |
|---|---|
| Error | 1.1 |
| Cost | 20424 |
| Alternative 7 | |
|---|---|
| Error | 1.1 |
| Cost | 20424 |
| Alternative 8 | |
|---|---|
| Error | 7.5 |
| Cost | 14480 |
| Alternative 9 | |
|---|---|
| Error | 6.1 |
| Cost | 14216 |
| Alternative 10 | |
|---|---|
| Error | 10.7 |
| Cost | 14088 |
| Alternative 11 | |
|---|---|
| Error | 11.0 |
| Cost | 13512 |
| Alternative 12 | |
|---|---|
| Error | 21.2 |
| Cost | 13448 |
| Alternative 13 | |
|---|---|
| Error | 21.2 |
| Cost | 13448 |
| Alternative 14 | |
|---|---|
| Error | 16.2 |
| Cost | 13448 |
| Alternative 15 | |
|---|---|
| Error | 31.0 |
| Cost | 7642 |
| Alternative 16 | |
|---|---|
| Error | 28.2 |
| Cost | 7112 |
| Alternative 17 | |
|---|---|
| Error | 35.7 |
| Cost | 6856 |
| Alternative 18 | |
|---|---|
| Error | 38.1 |
| Cost | 6724 |
| Alternative 19 | |
|---|---|
| Error | 40.1 |
| Cost | 964 |
| Alternative 20 | |
|---|---|
| Error | 40.1 |
| Cost | 584 |
| Alternative 21 | |
|---|---|
| Error | 45.2 |
| Cost | 520 |
| Alternative 22 | |
|---|---|
| Error | 42.7 |
| Cost | 520 |
| Alternative 23 | |
|---|---|
| Error | 51.5 |
| Cost | 324 |
| Alternative 24 | |
|---|---|
| Error | 56.5 |
| Cost | 192 |
herbie shell --seed 2023039
(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))))))