Closed ArjunNarayanan closed 4 years ago
Do you only need to evaluate univariate polynomials? In this case, the @horner
macro actually accomplishes the same thing as this package
Otherwise this looks like a problem with Taylor Models
I was able to get around this problem by intercepting the muladd(tm::TaylorModelN,a,b)
method and overloading it to simply return a*tm+b
. I imagine there is a performance hit due to this, but at least it works!
I looked for the documentation of StaticPolynomials.@horner
and found StaticPolynomials.@horner_deriv
-- is this what you are referring to?
The reason I am using TaylorModels
is because I also get a remainder bound for the error. I require this for my application. Does @horner
provide this as well?
This is in Base, although it's actually called @evalpoly
:
help?> Base.@evalpoly
@evalpoly(z, c...)
Evaluate the polynomial \sum_k c[k] z^{k-1} for the coefficients c[1], c[2], ...; that is, the coefficients are given in ascending order by power
of z. This macro expands to efficient inline code that uses either Horner's method or, for complex z, a more efficient Goertzel-like algorithm.
Examples
≡≡≡≡≡≡≡≡≡≡
julia> @evalpoly(3, 1, 0, 1)
10
julia> @evalpoly(2, 1, 0, 1)
5
julia> @evalpoly(2, 1, 1, 1)
7
This is the relevan math: https://en.wikipedia.org/wiki/Horner%27s_method
I see, thanks!
To provide some more context -- I am constructing a basis of Lagrange polynomials as a StaticPolynomials.PolynomialSystem
. Then for a given set of interpolation coefficients, I am trying to obtain tight bounds for the range of the interpolated polynomial.
Interval arithmetic gives valid bounds, but they are not very tight; hence my interest in Taylor Models.
I guess I can close this issue now since overloading muladd
gets around the issue for now!
I'm trying to use
StaticPolynomials.jl
along with TaylorModels.jl and ran into an error that I don't quite understand. Example:I'm not sure which is the appropriate place to report this error. Is it an issue with promotion of the
TaylorModels
type? Any inputs will be helpful!