On 11/27, Oleg Nesterov wrote: > > On 11/25, Julius Smith wrote: > > > > I would expect ba.tabulate() to be unbeatable when the function being > > sampled is actually linear, quadratic, or cubic, > > Well ;) If the function is cubic then chebtab() will win even with NX=1. > Ignoring the floating point issues, chebtab() will be simply equal to > the approximated function. If the function is "nearly cubic", chebtab() > should likely win anyway, I guess, but this depends.
Let me provide a couple of stupid test-cases just in case ;) CK = 1; FX(x) = x^3 - 2*x^2 - 100* x - 1; X0 = 0; X1 = 10; NX = 50; CD = 3; // Both ch() and tb() create rdtable of size=200 and both use cubic // polynomial, so this comparison is more or less fair. ch(x) = chebtab(CK, FX, NX, CD, X0,X1, x); tb(x) = ba.tabulate(CK, FX, NX*(CD+1), X0,X1, x).cub; maxerr = abs : max ~ _; line(n, x0,x1) = x0 + (ba.time%n)/n * (x1-x0); process = line(50000, X0,X1) <: FX-tb,FX-ch : par(i,2,maxerr); compiled with -a plot.cpp $ /tmp/c-plot -n 50000 | tail -1 0.600803971 5.68434189e-13 e-13 is just the floating point errors. The close result if I change ch(x) to use NX=1. Lets add some "noise" to FX, FX(x) = x^3 - 2*x^2 - 100* x - 1 + sin(x); // sin(x) is small compared to poly Now, $ /tmp/c-plot -n 50000 | tail -1 0.59773165 5.20619665e-07 OK, lets recall that ba.tabulate() doesn't play well near X0, X1, lets help tabulate() to be more accurate: // ensure that ba.tabulate() always have at least 4 valid points offs = 4 * (X1-X0) / (NX*(CD+1)); process = line(50000, X0+offs,X1-offs) <: FX-tb,FX-ch : par(i,2,maxerr); now ba.tabulate() works MUCH better but chebtab() still wins: $ /tmp/c-plot -n 50000 | tail -1 1.42467743e-05 5.20622848e-07 Oleg. _______________________________________________ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users