[sage-devel] Re: problems with hypergeometric and maxima_calculus.hgfpoly
On Friday, September 26, 2014 4:25:58 PM UTC+2, Nils Bruin wrote: It would be good if mpmath used a different approach when it's known a hypergeometric function is a polynomial, but it's a little orthogonal to what happens in sage. By the time we hit mpmath, we're doing multiprecision float computation. Polynomial hypergeometric functions can easily be evaluated at arbitrary inputs (rational, algebraic, symbolic). We should not be bothering with multiprecision floats if we don't have to, or at least only do so if there's a benefit and we can control precision issues. In most symbolic special functions we check for special values and, if found, evaluate immediately. This is not so in hypergeometric.py but would be trivial to add. I can only speculate that the reason was the then forced call of maxima. Since this doesn't seem a problem with commenters please review http://trac.sagemath.org/ticket/17066 and this can be simply emulated until inclusion of the ticket by saying sage: hypergeometric([-2,-1],[2],-1).simplify_hypergeometric() 0 No need to explicitly call Maxima here. Regards, -- You received this message because you are subscribed to the Google Groups sage-devel group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: problems with hypergeometric and maxima_calculus.hgfpoly
On 25 September 2014 20:51, kcrisman kcris...@gmail.com wrote: For Sage, fixing the problem is actually trivial: when the hypergeometric function is a polynomial (and at least when the inputs are exact), don't call mpmath; just evaluate the polynomial directly and then call .n() on the result. Except then Sage would have to know when it is a polynomial, and probably we would need to ask Maxima for that (assuming it knows). So maybe not completely trivial to make sure it works. It's a polynomial when any of the first parameters is a nonpositive integer. Is that if and only if? That would certainly be convenient. I believe this is true for the same reason as for the power series expansion of (1-x)^{-n}, there are rising factorials and these hit zero if and only if they start at a nonpositive integer. But you should check the definition of hypergeometric function to be 100% sure. John -- You received this message because you are subscribed to the Google Groups sage-devel group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups sage-devel group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: problems with hypergeometric and maxima_calculus.hgfpoly
On 2014-09-25, kcrisman kcris...@gmail.com wrote: For Sage, fixing the problem is actually trivial: when the hypergeometric function is a polynomial (and at least when the inputs are exact), don't call mpmath; just evaluate the polynomial directly and then call .n() on the result. Except then Sage would have to know when it is a polynomial, and probably we would need to ask Maxima for that (assuming it knows). So maybe not completely trivial to make sure it works. It's a polynomial when any of the first parameters is a nonpositive integer. Is that if and only if? That would certainly be convenient. isn't it more or less directly by definition ? Dima -- You received this message because you are subscribed to the Google Groups sage-devel group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: problems with hypergeometric and maxima_calculus.hgfpoly
On Thu, Sep 25, 2014 at 9:51 PM, kcrisman kcris...@gmail.com wrote: For Sage, fixing the problem is actually trivial: when the hypergeometric function is a polynomial (and at least when the inputs are exact), don't call mpmath; just evaluate the polynomial directly and then call .n() on the result. Except then Sage would have to know when it is a polynomial, and probably we would need to ask Maxima for that (assuming it knows). So maybe not completely trivial to make sure it works. It's a polynomial when any of the first parameters is a nonpositive integer. Is that if and only if? That would certainly be convenient. Yes, that follows immediately from the definition. I should clarify that the hypergeometric function can be zero for rational input even if it is not a polynomial in z. For example 1F1(3/2, 1/2, z) = (1 + 2*z) * exp(z) (you can verify that mpmath does not converge with z = -0.5). You are less likely to run into such zeros, though. Fredrik -- You received this message because you are subscribed to the Google Groups sage-devel group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: problems with hypergeometric and maxima_calculus.hgfpoly
For Sage, fixing the problem is actually trivial: when the hypergeometric function is a polynomial (and at least when the inputs are exact), don't call mpmath; just evaluate the polynomial directly and then call .n() on the result. Except then Sage would have to know when it is a polynomial, and probably we would need to ask Maxima for that (assuming it knows). So maybe not completely trivial to make sure it works. It's a polynomial when any of the first parameters is a nonpositive integer. Is that if and only if? That would certainly be convenient. Yes, that follows immediately from the definition. Well, then I guess this shouldn't be too hard to implement... I will admit that I will not be the one doing it, but sounds like a no-brainer. -- You received this message because you are subscribed to the Google Groups sage-devel group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: problems with hypergeometric and maxima_calculus.hgfpoly
On 2014-09-26, kcrisman kcris...@gmail.com wrote: For Sage, fixing the problem is actually trivial: when the hypergeometric function is a polynomial (and at least when the inputs are exact), don't call mpmath; just evaluate the polynomial directly and then call .n() on the result. Except then Sage would have to know when it is a polynomial, and probably we would need to ask Maxima for that (assuming it knows). So maybe not completely trivial to make sure it works. It's a polynomial when any of the first parameters is a nonpositive integer. Is that if and only if? That would certainly be convenient. Yes, that follows immediately from the definition. Well, then I guess this shouldn't be too hard to implement... I will admit that I will not be the one doing it, but sounds like a no-brainer. IMHO it would be great to have this in mpmath rather than a Sage workaround. (AFAIK, hypergeometric_U is vulnerable to the very same problem, so this would mean the workaround would either be needed in several places...) Dima -- You received this message because you are subscribed to the Google Groups sage-devel group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: problems with hypergeometric and maxima_calculus.hgfpoly
On Friday, September 26, 2014 6:55:39 AM UTC-7, Dima Pasechnik wrote: IMHO it would be great to have this in mpmath rather than a Sage workaround. (AFAIK, hypergeometric_U is vulnerable to the very same problem, so this would mean the workaround would either be needed in several places...) It would be good if mpmath used a different approach when it's known a hypergeometric function is a polynomial, but it's a little orthogonal to what happens in sage. By the time we hit mpmath, we're doing multiprecision float computation. Polynomial hypergeometric functions can easily be evaluated at arbitrary inputs (rational, algebraic, symbolic). We should not be bothering with multiprecision floats if we don't have to, or at least only do so if there's a benefit and we can control precision issues. -- You received this message because you are subscribed to the Google Groups sage-devel group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: problems with hypergeometric and maxima_calculus.hgfpoly
For Sage, fixing the problem is actually trivial: when the hypergeometric function is a polynomial (and at least when the inputs are exact), don't call mpmath; just evaluate the polynomial directly and then call .n() on the result. Except then Sage would have to know when it is a polynomial, and probably we would need to ask Maxima for that (assuming it knows). So maybe not completely trivial to make sure it works. - kcrisman -- You received this message because you are subscribed to the Google Groups sage-devel group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: problems with hypergeometric and maxima_calculus.hgfpoly
On Thu, Sep 25, 2014 at 9:02 AM, kcrisman kcris...@gmail.com wrote: For Sage, fixing the problem is actually trivial: when the hypergeometric function is a polynomial (and at least when the inputs are exact), don't call mpmath; just evaluate the polynomial directly and then call .n() on the result. Except then Sage would have to know when it is a polynomial, and probably we would need to ask Maxima for that (assuming it knows). So maybe not completely trivial to make sure it works. It's a polynomial when any of the first parameters is a nonpositive integer. Fredrik -- You received this message because you are subscribed to the Google Groups sage-devel group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: problems with hypergeometric and maxima_calculus.hgfpoly
For Sage, fixing the problem is actually trivial: when the hypergeometric function is a polynomial (and at least when the inputs are exact), don't call mpmath; just evaluate the polynomial directly and then call .n() on the result. Except then Sage would have to know when it is a polynomial, and probably we would need to ask Maxima for that (assuming it knows). So maybe not completely trivial to make sure it works. It's a polynomial when any of the first parameters is a nonpositive integer. Is that if and only if? That would certainly be convenient. -- You received this message because you are subscribed to the Google Groups sage-devel group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: problems with hypergeometric and maxima_calculus.hgfpoly
On Wednesday, September 24, 2014 12:35:50 PM UTC+2, Dima Pasechnik wrote: there is quite a bit of weirdness mentioned here: http://ask.sagemath.org/question/24257/a-hypergeometric-series/ e.g. sage: hypergeometric([-2,-1],[2],-1).n(100) --- - is any of these known? In the 1st case, looks like numeric evaluation of qFp by mpmath is seriously broken... hyp2f1(-2,-1,2,-1) doesn't converge because the value is zero, and the hypergeometric function evaluation code in mpmath always tries to achieve full *relative* accuracy. One solution is to do: hyp2f1(-2,-1,2,-1,zeroprec=1000) mpf('0.0') This is saying that if the result cannot be distinguished from zero when using 1000 bits of working precision, it is probably actually zero and not just merely something very small (so don't be fussy about it). In fact, hyp2f1(-2,-1,2,z) is just the polynomial 1+z. mpmath has no way to distinguish 1 + (-1) from 1 + (-1 + eps) in which the eps disappears due rounding, so it has to assume that something may have disappeared. Indeed: mp.dps = 1000 z = mpf(-1) + mpf(1e-900) mp.dps = 15 hyper([-2,-1],[2],z) # conservatively throws an error Traceback (most recent call last): ... ValueError: hypsum() failed to converge to the requested 53 bits of accuracy using a working precision of 3568 bits. Try with a higher maxprec, maxterms, or set zeroprec. hyper([-2,-1],[2],z,zeroprec=1000) # WRONG!!! (relatively speaking) mpf('0.0') hyper([-2,-1],[2],z,maxprec=1) # correct mpf('9.9998e-901') Exact zero detection could be done at least in trivial cases by identifying easy factors such as z-1 or z+1. In general, I think one basically has to fall back to using exact rational arithmetic for the evaluation. This would be worth implementing in mpmath, because the current behavior is definitely annoying. For Sage, fixing the problem is actually trivial: when the hypergeometric function is a polynomial (and at least when the inputs are exact), don't call mpmath; just evaluate the polynomial directly and then call .n() on the result. Fredrik -- You received this message because you are subscribed to the Google Groups sage-devel group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.