Prev: Interpretation within FOR loop
Next: Quantifying noise
From: Andres on 22 Apr 2010 10:49 "John D'Errico" <woodchips(a)rochester.rr.com> wrote in message <hqpirp$11p$1(a)fred.mathworks.com>... > Rather than using roots, use the explicit formula for the > roots of a cubic polynomial, given the coefficients. This > can be done in a fully vectorized form, so all the intervals > can be processed at once. > > Other tricks you can do are to break up knot intervals > into intervals such that the spline is strictly monotone > over each interval. That will allow you to only apply > a roots operation to the intervals where you KNOW a > root exists already. > > John Good ideas. One could rely on roots.m if the order of the spline is > 3 (or even 4), and use the explicit formulae otherwise (if the spline is not necessarily cubic). Of course some special cases (e.g. y=0 inside an interval of x) need to be considered for a general solution as well. Thanks!
From: John D'Errico on 22 Apr 2010 12:24 "Andres" <rantore(a)werb.deNoRs> wrote in message <hqpnlh$605$1(a)fred.mathworks.com>... > "John D'Errico" <woodchips(a)rochester.rr.com> wrote in message <hqpirp$11p$1(a)fred.mathworks.com>... > > > Rather than using roots, use the explicit formula for the > > roots of a cubic polynomial, given the coefficients. This > > can be done in a fully vectorized form, so all the intervals > > can be processed at once. > > > > Other tricks you can do are to break up knot intervals > > into intervals such that the spline is strictly monotone > > over each interval. That will allow you to only apply > > a roots operation to the intervals where you KNOW a > > root exists already. > > > > John > > Good ideas. One could rely on roots.m if the order of the spline is > 3 (or even 4), and use the explicit formulae otherwise (if the spline is not necessarily cubic). > Of course some special cases (e.g. y=0 inside an interval of x) need to be considered for a general solution as well. > Thanks! You need to check the results carefully in any such computation. For example, what if the computation yields a slightly complex result? What if the root found is just eps outside the interval of interest? What if the function is not truly cubic over the interval? That is, suppose the cubic coefficient is insignificant on a given interval? It will generate a spurious root, but where? The most careful code will worry about all of these things. John
|
Pages: 1 Prev: Interpretation within FOR loop Next: Quantifying noise |