| Alternative 1 | |
|---|---|
| Accuracy | 89.4% |
| 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 -4.4e+81)
(- (/ -1.0 (sin B)) t_0)
(if (<= F 5000000.0)
(- (* F (/ (sqrt (/ 1.0 (+ 2.0 (* F F)))) (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 <= -4.4e+81) {
tmp = (-1.0 / sin(B)) - t_0;
} else if (F <= 5000000.0) {
tmp = (F * (sqrt((1.0 / (2.0 + (F * F)))) / sin(B))) - t_0;
} else {
tmp = (1.0 / sin(B)) - t_0;
}
return tmp;
}
real(8) function code(f, b, x)
real(8), intent (in) :: f
real(8), intent (in) :: b
real(8), intent (in) :: x
code = -(x * (1.0d0 / tan(b))) + ((f / sin(b)) * ((((f * f) + 2.0d0) + (2.0d0 * x)) ** -(1.0d0 / 2.0d0)))
end function
real(8) function code(f, b, x)
real(8), intent (in) :: f
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = x / tan(b)
if (f <= (-4.4d+81)) then
tmp = ((-1.0d0) / sin(b)) - t_0
else if (f <= 5000000.0d0) then
tmp = (f * (sqrt((1.0d0 / (2.0d0 + (f * f)))) / sin(b))) - t_0
else
tmp = (1.0d0 / sin(b)) - t_0
end if
code = tmp
end function
public static double code(double F, double B, double x) {
return -(x * (1.0 / Math.tan(B))) + ((F / Math.sin(B)) * Math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)));
}
public static double code(double F, double B, double x) {
double t_0 = x / Math.tan(B);
double tmp;
if (F <= -4.4e+81) {
tmp = (-1.0 / Math.sin(B)) - t_0;
} else if (F <= 5000000.0) {
tmp = (F * (Math.sqrt((1.0 / (2.0 + (F * F)))) / Math.sin(B))) - t_0;
} else {
tmp = (1.0 / Math.sin(B)) - t_0;
}
return tmp;
}
def code(F, B, x): return -(x * (1.0 / math.tan(B))) + ((F / math.sin(B)) * math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)))
def code(F, B, x): t_0 = x / math.tan(B) tmp = 0 if F <= -4.4e+81: tmp = (-1.0 / math.sin(B)) - t_0 elif F <= 5000000.0: tmp = (F * (math.sqrt((1.0 / (2.0 + (F * F)))) / math.sin(B))) - t_0 else: tmp = (1.0 / math.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 <= -4.4e+81) tmp = Float64(Float64(-1.0 / sin(B)) - t_0); elseif (F <= 5000000.0) tmp = Float64(Float64(F * Float64(sqrt(Float64(1.0 / Float64(2.0 + Float64(F * F)))) / sin(B))) - t_0); else tmp = Float64(Float64(1.0 / sin(B)) - t_0); end return tmp end
function tmp = code(F, B, x) tmp = -(x * (1.0 / tan(B))) + ((F / sin(B)) * ((((F * F) + 2.0) + (2.0 * x)) ^ -(1.0 / 2.0))); end
function tmp_2 = code(F, B, x) t_0 = x / tan(B); tmp = 0.0; if (F <= -4.4e+81) tmp = (-1.0 / sin(B)) - t_0; elseif (F <= 5000000.0) tmp = (F * (sqrt((1.0 / (2.0 + (F * F)))) / sin(B))) - t_0; else tmp = (1.0 / sin(B)) - t_0; end tmp_2 = 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, -4.4e+81], N[(N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[F, 5000000.0], N[(N[(F * N[(N[Sqrt[N[(1.0 / N[(2.0 + N[(F * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $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 -4.4 \cdot 10^{+81}:\\
\;\;\;\;\frac{-1}{\sin B} - t_0\\
\mathbf{elif}\;F \leq 5000000:\\
\;\;\;\;F \cdot \frac{\sqrt{\frac{1}{2 + F \cdot F}}}{\sin B} - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - t_0\\
\end{array}
Results
if F < -4.39999999999999974e81Initial program 43.3%
Simplified52.4%
[Start]43.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 [=>]43.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 [=>]43.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}}
\] |
associate-*l/ [=>]52.4 | \[ \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/ [<=]52.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 [<=]52.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 F around -inf 87.2%
if -4.39999999999999974e81 < F < 5e6Initial program 90.6%
Simplified91.3%
[Start]90.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 [=>]90.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 [=>]90.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/ [=>]91.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/ [<=]91.1 | \[ \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 [<=]91.1 | \[ \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}
\] |
Applied egg-rr91.2%
[Start]91.3 | \[ 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}
\] |
|---|---|
add-sqr-sqrt [=>]91.2 | \[ F \cdot \frac{{\color{blue}{\left(\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)} \cdot \sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}\right)}}^{-0.5}}{\sin B} - \frac{x}{\tan B}
\] |
unpow-prod-down [=>]91.2 | \[ F \cdot \frac{\color{blue}{{\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}}}{\sin B} - \frac{x}{\tan B}
\] |
Simplified91.2%
[Start]91.2 | \[ F \cdot \frac{{\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}}{\sin B} - \frac{x}{\tan B}
\] |
|---|---|
pow-sqr [=>]91.2 | \[ F \cdot \frac{\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 [=>]91.2 | \[ F \cdot \frac{{\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}
\] |
unpow-1 [=>]91.2 | \[ F \cdot \frac{\color{blue}{\frac{1}{\sqrt{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)}}}}{\sin B} - \frac{x}{\tan B}
\] |
fma-udef [=>]91.2 | \[ F \cdot \frac{\frac{1}{\sqrt{\color{blue}{x \cdot 2 + \mathsf{fma}\left(F, F, 2\right)}}}}{\sin B} - \frac{x}{\tan B}
\] |
*-commutative [<=]91.2 | \[ F \cdot \frac{\frac{1}{\sqrt{\color{blue}{2 \cdot x} + \mathsf{fma}\left(F, F, 2\right)}}}{\sin B} - \frac{x}{\tan B}
\] |
fma-udef [=>]91.2 | \[ F \cdot \frac{\frac{1}{\sqrt{2 \cdot x + \color{blue}{\left(F \cdot F + 2\right)}}}}{\sin B} - \frac{x}{\tan B}
\] |
unpow2 [<=]91.2 | \[ F \cdot \frac{\frac{1}{\sqrt{2 \cdot x + \left(\color{blue}{{F}^{2}} + 2\right)}}}{\sin B} - \frac{x}{\tan B}
\] |
+-commutative [<=]91.2 | \[ F \cdot \frac{\frac{1}{\sqrt{\color{blue}{\left({F}^{2} + 2\right) + 2 \cdot x}}}}{\sin B} - \frac{x}{\tan B}
\] |
associate-+r+ [<=]91.2 | \[ F \cdot \frac{\frac{1}{\sqrt{\color{blue}{{F}^{2} + \left(2 + 2 \cdot x\right)}}}}{\sin B} - \frac{x}{\tan B}
\] |
unpow2 [=>]91.2 | \[ F \cdot \frac{\frac{1}{\sqrt{\color{blue}{F \cdot F} + \left(2 + 2 \cdot x\right)}}}{\sin B} - \frac{x}{\tan B}
\] |
fma-def [=>]91.2 | \[ F \cdot \frac{\frac{1}{\sqrt{\color{blue}{\mathsf{fma}\left(F, F, 2 + 2 \cdot x\right)}}}}{\sin B} - \frac{x}{\tan B}
\] |
+-commutative [<=]91.2 | \[ F \cdot \frac{\frac{1}{\sqrt{\mathsf{fma}\left(F, F, \color{blue}{2 \cdot x + 2}\right)}}}{\sin B} - \frac{x}{\tan B}
\] |
fma-def [=>]91.2 | \[ F \cdot \frac{\frac{1}{\sqrt{\mathsf{fma}\left(F, F, \color{blue}{\mathsf{fma}\left(2, x, 2\right)}\right)}}}{\sin B} - \frac{x}{\tan B}
\] |
Taylor expanded in x around 0 91.2%
Simplified91.2%
[Start]91.2 | \[ F \cdot \frac{\sqrt{\frac{1}{{F}^{2} + 2}}}{\sin B} - \frac{x}{\tan B}
\] |
|---|---|
+-commutative [=>]91.2 | \[ F \cdot \frac{\sqrt{\frac{1}{\color{blue}{2 + {F}^{2}}}}}{\sin B} - \frac{x}{\tan B}
\] |
unpow2 [=>]91.2 | \[ F \cdot \frac{\sqrt{\frac{1}{2 + \color{blue}{F \cdot F}}}}{\sin B} - \frac{x}{\tan B}
\] |
if 5e6 < F Initial program 52.6%
Simplified61.2%
[Start]52.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 [=>]52.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 [=>]52.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/ [=>]61.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/ [<=]61.1 | \[ \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 [<=]61.1 | \[ \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 89.6%
Final simplification89.9%
| Alternative 1 | |
|---|---|
| Accuracy | 89.4% |
| Cost | 20424 |
| Alternative 2 | |
|---|---|
| Accuracy | 89.4% |
| Cost | 20040 |
| Alternative 3 | |
|---|---|
| Accuracy | 89.4% |
| Cost | 20040 |
| Alternative 4 | |
|---|---|
| Accuracy | 80.0% |
| Cost | 14608 |
| Alternative 5 | |
|---|---|
| Accuracy | 80.0% |
| Cost | 14480 |
| Alternative 6 | |
|---|---|
| Accuracy | 80.0% |
| Cost | 14288 |
| Alternative 7 | |
|---|---|
| Accuracy | 79.8% |
| Cost | 14160 |
| Alternative 8 | |
|---|---|
| Accuracy | 75.7% |
| Cost | 13776 |
| Alternative 9 | |
|---|---|
| Accuracy | 55.4% |
| Cost | 13648 |
| Alternative 10 | |
|---|---|
| Accuracy | 61.9% |
| Cost | 13648 |
| Alternative 11 | |
|---|---|
| Accuracy | 61.9% |
| Cost | 13648 |
| Alternative 12 | |
|---|---|
| Accuracy | 62.0% |
| Cost | 13648 |
| Alternative 13 | |
|---|---|
| Accuracy | 69.0% |
| Cost | 13648 |
| Alternative 14 | |
|---|---|
| Accuracy | 53.9% |
| Cost | 7816 |
| Alternative 15 | |
|---|---|
| Accuracy | 53.8% |
| Cost | 7496 |
| Alternative 16 | |
|---|---|
| Accuracy | 47.7% |
| Cost | 7245 |
| Alternative 17 | |
|---|---|
| Accuracy | 51.2% |
| Cost | 7245 |
| Alternative 18 | |
|---|---|
| Accuracy | 52.0% |
| Cost | 7108 |
| Alternative 19 | |
|---|---|
| Accuracy | 41.6% |
| Cost | 6856 |
| Alternative 20 | |
|---|---|
| Accuracy | 37.6% |
| Cost | 6724 |
| Alternative 21 | |
|---|---|
| Accuracy | 33.5% |
| Cost | 968 |
| Alternative 22 | |
|---|---|
| Accuracy | 26.8% |
| Cost | 716 |
| Alternative 23 | |
|---|---|
| Accuracy | 24.2% |
| Cost | 653 |
| Alternative 24 | |
|---|---|
| Accuracy | 33.5% |
| Cost | 584 |
| Alternative 25 | |
|---|---|
| Accuracy | 18.1% |
| Cost | 324 |
| Alternative 26 | |
|---|---|
| Accuracy | 10.6% |
| Cost | 192 |
herbie shell --seed 2023153
(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))))))