1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449
|
// Copyright John Maddock 2015
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
// Comparison of finding roots using TOMS748, Newton-Raphson, Halley & Schroder algorithms.
// Note that this file contains Quickbook mark-up as well as code
// and comments, don't change any of the special comment mark-ups!
// This program also writes files in Quickbook tables mark-up format.
#include <boost/cstdlib.hpp>
#include <boost/config.hpp>
#include <boost/array.hpp>
#include <boost/math/tools/roots.hpp>
#include <boost/math/special_functions/ellint_1.hpp>
#include <boost/math/special_functions/ellint_2.hpp>
template <class T>
struct cbrt_functor_noderiv
{
// cube root of x using only function - no derivatives.
cbrt_functor_noderiv(T const& to_find_root_of) : a(to_find_root_of)
{ /* Constructor just stores value a to find root of. */
}
T operator()(T const& x)
{
T fx = x*x*x - a; // Difference (estimate x^3 - a).
return fx;
}
private:
T a; // to be 'cube_rooted'.
};
//] [/root_finding_noderiv_1
template <class T>
std::uintmax_t cbrt_noderiv(T x, T guess)
{
// return cube root of x using bracket_and_solve (no derivatives).
using namespace std; // Help ADL of std functions.
using namespace boost::math::tools; // For bracket_and_solve_root.
T factor = 2; // How big steps to take when searching.
const std::uintmax_t maxit = 20; // Limit to maximum iterations.
std::uintmax_t it = maxit; // Initially our chosen max iterations, but updated with actual.
bool is_rising = true; // So if result if guess^3 is too low, then try increasing guess.
int digits = std::numeric_limits<T>::digits; // Maximum possible binary digits accuracy for type T.
// Some fraction of digits is used to control how accurate to try to make the result.
int get_digits = digits - 3; // We have to have a non-zero interval at each step, so
// maximum accuracy is digits - 1. But we also have to
// allow for inaccuracy in f(x), otherwise the last few
// iterations just thrash around.
eps_tolerance<T> tol(get_digits); // Set the tolerance.
bracket_and_solve_root(cbrt_functor_noderiv<T>(x), guess, factor, is_rising, tol, it);
return it;
}
template <class T>
struct cbrt_functor_deriv
{ // Functor also returning 1st derivative.
cbrt_functor_deriv(T const& to_find_root_of) : a(to_find_root_of)
{ // Constructor stores value a to find root of,
// for example: calling cbrt_functor_deriv<T>(a) to use to get cube root of a.
}
std::pair<T, T> operator()(T const& x)
{
// Return both f(x) and f'(x).
T fx = x*x*x - a; // Difference (estimate x^3 - value).
T dx = 3 * x*x; // 1st derivative = 3x^2.
return std::make_pair(fx, dx); // 'return' both fx and dx.
}
private:
T a; // Store value to be 'cube_rooted'.
};
template <class T>
std::uintmax_t cbrt_deriv(T x, T guess)
{
// return cube root of x using 1st derivative and Newton_Raphson.
using namespace boost::math::tools;
T min = guess / 100; // We don't really know what this should be!
T max = guess * 100; // We don't really know what this should be!
const int digits = std::numeric_limits<T>::digits; // Maximum possible binary digits accuracy for type T.
int get_digits = static_cast<int>(digits * 0.6); // Accuracy doubles with each step, so stop when we have
// just over half the digits correct.
const std::uintmax_t maxit = 20;
std::uintmax_t it = maxit;
newton_raphson_iterate(cbrt_functor_deriv<T>(x), guess, min, max, get_digits, it);
return it;
}
template <class T>
struct cbrt_functor_2deriv
{
// Functor returning both 1st and 2nd derivatives.
cbrt_functor_2deriv(T const& to_find_root_of) : a(to_find_root_of)
{ // Constructor stores value a to find root of, for example:
// calling cbrt_functor_2deriv<T>(x) to get cube root of x,
}
std::tuple<T, T, T> operator()(T const& x)
{
// Return both f(x) and f'(x) and f''(x).
T fx = x*x*x - a; // Difference (estimate x^3 - value).
T dx = 3 * x*x; // 1st derivative = 3x^2.
T d2x = 6 * x; // 2nd derivative = 6x.
return std::make_tuple(fx, dx, d2x); // 'return' fx, dx and d2x.
}
private:
T a; // to be 'cube_rooted'.
};
template <class T>
std::uintmax_t cbrt_2deriv(T x, T guess)
{
// return cube root of x using 1st and 2nd derivatives and Halley.
//using namespace std; // Help ADL of std functions.
using namespace boost::math::tools;
T min = guess / 100; // We don't really know what this should be!
T max = guess * 100; // We don't really know what this should be!
const int digits = std::numeric_limits<T>::digits; // Maximum possible binary digits accuracy for type T.
// digits used to control how accurate to try to make the result.
int get_digits = static_cast<int>(digits * 0.4); // Accuracy triples with each step, so stop when just
// over one third of the digits are correct.
std::uintmax_t maxit = 20;
halley_iterate(cbrt_functor_2deriv<T>(x), guess, min, max, get_digits, maxit);
return maxit;
}
template <class T>
std::uintmax_t cbrt_2deriv_s(T x, T guess)
{
// return cube root of x using 1st and 2nd derivatives and Halley.
//using namespace std; // Help ADL of std functions.
using namespace boost::math::tools;
T min = guess / 100; // We don't really know what this should be!
T max = guess * 100; // We don't really know what this should be!
const int digits = std::numeric_limits<T>::digits; // Maximum possible binary digits accuracy for type T.
// digits used to control how accurate to try to make the result.
int get_digits = static_cast<int>(digits * 0.4); // Accuracy triples with each step, so stop when just
// over one third of the digits are correct.
std::uintmax_t maxit = 20;
schroder_iterate(cbrt_functor_2deriv<T>(x), guess, min, max, get_digits, maxit);
return maxit;
}
template <typename T = double>
struct elliptic_root_functor_noderiv
{
elliptic_root_functor_noderiv(T const& arc, T const& radius) : m_arc(arc), m_radius(radius)
{ // Constructor just stores value a to find root of.
}
T operator()(T const& x)
{
// return the difference between required arc-length, and the calculated arc-length for an
// ellipse with radii m_radius and x:
T a = (std::max)(m_radius, x);
T b = (std::min)(m_radius, x);
T k = sqrt(1 - b * b / (a * a));
return 4 * a * boost::math::ellint_2(k) - m_arc;
}
private:
T m_arc; // length of arc.
T m_radius; // one of the two radii of the ellipse
}; // template <class T> struct elliptic_root_functor_noderiv
template <class T = double>
std::uintmax_t elliptic_root_noderiv(T radius, T arc, T guess)
{ // return the other radius of an ellipse, given one radii and the arc-length
using namespace std; // Help ADL of std functions.
using namespace boost::math::tools; // For bracket_and_solve_root.
T factor = 2; // How big steps to take when searching.
const std::uintmax_t maxit = 50; // Limit to maximum iterations.
std::uintmax_t it = maxit; // Initially our chosen max iterations, but updated with actual.
bool is_rising = true; // arc-length increases if one radii increases, so function is rising
// Define a termination condition, stop when nearly all digits are correct, but allow for
// the fact that we are returning a range, and must have some inaccuracy in the elliptic integral:
eps_tolerance<T> tol(std::numeric_limits<T>::digits - 2);
// Call bracket_and_solve_root to find the solution, note that this is a rising function:
bracket_and_solve_root(elliptic_root_functor_noderiv<T>(arc, radius), guess, factor, is_rising, tol, it);
return it;
}
template <class T = double>
struct elliptic_root_functor_1deriv
{ // Functor also returning 1st derivative.
static_assert(boost::is_integral<T>::value == false, "Only floating-point type types can be used!");
elliptic_root_functor_1deriv(T const& arc, T const& radius) : m_arc(arc), m_radius(radius)
{ // Constructor just stores value a to find root of.
}
std::pair<T, T> operator()(T const& x)
{
// Return the difference between required arc-length, and the calculated arc-length for an
// ellipse with radii m_radius and x, plus it's derivative.
// See http://www.wolframalpha.com/input/?i=d%2Fda+[4+*+a+*+EllipticE%281+-+b^2%2Fa^2%29]
// We require two elliptic integral calls, but from these we can calculate both
// the function and it's derivative:
T a = (std::max)(m_radius, x);
T b = (std::min)(m_radius, x);
T a2 = a * a;
T b2 = b * b;
T k = sqrt(1 - b2 / a2);
T Ek = boost::math::ellint_2(k);
T Kk = boost::math::ellint_1(k);
T fx = 4 * a * Ek - m_arc;
T dfx = 4 * (a2 * Ek - b2 * Kk) / (a2 - b2);
return std::make_pair(fx, dfx);
}
private:
T m_arc; // length of arc.
T m_radius; // one of the two radii of the ellipse
}; // struct elliptic_root__functor_1deriv
template <class T = double>
std::uintmax_t elliptic_root_1deriv(T radius, T arc, T guess)
{
using namespace std; // Help ADL of std functions.
using namespace boost::math::tools; // For newton_raphson_iterate.
static_assert(boost::is_integral<T>::value == false, "Only floating-point type types can be used!");
T min = 0; // Minimum possible value is zero.
T max = arc; // Maximum possible value is the arc length.
// Accuracy doubles at each step, so stop when just over half of the digits are
// correct, and rely on that step to polish off the remainder:
int get_digits = static_cast<int>(std::numeric_limits<T>::digits * 0.6);
const std::uintmax_t maxit = 20;
std::uintmax_t it = maxit;
newton_raphson_iterate(elliptic_root_functor_1deriv<T>(arc, radius), guess, min, max, get_digits, it);
return it;
}
template <class T = double>
struct elliptic_root_functor_2deriv
{ // Functor returning both 1st and 2nd derivatives.
static_assert(boost::is_integral<T>::value == false, "Only floating-point type types can be used!");
elliptic_root_functor_2deriv(T const& arc, T const& radius) : m_arc(arc), m_radius(radius) {}
std::tuple<T, T, T> operator()(T const& x)
{
// Return the difference between required arc-length, and the calculated arc-length for an
// ellipse with radii m_radius and x, plus it's derivative.
// See http://www.wolframalpha.com/input/?i=d^2%2Fda^2+[4+*+a+*+EllipticE%281+-+b^2%2Fa^2%29]
// for the second derivative.
T a = (std::max)(m_radius, x);
T b = (std::min)(m_radius, x);
T a2 = a * a;
T b2 = b * b;
T k = sqrt(1 - b2 / a2);
T Ek = boost::math::ellint_2(k);
T Kk = boost::math::ellint_1(k);
T fx = 4 * a * Ek - m_arc;
T dfx = 4 * (a2 * Ek - b2 * Kk) / (a2 - b2);
T dfx2 = 4 * b2 * ((a2 + b2) * Kk - 2 * a2 * Ek) / (a * (a2 - b2) * (a2 - b2));
return std::make_tuple(fx, dfx, dfx2);
}
private:
T m_arc; // length of arc.
T m_radius; // one of the two radii of the ellipse
};
template <class T = double>
std::uintmax_t elliptic_root_2deriv(T radius, T arc, T guess)
{
using namespace std; // Help ADL of std functions.
using namespace boost::math::tools; // For halley_iterate.
static_assert(boost::is_integral<T>::value == false, "Only floating-point type types can be used!");
T min = 0; // Minimum possible value is zero.
T max = arc; // radius can't be larger than the arc length.
// Accuracy triples at each step, so stop when just over one-third of the digits
// are correct, and the last iteration will polish off the remaining digits:
int get_digits = static_cast<int>(std::numeric_limits<T>::digits * 0.4);
const std::uintmax_t maxit = 20;
std::uintmax_t it = maxit;
halley_iterate(elliptic_root_functor_2deriv<T>(arc, radius), guess, min, max, get_digits, it);
return it;
} // nth_2deriv Halley
//]
// Using 1st and 2nd derivatives using Schroder algorithm.
template <class T = double>
std::uintmax_t elliptic_root_2deriv_s(T radius, T arc, T guess)
{ // return nth root of x using 1st and 2nd derivatives and Schroder.
using namespace std; // Help ADL of std functions.
using namespace boost::math::tools; // For schroder_iterate.
static_assert(boost::is_integral<T>::value == false, "Only floating-point type types can be used!");
T min = 0; // Minimum possible value is zero.
T max = arc; // radius can't be larger than the arc length.
int digits = std::numeric_limits<T>::digits; // Maximum possible binary digits accuracy for type T.
int get_digits = static_cast<int>(digits * 0.4);
const std::uintmax_t maxit = 20;
std::uintmax_t it = maxit;
schroder_iterate(elliptic_root_functor_2deriv<T>(arc, radius), guess, min, max, get_digits, it);
return it;
} // T elliptic_root_2deriv_s Schroder
int main()
{
try
{
double to_root = 500;
double answer = 7.93700525984;
std::cout << "[table\n"
<< "[[Initial Guess=][-500% ([approx]1.323)][-100% ([approx]3.97)][-50% ([approx]3.96)][-20% ([approx]6.35)][-10% ([approx]7.14)][-5% ([approx]7.54)]"
"[5% ([approx]8.33)][10% ([approx]8.73)][20% ([approx]9.52)][50% ([approx]11.91)][100% ([approx]15.87)][500 ([approx]47.6)]]\n";
std::cout << "[[bracket_and_solve_root]["
<< cbrt_noderiv(to_root, answer / 6)
<< "][" << cbrt_noderiv(to_root, answer / 2)
<< "][" << cbrt_noderiv(to_root, answer - answer * 0.5)
<< "][" << cbrt_noderiv(to_root, answer - answer * 0.2)
<< "][" << cbrt_noderiv(to_root, answer - answer * 0.1)
<< "][" << cbrt_noderiv(to_root, answer - answer * 0.05)
<< "][" << cbrt_noderiv(to_root, answer + answer * 0.05)
<< "][" << cbrt_noderiv(to_root, answer + answer * 0.1)
<< "][" << cbrt_noderiv(to_root, answer + answer * 0.2)
<< "][" << cbrt_noderiv(to_root, answer + answer * 0.5)
<< "][" << cbrt_noderiv(to_root, answer + answer)
<< "][" << cbrt_noderiv(to_root, answer + answer * 5) << "]]\n";
std::cout << "[[newton_iterate]["
<< cbrt_deriv(to_root, answer / 6)
<< "][" << cbrt_deriv(to_root, answer / 2)
<< "][" << cbrt_deriv(to_root, answer - answer * 0.5)
<< "][" << cbrt_deriv(to_root, answer - answer * 0.2)
<< "][" << cbrt_deriv(to_root, answer - answer * 0.1)
<< "][" << cbrt_deriv(to_root, answer - answer * 0.05)
<< "][" << cbrt_deriv(to_root, answer + answer * 0.05)
<< "][" << cbrt_deriv(to_root, answer + answer * 0.1)
<< "][" << cbrt_deriv(to_root, answer + answer * 0.2)
<< "][" << cbrt_deriv(to_root, answer + answer * 0.5)
<< "][" << cbrt_deriv(to_root, answer + answer)
<< "][" << cbrt_deriv(to_root, answer + answer * 5) << "]]\n";
std::cout << "[[halley_iterate]["
<< cbrt_2deriv(to_root, answer / 6)
<< "][" << cbrt_2deriv(to_root, answer / 2)
<< "][" << cbrt_2deriv(to_root, answer - answer * 0.5)
<< "][" << cbrt_2deriv(to_root, answer - answer * 0.2)
<< "][" << cbrt_2deriv(to_root, answer - answer * 0.1)
<< "][" << cbrt_2deriv(to_root, answer - answer * 0.05)
<< "][" << cbrt_2deriv(to_root, answer + answer * 0.05)
<< "][" << cbrt_2deriv(to_root, answer + answer * 0.1)
<< "][" << cbrt_2deriv(to_root, answer + answer * 0.2)
<< "][" << cbrt_2deriv(to_root, answer + answer * 0.5)
<< "][" << cbrt_2deriv(to_root, answer + answer)
<< "][" << cbrt_2deriv(to_root, answer + answer * 5) << "]]\n";
std::cout << "[[schr'''ö'''der_iterate]["
<< cbrt_2deriv_s(to_root, answer / 6)
<< "][" << cbrt_2deriv_s(to_root, answer / 2)
<< "][" << cbrt_2deriv_s(to_root, answer - answer * 0.5)
<< "][" << cbrt_2deriv_s(to_root, answer - answer * 0.2)
<< "][" << cbrt_2deriv_s(to_root, answer - answer * 0.1)
<< "][" << cbrt_2deriv_s(to_root, answer - answer * 0.05)
<< "][" << cbrt_2deriv_s(to_root, answer + answer * 0.05)
<< "][" << cbrt_2deriv_s(to_root, answer + answer * 0.1)
<< "][" << cbrt_2deriv_s(to_root, answer + answer * 0.2)
<< "][" << cbrt_2deriv_s(to_root, answer + answer * 0.5)
<< "][" << cbrt_2deriv_s(to_root, answer + answer)
<< "][" << cbrt_2deriv_s(to_root, answer + answer * 5) << "]]\n]\n\n";
double radius_a = 10;
double arc_length = 500;
double radius_b = 123.6216507967705;
std::cout << std::setprecision(4) << "[table\n"
<< "[[Initial Guess=][-500% ([approx]" << radius_b / 6 << ")][-100% ([approx]" << radius_b / 2 << ")][-50% ([approx]"
<< radius_b - radius_b * 0.5 << ")][-20% ([approx]" << radius_b - radius_b * 0.2 << ")][-10% ([approx]" << radius_b - radius_b * 0.1 << ")][-5% ([approx]" << radius_b - radius_b * 0.05 << ")]"
"[5% ([approx]" << radius_b + radius_b * 0.05 << ")][10% ([approx]" << radius_b + radius_b * 0.1 << ")][20% ([approx]" << radius_b + radius_b * 0.2 << ")][50% ([approx]" << radius_b + radius_b * 0.5
<< ")][100% ([approx]" << radius_b + radius_b << ")][500 ([approx]" << radius_b + radius_b * 5 << ")]]\n";
std::cout << "[[bracket_and_solve_root]["
<< elliptic_root_noderiv(radius_a, arc_length, radius_b / 6)
<< "][" << elliptic_root_noderiv(radius_a, arc_length, radius_b / 2)
<< "][" << elliptic_root_noderiv(radius_a, arc_length, radius_b - radius_b * 0.5)
<< "][" << elliptic_root_noderiv(radius_a, arc_length, radius_b - radius_b * 0.2)
<< "][" << elliptic_root_noderiv(radius_a, arc_length, radius_b - radius_b * 0.1)
<< "][" << elliptic_root_noderiv(radius_a, arc_length, radius_b - radius_b * 0.05)
<< "][" << elliptic_root_noderiv(radius_a, arc_length, radius_b + radius_b * 0.05)
<< "][" << elliptic_root_noderiv(radius_a, arc_length, radius_b + radius_b * 0.1)
<< "][" << elliptic_root_noderiv(radius_a, arc_length, radius_b + radius_b * 0.2)
<< "][" << elliptic_root_noderiv(radius_a, arc_length, radius_b + radius_b * 0.5)
<< "][" << elliptic_root_noderiv(radius_a, arc_length, radius_b + radius_b)
<< "][" << elliptic_root_noderiv(radius_a, arc_length, radius_b + radius_b * 5) << "]]\n";
std::cout << "[[newton_iterate]["
<< elliptic_root_1deriv(radius_a, arc_length, radius_b / 6)
<< "][" << elliptic_root_1deriv(radius_a, arc_length, radius_b / 2)
<< "][" << elliptic_root_1deriv(radius_a, arc_length, radius_b - radius_b * 0.5)
<< "][" << elliptic_root_1deriv(radius_a, arc_length, radius_b - radius_b * 0.2)
<< "][" << elliptic_root_1deriv(radius_a, arc_length, radius_b - radius_b * 0.1)
<< "][" << elliptic_root_1deriv(radius_a, arc_length, radius_b - radius_b * 0.05)
<< "][" << elliptic_root_1deriv(radius_a, arc_length, radius_b + radius_b * 0.05)
<< "][" << elliptic_root_1deriv(radius_a, arc_length, radius_b + radius_b * 0.1)
<< "][" << elliptic_root_1deriv(radius_a, arc_length, radius_b + radius_b * 0.2)
<< "][" << elliptic_root_1deriv(radius_a, arc_length, radius_b + radius_b * 0.5)
<< "][" << elliptic_root_1deriv(radius_a, arc_length, radius_b + radius_b)
<< "][" << elliptic_root_1deriv(radius_a, arc_length, radius_b + radius_b * 5) << "]]\n";
std::cout << "[[halley_iterate]["
<< elliptic_root_2deriv(radius_a, arc_length, radius_b / 6)
<< "][" << elliptic_root_2deriv(radius_a, arc_length, radius_b / 2)
<< "][" << elliptic_root_2deriv(radius_a, arc_length, radius_b - radius_b * 0.5)
<< "][" << elliptic_root_2deriv(radius_a, arc_length, radius_b - radius_b * 0.2)
<< "][" << elliptic_root_2deriv(radius_a, arc_length, radius_b - radius_b * 0.1)
<< "][" << elliptic_root_2deriv(radius_a, arc_length, radius_b - radius_b * 0.05)
<< "][" << elliptic_root_2deriv(radius_a, arc_length, radius_b + radius_b * 0.05)
<< "][" << elliptic_root_2deriv(radius_a, arc_length, radius_b + radius_b * 0.1)
<< "][" << elliptic_root_2deriv(radius_a, arc_length, radius_b + radius_b * 0.2)
<< "][" << elliptic_root_2deriv(radius_a, arc_length, radius_b + radius_b * 0.5)
<< "][" << elliptic_root_2deriv(radius_a, arc_length, radius_b + radius_b)
<< "][" << elliptic_root_2deriv(radius_a, arc_length, radius_b + radius_b * 5) << "]]\n";
std::cout << "[[schr'''ö'''der_iterate]["
<< elliptic_root_2deriv_s(radius_a, arc_length, radius_b / 6)
<< "][" << elliptic_root_2deriv_s(radius_a, arc_length, radius_b / 2)
<< "][" << elliptic_root_2deriv_s(radius_a, arc_length, radius_b - radius_b * 0.5)
<< "][" << elliptic_root_2deriv_s(radius_a, arc_length, radius_b - radius_b * 0.2)
<< "][" << elliptic_root_2deriv_s(radius_a, arc_length, radius_b - radius_b * 0.1)
<< "][" << elliptic_root_2deriv_s(radius_a, arc_length, radius_b - radius_b * 0.05)
<< "][" << elliptic_root_2deriv_s(radius_a, arc_length, radius_b + radius_b * 0.05)
<< "][" << elliptic_root_2deriv_s(radius_a, arc_length, radius_b + radius_b * 0.1)
<< "][" << elliptic_root_2deriv_s(radius_a, arc_length, radius_b + radius_b * 0.2)
<< "][" << elliptic_root_2deriv_s(radius_a, arc_length, radius_b + radius_b * 0.5)
<< "][" << elliptic_root_2deriv_s(radius_a, arc_length, radius_b + radius_b)
<< "][" << elliptic_root_2deriv_s(radius_a, arc_length, radius_b + radius_b * 5) << "]]\n]\n\n";
return boost::exit_success;
}
catch(std::exception ex)
{
std::cout << "exception thrown: " << ex.what() << std::endl;
return boost::exit_failure;
}
} // int main()
|