| Alternative 1 | |
|---|---|
| Accuracy | 99.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 (/ 1.0 (sin B))) (t_1 (/ x (tan B))))
(if (<= F -1.65e+85)
(- (/ -1.0 (sin B)) t_1)
(if (<= F 40000000.0)
(- (* F (/ t_0 (sqrt (fma F F 2.0)))) t_1)
(- t_0 t_1)))))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 = 1.0 / sin(B);
double t_1 = x / tan(B);
double tmp;
if (F <= -1.65e+85) {
tmp = (-1.0 / sin(B)) - t_1;
} else if (F <= 40000000.0) {
tmp = (F * (t_0 / sqrt(fma(F, F, 2.0)))) - t_1;
} else {
tmp = t_0 - t_1;
}
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(1.0 / sin(B)) t_1 = Float64(x / tan(B)) tmp = 0.0 if (F <= -1.65e+85) tmp = Float64(Float64(-1.0 / sin(B)) - t_1); elseif (F <= 40000000.0) tmp = Float64(Float64(F * Float64(t_0 / sqrt(fma(F, F, 2.0)))) - t_1); else tmp = Float64(t_0 - t_1); 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[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[F, -1.65e+85], N[(N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], If[LessEqual[F, 40000000.0], N[(N[(F * N[(t$95$0 / N[Sqrt[N[(F * F + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], N[(t$95$0 - t$95$1), $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{1}{\sin B}\\
t_1 := \frac{x}{\tan B}\\
\mathbf{if}\;F \leq -1.65 \cdot 10^{+85}:\\
\;\;\;\;\frac{-1}{\sin B} - t_1\\
\mathbf{elif}\;F \leq 40000000:\\
\;\;\;\;F \cdot \frac{t_0}{\sqrt{\mathsf{fma}\left(F, F, 2\right)}} - t_1\\
\mathbf{else}:\\
\;\;\;\;t_0 - t_1\\
\end{array}
if F < -1.65e85Initial program 46.0%
Simplified59.5%
[Start]46.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)}
\] |
|---|---|
+-commutative [=>]46.0 | \[ \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 [=>]46.0 | \[ \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}}
\] |
associate-*l/ [=>]59.5 | \[ \color{blue}{\frac{F \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}}{\sin B}} - x \cdot \frac{1}{\tan B}
\] |
associate-*r/ [<=]59.4 | \[ \color{blue}{F \cdot \frac{{\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}}{\sin B}} - x \cdot \frac{1}{\tan B}
\] |
*-commutative [<=]59.4 | \[ \color{blue}{\frac{{\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}}{\sin B} \cdot F} - x \cdot \frac{1}{\tan B}
\] |
Taylor expanded in F around -inf 99.8%
if -1.65e85 < F < 4e7Initial program 98.6%
Simplified99.5%
[Start]98.6 | \[ \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 [=>]98.6 | \[ \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 [=>]98.6 | \[ \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}}
\] |
associate-*l/ [=>]99.3 | \[ \color{blue}{\frac{F \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}}{\sin B}} - x \cdot \frac{1}{\tan B}
\] |
associate-*r/ [<=]99.3 | \[ \color{blue}{F \cdot \frac{{\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}}{\sin B}} - x \cdot \frac{1}{\tan B}
\] |
*-commutative [<=]99.3 | \[ \color{blue}{\frac{{\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}}{\sin B} \cdot F} - x \cdot \frac{1}{\tan B}
\] |
Taylor expanded in x around 0 99.5%
Simplified99.5%
[Start]99.5 | \[ F \cdot \left(\frac{1}{\sin B} \cdot \sqrt{\frac{1}{{F}^{2} + 2}}\right) - \frac{x}{\tan B}
\] |
|---|---|
*-commutative [=>]99.5 | \[ F \cdot \color{blue}{\left(\sqrt{\frac{1}{{F}^{2} + 2}} \cdot \frac{1}{\sin B}\right)} - \frac{x}{\tan B}
\] |
unpow2 [=>]99.5 | \[ F \cdot \left(\sqrt{\frac{1}{\color{blue}{F \cdot F} + 2}} \cdot \frac{1}{\sin B}\right) - \frac{x}{\tan B}
\] |
fma-udef [<=]99.5 | \[ F \cdot \left(\sqrt{\frac{1}{\color{blue}{\mathsf{fma}\left(F, F, 2\right)}}} \cdot \frac{1}{\sin B}\right) - \frac{x}{\tan B}
\] |
Applied egg-rr99.6%
[Start]99.5 | \[ F \cdot \left(\sqrt{\frac{1}{\mathsf{fma}\left(F, F, 2\right)}} \cdot \frac{1}{\sin B}\right) - \frac{x}{\tan B}
\] |
|---|---|
*-commutative [=>]99.5 | \[ F \cdot \color{blue}{\left(\frac{1}{\sin B} \cdot \sqrt{\frac{1}{\mathsf{fma}\left(F, F, 2\right)}}\right)} - \frac{x}{\tan B}
\] |
sqrt-div [=>]99.5 | \[ F \cdot \left(\frac{1}{\sin B} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\mathsf{fma}\left(F, F, 2\right)}}}\right) - \frac{x}{\tan B}
\] |
metadata-eval [=>]99.5 | \[ F \cdot \left(\frac{1}{\sin B} \cdot \frac{\color{blue}{1}}{\sqrt{\mathsf{fma}\left(F, F, 2\right)}}\right) - \frac{x}{\tan B}
\] |
un-div-inv [=>]99.6 | \[ F \cdot \color{blue}{\frac{\frac{1}{\sin B}}{\sqrt{\mathsf{fma}\left(F, F, 2\right)}}} - \frac{x}{\tan B}
\] |
if 4e7 < F Initial program 58.2%
Simplified75.0%
[Start]58.2 | \[ \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 [=>]58.2 | \[ \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 [=>]58.2 | \[ \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}}
\] |
associate-*l/ [=>]75.1 | \[ \color{blue}{\frac{F \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}}{\sin B}} - x \cdot \frac{1}{\tan B}
\] |
associate-*r/ [<=]74.9 | \[ \color{blue}{F \cdot \frac{{\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}}{\sin B}} - x \cdot \frac{1}{\tan B}
\] |
*-commutative [<=]74.9 | \[ \color{blue}{\frac{{\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}}{\sin B} \cdot F} - x \cdot \frac{1}{\tan B}
\] |
Taylor expanded in F around inf 99.8%
Final simplification99.7%
| Alternative 1 | |
|---|---|
| Accuracy | 99.6% |
| Cost | 26568 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.6% |
| Cost | 20744 |
| Alternative 3 | |
|---|---|
| Accuracy | 99.2% |
| Cost | 20040 |
| Alternative 4 | |
|---|---|
| Accuracy | 88.3% |
| Cost | 14480 |
| Alternative 5 | |
|---|---|
| Accuracy | 85.4% |
| Cost | 14288 |
| Alternative 6 | |
|---|---|
| Accuracy | 85.5% |
| Cost | 14288 |
| Alternative 7 | |
|---|---|
| Accuracy | 85.3% |
| Cost | 14028 |
| Alternative 8 | |
|---|---|
| Accuracy | 66.5% |
| Cost | 13912 |
| Alternative 9 | |
|---|---|
| Accuracy | 66.4% |
| Cost | 13912 |
| Alternative 10 | |
|---|---|
| Accuracy | 85.4% |
| Cost | 13776 |
| Alternative 11 | |
|---|---|
| Accuracy | 77.0% |
| Cost | 13648 |
| Alternative 12 | |
|---|---|
| Accuracy | 64.6% |
| Cost | 8024 |
| Alternative 13 | |
|---|---|
| Accuracy | 60.3% |
| Cost | 7582 |
| Alternative 14 | |
|---|---|
| Accuracy | 60.1% |
| Cost | 7582 |
| Alternative 15 | |
|---|---|
| Accuracy | 63.5% |
| Cost | 7504 |
| Alternative 16 | |
|---|---|
| Accuracy | 63.4% |
| Cost | 7504 |
| Alternative 17 | |
|---|---|
| Accuracy | 47.5% |
| Cost | 6920 |
| Alternative 18 | |
|---|---|
| Accuracy | 46.1% |
| Cost | 6856 |
| Alternative 19 | |
|---|---|
| Accuracy | 41.0% |
| Cost | 6724 |
| Alternative 20 | |
|---|---|
| Accuracy | 33.4% |
| Cost | 584 |
| Alternative 21 | |
|---|---|
| Accuracy | 33.3% |
| Cost | 584 |
| Alternative 22 | |
|---|---|
| Accuracy | 30.3% |
| Cost | 520 |
| Alternative 23 | |
|---|---|
| Accuracy | 19.4% |
| Cost | 324 |
| Alternative 24 | |
|---|---|
| Accuracy | 11.8% |
| Cost | 192 |
herbie shell --seed 2023151
(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))))))