#8321: numerical integration with arbitrary precision
----------------------------------------------+-----------------------------
Reporter: burcin | Owner:
Type: defect | Status: needs_work
Priority: major | Milestone: sage-5.0
Component: symbolics | Resolution:
Keywords: numerics,integration, sd32 | Work issues:
Report Upstream: N/A | Reviewers:
Authors: Stefan Reiterer | Merged in:
Dependencies: | Stopgaps:
----------------------------------------------+-----------------------------
Comment (by nbruin):
Replying to [comment:1 zimmerma]:
> I don't know why it does not work from Sage:
> {{{
> sage: gp.intnum(x=1,2,sin(x)/x^2)
> ------------------------------------------------------------
> File "<ipython console>", line 1
> SyntaxError: non-keyword arg after keyword arg (<ipython console>, line
1)
> }}}
It does not work for two reasons:
- `gp.intnum` does not accept python keyword arguments (it would be very
painful and error prone to transform that to the appropriate string input
to `gp`
- formula transformation to gp is very limited:
{{{
sage: gp(sin(x)/x^2)
x^-1 - 1/6*x + 1/120*x^3 - 1/5040*x^5 + 1/362880*x^7 - 1/39916800*x^9 +
1/6227020800*x^11 - 1/1307674368000*x^13 + O(x^15)
}}}
The latter point seems the most fundamental to me. For arbitrary precision
numerical integration, GP/PARI is probably our best bet, though, and it
seems that the PARI C api should be quite usable, because the integrand
gets passed as a black box function. From
[http://pari.math.u-bordeaux.fr/dochtml/html.stable/Sums,_products,_integrals_and_similar_functions.html
PARI handbook], we get the signature:
{{{
intnum(void *E, GEN (*eval)(void*,GEN), GEN a,GEN b,GEN tab, long prec)
}}}
so as long as we can provide a way to evaluate our integrand (say) `f` at
a value `x` with precision `prec`, we can wrap that up into a C function
that takes a `GEN`, converts it to `x`, evaluates `f` there and converts
the result to a `GEN` and passes it back. We could pass a pointer to that
function in as `eval` and then everything should work.
Pari's high precision numerical integration is supposed to be of quite
high quality.
This approach would be much easier than trying to symbolically translate
any arbitrary Sage symbolic expression to GP (plus more general, because
we would be able to use any python callable, provided we find a way to
provide the desired precision)
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8321#comment:50>
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.