| Alternative 1 | |
|---|---|
| Error | 0.87% |
| Cost | 20424 |
(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 -115000.0)
(- (/ (/ F (- (/ (- -1.0 x) F) F)) (sin B)) t_0)
(if (<= F 200000000.0)
(- (* F (/ (pow (fma x 2.0 (fma F F 2.0)) -0.5) (sin B))) 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 <= -115000.0) {
tmp = ((F / (((-1.0 - x) / F) - F)) / sin(B)) - t_0;
} else if (F <= 200000000.0) {
tmp = (F * (pow(fma(x, 2.0, fma(F, F, 2.0)), -0.5) / sin(B))) - 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 <= -115000.0) tmp = Float64(Float64(Float64(F / Float64(Float64(Float64(-1.0 - x) / F) - F)) / sin(B)) - t_0); elseif (F <= 200000000.0) tmp = Float64(Float64(F * Float64((fma(x, 2.0, fma(F, F, 2.0)) ^ -0.5) / sin(B))) - 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, -115000.0], N[(N[(N[(F / N[(N[(N[(-1.0 - x), $MachinePrecision] / F), $MachinePrecision] - F), $MachinePrecision]), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[F, 200000000.0], N[(N[(F * N[(N[Power[N[(x * 2.0 + N[(F * F + 2.0), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision] / N[Sin[B], $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 -115000:\\
\;\;\;\;\frac{\frac{F}{\frac{-1 - x}{F} - F}}{\sin B} - t_0\\
\mathbf{elif}\;F \leq 200000000:\\
\;\;\;\;F \cdot \frac{{\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{-0.5}}{\sin B} - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - t_0\\
\end{array}
if F < -115000Initial program 41.53
Simplified41.46
[Start]41.53 | \[ \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 [=>]41.53 | \[ \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 [=>]41.53 | \[ \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 [=>]41.53 | \[ \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 [=>]41.53 | \[ \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 [=>]41.53 | \[ \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 [=>]41.53 | \[ \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 [=>]41.53 | \[ \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 [=>]41.53 | \[ \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/ [=>]41.46 | \[ \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 [=>]41.46 | \[ \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-rr31.89
Applied egg-rr32
Simplified31.88
[Start]32 | \[ \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 [=>]31.88 | \[ \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 [=>]31.88 | \[ \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}
\] |
Applied egg-rr32.26
Simplified31.84
[Start]32.26 | \[ \frac{e^{\mathsf{log1p}\left(\frac{F}{\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}}\right)} - 1}{\sin B} - \frac{x}{\tan B}
\] |
|---|---|
expm1-def [=>]32.26 | \[ \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{F}{\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}}\right)\right)}}{\sin B} - \frac{x}{\tan B}
\] |
expm1-log1p [=>]31.84 | \[ \frac{\color{blue}{\frac{F}{\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}}}}{\sin B} - \frac{x}{\tan B}
\] |
Taylor expanded in F around -inf 0.22
Simplified0.22
[Start]0.22 | \[ \frac{\frac{F}{-0.5 \cdot \frac{2 \cdot x + 2}{F} + -1 \cdot F}}{\sin B} - \frac{x}{\tan B}
\] |
|---|---|
mul-1-neg [=>]0.22 | \[ \frac{\frac{F}{-0.5 \cdot \frac{2 \cdot x + 2}{F} + \color{blue}{\left(-F\right)}}}{\sin B} - \frac{x}{\tan B}
\] |
unsub-neg [=>]0.22 | \[ \frac{\frac{F}{\color{blue}{-0.5 \cdot \frac{2 \cdot x + 2}{F} - F}}}{\sin B} - \frac{x}{\tan B}
\] |
+-commutative [=>]0.22 | \[ \frac{\frac{F}{-0.5 \cdot \frac{\color{blue}{2 + 2 \cdot x}}{F} - F}}{\sin B} - \frac{x}{\tan B}
\] |
associate-*r/ [=>]0.22 | \[ \frac{\frac{F}{\color{blue}{\frac{-0.5 \cdot \left(2 + 2 \cdot x\right)}{F}} - F}}{\sin B} - \frac{x}{\tan B}
\] |
distribute-lft-in [=>]0.22 | \[ \frac{\frac{F}{\frac{\color{blue}{-0.5 \cdot 2 + -0.5 \cdot \left(2 \cdot x\right)}}{F} - F}}{\sin B} - \frac{x}{\tan B}
\] |
metadata-eval [=>]0.22 | \[ \frac{\frac{F}{\frac{\color{blue}{-1} + -0.5 \cdot \left(2 \cdot x\right)}{F} - F}}{\sin B} - \frac{x}{\tan B}
\] |
associate-*r* [=>]0.22 | \[ \frac{\frac{F}{\frac{-1 + \color{blue}{\left(-0.5 \cdot 2\right) \cdot x}}{F} - F}}{\sin B} - \frac{x}{\tan B}
\] |
metadata-eval [=>]0.22 | \[ \frac{\frac{F}{\frac{-1 + \color{blue}{-1} \cdot x}{F} - F}}{\sin B} - \frac{x}{\tan B}
\] |
mul-1-neg [=>]0.22 | \[ \frac{\frac{F}{\frac{-1 + \color{blue}{\left(-x\right)}}{F} - F}}{\sin B} - \frac{x}{\tan B}
\] |
if -115000 < F < 2e8Initial program 0.65
Simplified0.45
[Start]0.65 | \[ \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.65 | \[ \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.65 | \[ \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.65 | \[ \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.65 | \[ \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.65 | \[ \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.65 | \[ \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.65 | \[ \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.65 | \[ \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.45 | \[ \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.45 | \[ \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-rr33.86
Simplified0.45
[Start]33.86 | \[ \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 [=>]11.63 | \[ \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 [=>]0.45 | \[ \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}
\] |
if 2e8 < F Initial program 38.59
Simplified38.51
[Start]38.59 | \[ \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 [=>]38.59 | \[ \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 [=>]38.59 | \[ \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 [=>]38.59 | \[ \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 [=>]38.59 | \[ \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 [=>]38.59 | \[ \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 [=>]38.59 | \[ \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 [=>]38.59 | \[ \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 [=>]38.59 | \[ \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/ [=>]38.51 | \[ \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 [=>]38.51 | \[ \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.24
Final simplification0.33
| Alternative 1 | |
|---|---|
| Error | 0.87% |
| Cost | 20424 |
| Alternative 2 | |
|---|---|
| Error | 0.87% |
| Cost | 20424 |
| Alternative 3 | |
|---|---|
| Error | 0.87% |
| Cost | 20296 |
| Alternative 4 | |
|---|---|
| Error | 13.01% |
| Cost | 14545 |
| Alternative 5 | |
|---|---|
| Error | 9.19% |
| Cost | 14344 |
| Alternative 6 | |
|---|---|
| Error | 16.4% |
| Cost | 14148 |
| Alternative 7 | |
|---|---|
| Error | 17.12% |
| Cost | 13892 |
| Alternative 8 | |
|---|---|
| Error | 17.42% |
| Cost | 13512 |
| Alternative 9 | |
|---|---|
| Error | 40.6% |
| Cost | 13448 |
| Alternative 10 | |
|---|---|
| Error | 40.6% |
| Cost | 13448 |
| Alternative 11 | |
|---|---|
| Error | 29.1% |
| Cost | 13448 |
| Alternative 12 | |
|---|---|
| Error | 50.25% |
| Cost | 7892 |
| Alternative 13 | |
|---|---|
| Error | 50.22% |
| Cost | 7764 |
| Alternative 14 | |
|---|---|
| Error | 52.96% |
| Cost | 7640 |
| Alternative 15 | |
|---|---|
| Error | 52.13% |
| Cost | 7632 |
| Alternative 16 | |
|---|---|
| Error | 57.33% |
| Cost | 6920 |
| Alternative 17 | |
|---|---|
| Error | 58.66% |
| Cost | 6724 |
| Alternative 18 | |
|---|---|
| Error | 62.58% |
| Cost | 584 |
| Alternative 19 | |
|---|---|
| Error | 76.16% |
| Cost | 521 |
| Alternative 20 | |
|---|---|
| Error | 70.4% |
| Cost | 452 |
| Alternative 21 | |
|---|---|
| Error | 89.19% |
| Cost | 192 |
herbie shell --seed 2023125
(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))))))