add numerical recipes library
This commit is contained in:
21
lib/nr/cpp/recipes/bessk1.cpp
Normal file
21
lib/nr/cpp/recipes/bessk1.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <cmath>
|
||||
#include "nr.h"
|
||||
using namespace std;
|
||||
|
||||
DP NR::bessk1(const DP x)
|
||||
{
|
||||
DP y,ans;
|
||||
|
||||
if (x <= 2.0) {
|
||||
y=x*x/4.0;
|
||||
ans=(log(x/2.0)*bessi1(x))+(1.0/x)*(1.0+y*(0.15443144
|
||||
+y*(-0.67278579+y*(-0.18156897+y*(-0.1919402e-1
|
||||
+y*(-0.110404e-2+y*(-0.4686e-4)))))));
|
||||
} else {
|
||||
y=2.0/x;
|
||||
ans=(exp(-x)/sqrt(x))*(1.25331414+y*(0.23498619
|
||||
+y*(-0.3655620e-1+y*(0.1504268e-1+y*(-0.780353e-2
|
||||
+y*(0.325614e-2+y*(-0.68245e-3)))))));
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
Reference in New Issue
Block a user