| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 20744 |
(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 -10000000000.0)
(/ (- (/ (tan B) (- (sin B))) x) (tan B))
(if (<= F 36000.0)
(- (/ (/ F (sin B)) (sqrt (fma x 2.0 (fma F F 2.0)))) 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 <= -10000000000.0) {
tmp = ((tan(B) / -sin(B)) - x) / tan(B);
} else if (F <= 36000.0) {
tmp = ((F / sin(B)) / sqrt(fma(x, 2.0, fma(F, F, 2.0)))) - 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 <= -10000000000.0) tmp = Float64(Float64(Float64(tan(B) / Float64(-sin(B))) - x) / tan(B)); elseif (F <= 36000.0) tmp = Float64(Float64(Float64(F / sin(B)) / sqrt(fma(x, 2.0, fma(F, F, 2.0)))) - 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, -10000000000.0], N[(N[(N[(N[Tan[B], $MachinePrecision] / (-N[Sin[B], $MachinePrecision])), $MachinePrecision] - x), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 36000.0], N[(N[(N[(F / N[Sin[B], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(x * 2.0 + N[(F * F + 2.0), $MachinePrecision]), $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 -10000000000:\\
\;\;\;\;\frac{\frac{\tan B}{-\sin B} - x}{\tan B}\\
\mathbf{elif}\;F \leq 36000:\\
\;\;\;\;\frac{\frac{F}{\sin B}}{\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}} - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - t_0\\
\end{array}
if F < -1e10Initial 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
Applied egg-rr12.3
Simplified0.2
[Start]12.3 | \[ \frac{-1 \cdot \left(-\tan B\right) - \sin B \cdot \left(-x\right)}{\sin B \cdot \left(-\tan B\right)}
\] |
|---|---|
distribute-rgt-neg-in [<=]12.3 | \[ \frac{-1 \cdot \left(-\tan B\right) - \sin B \cdot \left(-x\right)}{\color{blue}{-\sin B \cdot \tan B}}
\] |
distribute-lft-neg-in [=>]12.3 | \[ \frac{-1 \cdot \left(-\tan B\right) - \sin B \cdot \left(-x\right)}{\color{blue}{\left(-\sin B\right) \cdot \tan B}}
\] |
div-sub [=>]12.3 | \[ \color{blue}{\frac{-1 \cdot \left(-\tan B\right)}{\left(-\sin B\right) \cdot \tan B} - \frac{\sin B \cdot \left(-x\right)}{\left(-\sin B\right) \cdot \tan B}}
\] |
associate-/r* [=>]12.0 | \[ \color{blue}{\frac{\frac{-1 \cdot \left(-\tan B\right)}{-\sin B}}{\tan B}} - \frac{\sin B \cdot \left(-x\right)}{\left(-\sin B\right) \cdot \tan B}
\] |
mul-1-neg [=>]12.0 | \[ \frac{\frac{\color{blue}{-\left(-\tan B\right)}}{-\sin B}}{\tan B} - \frac{\sin B \cdot \left(-x\right)}{\left(-\sin B\right) \cdot \tan B}
\] |
remove-double-neg [=>]12.0 | \[ \frac{\frac{\color{blue}{\tan B}}{-\sin B}}{\tan B} - \frac{\sin B \cdot \left(-x\right)}{\left(-\sin B\right) \cdot \tan B}
\] |
associate-/r* [=>]0.2 | \[ \frac{\frac{\tan B}{-\sin B}}{\tan B} - \color{blue}{\frac{\frac{\sin B \cdot \left(-x\right)}{-\sin B}}{\tan B}}
\] |
div-sub [<=]0.2 | \[ \color{blue}{\frac{\frac{\tan B}{-\sin B} - \frac{\sin B \cdot \left(-x\right)}{-\sin B}}{\tan B}}
\] |
distribute-rgt-neg-out [=>]0.2 | \[ \frac{\frac{\tan B}{-\sin B} - \frac{\color{blue}{-\sin B \cdot x}}{-\sin B}}{\tan B}
\] |
distribute-lft-neg-out [<=]0.2 | \[ \frac{\frac{\tan B}{-\sin B} - \frac{\color{blue}{\left(-\sin B\right) \cdot x}}{-\sin B}}{\tan B}
\] |
*-commutative [=>]0.2 | \[ \frac{\frac{\tan B}{-\sin B} - \frac{\color{blue}{x \cdot \left(-\sin B\right)}}{-\sin B}}{\tan B}
\] |
associate-/l* [=>]0.2 | \[ \frac{\frac{\tan B}{-\sin B} - \color{blue}{\frac{x}{\frac{-\sin B}{-\sin B}}}}{\tan B}
\] |
*-inverses [=>]0.2 | \[ \frac{\frac{\tan B}{-\sin B} - \frac{x}{\color{blue}{1}}}{\tan B}
\] |
if -1e10 < F < 36000Initial 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-rr21.5
Simplified0.3
[Start]21.5 | \[ \left(e^{\mathsf{log1p}\left(\frac{\frac{F}{\sin B}}{\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}}\right)} - 1\right) - \frac{x}{\tan B}
\] |
|---|---|
expm1-def [=>]7.5 | \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{F}{\sin B}}{\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}}\right)\right)} - \frac{x}{\tan B}
\] |
expm1-log1p [=>]0.3 | \[ \color{blue}{\frac{\frac{F}{\sin B}}{\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}}} - \frac{x}{\tan B}
\] |
if 36000 < F Initial program 25.4
Simplified25.3
[Start]25.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 [=>]25.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 [=>]25.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 [=>]25.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 [=>]25.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 [=>]25.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 [=>]25.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 [=>]25.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 [=>]25.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/ [=>]25.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 [=>]25.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}
\] |
Taylor expanded in F around inf 0.2
Final simplification0.2
| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 20744 |
| Alternative 2 | |
|---|---|
| Error | 0.7 |
| Cost | 20424 |
| Alternative 3 | |
|---|---|
| Error | 0.7 |
| Cost | 20296 |
| Alternative 4 | |
|---|---|
| Error | 0.7 |
| Cost | 20040 |
| Alternative 5 | |
|---|---|
| Error | 0.7 |
| Cost | 20040 |
| Alternative 6 | |
|---|---|
| Error | 7.3 |
| Cost | 19908 |
| Alternative 7 | |
|---|---|
| Error | 7.3 |
| Cost | 14480 |
| Alternative 8 | |
|---|---|
| Error | 7.5 |
| Cost | 14288 |
| Alternative 9 | |
|---|---|
| Error | 10.9 |
| Cost | 13644 |
| Alternative 10 | |
|---|---|
| Error | 25.1 |
| Cost | 13580 |
| Alternative 11 | |
|---|---|
| Error | 25.1 |
| Cost | 13580 |
| Alternative 12 | |
|---|---|
| Error | 25.1 |
| Cost | 13580 |
| Alternative 13 | |
|---|---|
| Error | 18.1 |
| Cost | 13580 |
| Alternative 14 | |
|---|---|
| Error | 29.6 |
| Cost | 8080 |
| Alternative 15 | |
|---|---|
| Error | 30.6 |
| Cost | 7641 |
| Alternative 16 | |
|---|---|
| Error | 35.3 |
| Cost | 6856 |
| Alternative 17 | |
|---|---|
| Error | 37.9 |
| Cost | 6724 |
| Alternative 18 | |
|---|---|
| Error | 42.5 |
| Cost | 584 |
| Alternative 19 | |
|---|---|
| Error | 40.0 |
| Cost | 584 |
| Alternative 20 | |
|---|---|
| Error | 47.7 |
| Cost | 388 |
| Alternative 21 | |
|---|---|
| Error | 56.9 |
| Cost | 192 |
herbie shell --seed 2022354
(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))))))