class_docstr: This class implements "tanh-sinh" or "doubly exponential"
  quadrature. This quadrature rule is based on the Euler-Maclaurin
  integral formula. By performing a change of variables involving
  nested exponentials / hyperbolic functions (hence the name), the
  derivatives at the endpoints vanish rapidly. Since the error term
  in the Euler-Maclaurin formula depends on the derivatives at the
  endpoints, a simple step sum becomes extremely accurate. In
  practice, this means that doubling the number of evaluation
  points roughly doubles the number of accurate digits.
  
  Comparison to Gauss-Legendre:
    * Initial computation of nodes is usually faster
    * Handles endpoint singularities better
    * Handles infinite integration intervals better
    * Is slower for smooth integrands once nodes have been computed
  
  The implementation of the tanh-sinh algorithm is based on the
  description given in Borwein, Bailey & Girgensohn, "Experimentation
  in Mathematics - Computational Paths to Discovery", A K Peters,
  2003, pages 312-313. In the present implementation, a few
  improvements have been made:
  
    * A more efficient scheme is used to compute nodes (exploiting
      recurrence for the exponential function)
    * The nodes are computed successively instead of all at once
  
  **References**
  
  * [Bailey]_
  * http://users.cs.dal.ca/~jborwein/tanh-sinh.pdf
class_docstr_tok: ["This","class","implements","``","tanh-sinh","''","or","``","doubly","exponential","''","quadrature",".","This","quadrature","rule","is","based","on","the","Euler-Maclaurin","integral","formula",".","By","performing","a","change","of","variables","involving","nested","exponentials","\/","hyperbolic","functions","(","hence","the","name",")",",","the","derivatives","at","the","endpoints","vanish","rapidly",".","Since","the","error","term","in","the","Euler-Maclaurin","formula","depends","on","the","derivatives","at","the","endpoints",",","a","simple","step","sum","becomes","extremely","accurate",".","In","practice",",","this","means","that","doubling","the","number","of","evaluation","points","roughly","doubles","the","number","of","accurate","digits",".","Comparison","to","Gauss-Legendre",":","*","Initial","computation","of","nodes","is","usually","faster","*","Handles","endpoint","singularities","better","*","Handles","infinite","integration","intervals","better","*","Is","slower","for","smooth","integrands","once","nodes","have","been","computed","The","implementation","of","the","tanh-sinh","algorithm","is","based","on","the","description","given","in","Borwein",",","Bailey","&","Girgensohn",",","``","Experimentation","in","Mathematics","-","Computational","Paths","to","Discovery","''",",","A","K","Peters",",","2003",",","pages","312-313",".","In","the","present","implementation",",","a","few","improvements","have","been","made",":","*","A","more","efficient","scheme","is","used","to","compute","nodes","(","exploiting","recurrence","for","the","exponential","function",")","*","The","nodes","are","computed","successively","instead","of","all","at","once","*","*","References","*","*","*","[","Bailey","]","_","*","http",":","\/\/users.cs.dal.ca\/~jborwein\/tanh-sinh.pdf"]
docstr: Step sum for tanh-sinh quadrature of degree `m`. We exploit the
  fact that half of the abscissas at degree `m` are precisely the
  abscissas from degree `m-1`. Thus reusing the result from
  the previous level allows a 2x speedup.
docstr_tok: ["Step","sum","for","tanh-sinh","quadrature","of","degree","`","m","`",".","We","exploit","the","fact","that","half","of","the","abscissas","at","degree","`","m","`","are","precisely","the","abscissas","from","degree","`","m-1","`",".","Thus","reusing","the","result","from","the","previous","level","allows","a","2x","speedup","."]
code: def sum_next(self, f, nodes, degree, prec, previous, verbose=False):
      """
      Step sum for tanh-sinh quadrature of degree `m`. We exploit the
      fact that half of the abscissas at degree `m` are precisely the
      abscissas from degree `m-1`. Thus reusing the result from
      the previous level allows a 2x speedup.
      """
      h = self.ctx.mpf(2) ** (-degree)
      # Abscissas overlap, so reusing saves half of the time
      if previous:
          S = previous[-1] / (h * 2)
      else:
          S = self.ctx.zero
      S += self.ctx.fdot((w, f(x)) for (x, w) in nodes)
      return h * S
  
imports: import math
  from ..libmp.backend import xrange
label_desc: Use image node_id 1 for calling the TanhSinh obj's underlying member method code with example usage: obj.sum_next(f, nodes, degree, prec, previous, verbose) and returns: unknown