-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Numerical precision of coefficients #205
Comments
Thanks for reporting! Indeed, the normalized coefficients of the Taylor series are simply too small to be handled by Float64; note that we compute the coefficients using recurrence relations, which include the julia> x = 5 + Taylor1(200)
5.0 + 1.0 t + 𝒪(t²⁰¹)
julia> sin_x = sin(x);
julia> sin_x[177] # same as getcoeff(sin_x, 177)
1.0e-323
julia> sin_x[178]
0.0 Note that the 177th (normalized) coefficient of the Taylor series is already a subnormal Float64, so I guess there may be precision problems already before. Is it of any help to use julia> xb = 5 + Taylor1(BigFloat, 200)
5.0 + 1.0 t + 𝒪(t²⁰¹)
julia> sin_xb = sin(xb);
julia> sin_xb[177]
8.097958712298242025294651104096755715810462343573419929878033256108316811354375e-324
julia> sin_xb[178]
1.537936570049971023666298556096633985711543026211028342942105542375668955243689e-325 Let me think it over if there is a simple (recursive) way to compute the derivatives directly. |
I think what Mike is asking is if we could have a version where the coefficients stored are n! times the current coefficients. (I had already asked this same question.) This should be easy to implement (just don't divide by k when calculating the coefficients), but it's not so clear what API to use. Basically this would be a different type. |
Something like the exponential generating function of the derivatives (?) |
Right, exactly. It could be the same type if you modified the display and |
Hmm, I think this would be much harder that it seems at a first glance, since the product of two series would no longer be the simple Cauchy product. |
In terms of recurrence relations, things are not too far from what we already have. As for products of series, the Cauchy product will not be so simple, indeed, but it is doable. As Mike points out, overflow may be a concern, which is obviously controlled by the |
In a simple case we get poor precision on the 177th term, and it zeros out on the 178th.
Getting accurate and extremely fast 176th derivatives is hardly unimpressive, but I figured I'd open this both so that anyone else who hits this isn't confused, and to speculate about whether TaylorSeries can be made to work to arbitrary order.
Presumably the core issue is that the factorial terms
1/k!
get too small for Float64 to handle. Would it be possible/performant to store the gradients without these factors, and dynamically include them when multiplying series together?The text was updated successfully, but these errors were encountered: