#8321: numerical integration with arbitrary precision
-------------------------+--------------------------------------------------
Reporter: burcin | Owner:
Type: defect | Status: needs_work
Priority: major | Milestone: sage-4.7.2
Component: symbolics | Keywords: numerics,integration
Work_issues: | Upstream: N/A
Reviewer: | Author: Stefan Reiterer
Merged: | Dependencies:
-------------------------+--------------------------------------------------
Comment(by fredrik.johansson):
Ugh, I should clearly have tested this feature properly in mpmath. The
problem is that the {{{__init__}}} method clears the caches. This
definitely needs to be changed in mpmath. Anyway, a workaround is to move
the initialization to the {{{__new__}}} method, like this:
{{{
def __new__(cls):
if not cls.instance:
cls.instance = object.__new__(cls)
cls.instance.standard_cache = {}
cls.instance.transformed_cache = {}
cls.instance.interval_count = {}
return cls.instance
def __init__(self, ctx):
self.ctx = ctx
}}}
This ought to work. The speedup of doing this should be greater for
!GaussLegendre than for !TanhSinh, since the node generation is more
expensive for the former.
Some further speedup would be possible by overriding the transform_nodes
and sum_next methods so that Sage numbers are used most of the time. This
way most of the calls to sage_to_mpmath and mpmath_to_sage could be
avoided when an interval is reused.
transform_nodes would just have to be replaced by a simple wrapper
function that takes the output (a list of pairs of numbers) from the
transform_nodes method of the parent class and converts it to Sage
numbers.
sum_next computes the sum over `weight[i]*f(node[i])`. This is trivial and
could just be changed to a simple loop to work optimally with Sage
numbers. (Only the return value needs to be converted back to an mpmath
number).
This should all just require a few lines of code. One just needs to be
careful to get the precision right in the conversions, and to support both
real and complex numbers. Unless someone else is extremely eager to
implement this, I could look at this tomorrow.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8321#comment:42>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.