diff --git a/poincare/src/integral.cpp b/poincare/src/integral.cpp index 15fbb9e7e..404ca9902 100644 --- a/poincare/src/integral.cpp +++ b/poincare/src/integral.cpp @@ -26,10 +26,19 @@ Expression * Integral::cloneWithDifferentOperands(Expression** newOperands, } float Integral::approximate(Context& context) const { - /* We here use Gauss-Legendre quadrature with n = 5 */ + /* We here use Gauss-Legendre quadrature with n = 5 + * Gauss-Legendre abscissae and weights taken from + * http://www.holoborodko.com/pavel/numerical-methods/numerical-integration/*/ + /* TODO: implement an adaptive quadrature version + * Use Gauss-Konrad quadrature (the one used in GNU scientific library)? + * QAGS and QAGI from netlib? + * Add to this version: + * - assess error + * - higher degree if error > threshold + * - find a way to reuse x and w ? Or useless, store all values ? */ XContext xContext = XContext(&context); - static float x[5]={0.1488743389f, 0.4333953941f, 0.6794095682f, 0.8650633666f, 0.9739065285f}; - static float w[5]={0.2955242247f, 0.2692667193f, 0.2190863625f, 0.1494513491f, 0.0666713443f}; + static float x[5]={0.1488743389816312108848260f, 0.4333953941292471907992659f, 0.6794095682990244062343274f, 0.8650633666889845107320967f, 0.9739065285171717200779640f}; + static float w[5]={0.2955242247147528701738930f, 0.2692667193099963550912269f, 0.2190863625159820439955349f, 0.1494513491505805931457763f, 0.0666713443086881375935688f}; float a = m_args[1]->approximate(context); float b = m_args[2]->approximate(context); float xm = 0.5f*(a+b);