| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 26568 |
(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 -8e+23)
(- (/ -1.0 (sin B)) t_0)
(if (<= F 15000.0)
(- (/ (/ F (sin B)) (sqrt (fma F F 2.0))) t_0)
(- (/ (+ 1.0 (/ -1.0 (* F F))) (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 <= -8e+23) {
tmp = (-1.0 / sin(B)) - t_0;
} else if (F <= 15000.0) {
tmp = ((F / sin(B)) / sqrt(fma(F, F, 2.0))) - t_0;
} else {
tmp = ((1.0 + (-1.0 / (F * F))) / 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 <= -8e+23) tmp = Float64(Float64(-1.0 / sin(B)) - t_0); elseif (F <= 15000.0) tmp = Float64(Float64(Float64(F / sin(B)) / sqrt(fma(F, F, 2.0))) - t_0); else tmp = Float64(Float64(Float64(1.0 + Float64(-1.0 / Float64(F * F))) / 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, -8e+23], N[(N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[F, 15000.0], N[(N[(N[(F / N[Sin[B], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(F * F + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[(1.0 + N[(-1.0 / N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 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 -8 \cdot 10^{+23}:\\
\;\;\;\;\frac{-1}{\sin B} - t_0\\
\mathbf{elif}\;F \leq 15000:\\
\;\;\;\;\frac{\frac{F}{\sin B}}{\sqrt{\mathsf{fma}\left(F, F, 2\right)}} - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \frac{-1}{F \cdot F}}{\sin B} - t_0\\
\end{array}
if F < -7.9999999999999993e23Initial program 26.1
Simplified26.1
[Start]26.1 | \[ \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 [=>]26.1 | \[ \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 [=>]26.1 | \[ \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 [=>]26.1 | \[ \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 [=>]26.1 | \[ \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 [=>]26.1 | \[ \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 [=>]26.1 | \[ \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 [=>]26.1 | \[ \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 [=>]26.1 | \[ \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/ [=>]26.1 | \[ \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 [=>]26.1 | \[ \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 -7.9999999999999993e23 < F < 15000Initial program 0.5
Simplified0.4
[Start]0.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)}
\] |
|---|---|
+-commutative [=>]0.5 | \[ \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.5 | \[ \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.5 | \[ \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.5 | \[ \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.5 | \[ \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.5 | \[ \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.5 | \[ \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.5 | \[ \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.4 | \[ \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.4 | \[ \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
Simplified0.3
[Start]0.3 | \[ \frac{F \cdot \left({\left(\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}\right)}^{-0.5} \cdot {\left(\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}\right)}^{-0.5}\right)}{\sin B} - \frac{x}{\tan B}
\] |
|---|---|
pow-sqr [=>]0.3 | \[ \frac{F \cdot \color{blue}{{\left(\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}\right)}^{\left(2 \cdot -0.5\right)}}}{\sin B} - \frac{x}{\tan B}
\] |
metadata-eval [=>]0.3 | \[ \frac{F \cdot {\left(\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}\right)}^{\color{blue}{-1}}}{\sin B} - \frac{x}{\tan B}
\] |
Taylor expanded in x around 0 0.4
Simplified0.4
[Start]0.4 | \[ \frac{F \cdot {\left(\sqrt{{F}^{2} + 2}\right)}^{-1}}{\sin B} - \frac{x}{\tan B}
\] |
|---|---|
unpow2 [=>]0.4 | \[ \frac{F \cdot {\left(\sqrt{\color{blue}{F \cdot F} + 2}\right)}^{-1}}{\sin B} - \frac{x}{\tan B}
\] |
fma-udef [<=]0.4 | \[ \frac{F \cdot {\left(\sqrt{\color{blue}{\mathsf{fma}\left(F, F, 2\right)}}\right)}^{-1}}{\sin B} - \frac{x}{\tan B}
\] |
Applied egg-rr22.4
Simplified0.4
[Start]22.4 | \[ \left(e^{\mathsf{log1p}\left(\frac{\frac{F}{\sin B}}{\sqrt{\mathsf{fma}\left(F, F, 2\right)}}\right)} - 1\right) - \frac{x}{\tan B}
\] |
|---|---|
expm1-def [=>]9.1 | \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{F}{\sin B}}{\sqrt{\mathsf{fma}\left(F, F, 2\right)}}\right)\right)} - \frac{x}{\tan B}
\] |
expm1-log1p [=>]0.4 | \[ \color{blue}{\frac{\frac{F}{\sin B}}{\sqrt{\mathsf{fma}\left(F, F, 2\right)}}} - \frac{x}{\tan B}
\] |
if 15000 < F Initial program 26.3
Simplified26.3
[Start]26.3 | \[ \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 [=>]26.3 | \[ \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 [=>]26.3 | \[ \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 [=>]26.3 | \[ \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 [=>]26.3 | \[ \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 [=>]26.3 | \[ \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 [=>]26.3 | \[ \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 [=>]26.3 | \[ \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 [=>]26.3 | \[ \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/ [=>]26.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 [=>]26.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-rr19.9
Applied egg-rr20.0
Simplified19.9
[Start]20.0 | \[ \frac{F \cdot \left({\left(\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}\right)}^{-0.5} \cdot {\left(\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}\right)}^{-0.5}\right)}{\sin B} - \frac{x}{\tan B}
\] |
|---|---|
pow-sqr [=>]19.9 | \[ \frac{F \cdot \color{blue}{{\left(\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}\right)}^{\left(2 \cdot -0.5\right)}}}{\sin B} - \frac{x}{\tan B}
\] |
metadata-eval [=>]19.9 | \[ \frac{F \cdot {\left(\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}\right)}^{\color{blue}{-1}}}{\sin B} - \frac{x}{\tan B}
\] |
Taylor expanded in x around 0 19.9
Simplified19.9
[Start]19.9 | \[ \frac{F \cdot {\left(\sqrt{{F}^{2} + 2}\right)}^{-1}}{\sin B} - \frac{x}{\tan B}
\] |
|---|---|
unpow2 [=>]19.9 | \[ \frac{F \cdot {\left(\sqrt{\color{blue}{F \cdot F} + 2}\right)}^{-1}}{\sin B} - \frac{x}{\tan B}
\] |
fma-udef [<=]19.9 | \[ \frac{F \cdot {\left(\sqrt{\color{blue}{\mathsf{fma}\left(F, F, 2\right)}}\right)}^{-1}}{\sin B} - \frac{x}{\tan B}
\] |
Taylor expanded in F around inf 0.1
Simplified0.1
[Start]0.1 | \[ \frac{1 - \frac{1}{{F}^{2}}}{\sin B} - \frac{x}{\tan B}
\] |
|---|---|
unpow2 [=>]0.1 | \[ \frac{1 - \frac{1}{\color{blue}{F \cdot F}}}{\sin B} - \frac{x}{\tan B}
\] |
Final simplification0.3
| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 26568 |
| Alternative 2 | |
|---|---|
| Error | 0.6 |
| Cost | 26568 |
| Alternative 3 | |
|---|---|
| Error | 0.3 |
| Cost | 20744 |
| Alternative 4 | |
|---|---|
| Error | 0.6 |
| Cost | 20424 |
| Alternative 5 | |
|---|---|
| Error | 0.6 |
| Cost | 20424 |
| Alternative 6 | |
|---|---|
| Error | 0.6 |
| Cost | 20424 |
| Alternative 7 | |
|---|---|
| Error | 0.6 |
| Cost | 20168 |
| Alternative 8 | |
|---|---|
| Error | 0.6 |
| Cost | 20040 |
| Alternative 9 | |
|---|---|
| Error | 5.5 |
| Cost | 14476 |
| Alternative 10 | |
|---|---|
| Error | 5.5 |
| Cost | 14216 |
| Alternative 11 | |
|---|---|
| Error | 5.5 |
| Cost | 14028 |
| Alternative 12 | |
|---|---|
| Error | 22.4 |
| Cost | 13977 |
| Alternative 13 | |
|---|---|
| Error | 5.6 |
| Cost | 13896 |
| Alternative 14 | |
|---|---|
| Error | 17.7 |
| Cost | 13845 |
| Alternative 15 | |
|---|---|
| Error | 5.7 |
| Cost | 13764 |
| Alternative 16 | |
|---|---|
| Error | 10.5 |
| Cost | 13644 |
| Alternative 17 | |
|---|---|
| Error | 5.7 |
| Cost | 13640 |
| Alternative 18 | |
|---|---|
| Error | 26.3 |
| Cost | 7892 |
| Alternative 19 | |
|---|---|
| Error | 29.1 |
| Cost | 7640 |
| Alternative 20 | |
|---|---|
| Error | 28.5 |
| Cost | 7632 |
| Alternative 21 | |
|---|---|
| Error | 28.0 |
| Cost | 7632 |
| Alternative 22 | |
|---|---|
| Error | 29.1 |
| Cost | 7508 |
| Alternative 23 | |
|---|---|
| Error | 35.0 |
| Cost | 7048 |
| Alternative 24 | |
|---|---|
| Error | 33.9 |
| Cost | 6920 |
| Alternative 25 | |
|---|---|
| Error | 35.0 |
| Cost | 6856 |
| Alternative 26 | |
|---|---|
| Error | 37.6 |
| Cost | 6724 |
| Alternative 27 | |
|---|---|
| Error | 40.3 |
| Cost | 584 |
| Alternative 28 | |
|---|---|
| Error | 45.3 |
| Cost | 452 |
| Alternative 29 | |
|---|---|
| Error | 47.6 |
| Cost | 388 |
| Alternative 30 | |
|---|---|
| Error | 56.9 |
| Cost | 192 |
herbie shell --seed 2023083
(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))))))