/*
* testelliptic.cpp --- 与えられた k に対し F(x;k), E(x;k) (-1≦x≦1)の値を計算
* g++ -I/opt/local/include testelliptic.cpp
*/
#include <iostream>
#include <iomanip>
using namespace std;
#include <boost/math/special_functions/ellint_1.hpp>
#include <boost/math/special_functions/ellint_2.hpp>
int main(int argc, char **argv)
{
int i, n;
double pi, k, dx, xmin, xmax;
double *x, *y1, *y2;
n = 100;
x = new double [n+1];
y1 = new double [n+1];
y2 = new double [n+1];
pi = 4 * atan(1.0);
if (argc == 2)
k = atof(argv[1]);
else {
cout << "k="; cin >> k;
}
cout << "# k=" << k << endl;
// [-1,1] を100等分
xmin = - 1.0; xmax = 1.0; n = 100;
dx = (xmax - xmin) / n;
for (i = 0; i <= n; i++) {
x[i] = xmin + i * dx;
y1[i] = boost::math::ellint_1(k, asin(x[i]));
y2[i] = boost::math::ellint_2(k, asin(x[i]));
// cout << setiosflags(ios::scientific) << setprecision(8) << x[i] << " " << y1[i] << " " << y2[i] << endl;
cout << setiosflags(ios::fixed) << setprecision(4) << x[i] << " "
<< setprecision(15) << y1[i] << " " << y2[i] << endl;
}
return 0;
}
|