On 12/6/08, David Joyner <[EMAIL PROTECTED]> wrote: > (1) Sage calls Maxima and asks it to do lots of definite integrals > (about 30 in this case, each involving a sine or cosine) - these are the > Fourier coefficients, > (2) Sage multiplies each of these coefficients by a sine or cosine function > and adds them up - call this finite sum f(x), > (3) Sage calls Maxima to evaluate f(x) at lots of points to plot the graph > (maybe 100 point-wise evaluations of f(x)), > (4) calls matplotlib to create the plot of f.
OK, I hope the following script (see PS) follows these steps. > This was repeated (for timing purposes) 10 times. In an example involving > about 30 terms, the first took about 10-11 seconds, and repeated > evaluations took longer and longer, with the 10th taking about 30-35 seconds. With the script as shown in the PS, I don't see an increase of run time over 100 iterations. It takes about 16 seconds (varies between 15.something to 17.something) with Maxima 5.17.0 + Clisp 2.46 on CentOS Linux, 3.4 GHz Intel x86. Incidentally some integrals cause messages to be printed; these originate in the Taylor series code, which is called from integration. Hope I've understood the question & haven't messed up something. Robert Dodier PS. $ maxima --batch sage_fourier_helper.mac 1> 1.out 2> 2.out $ tail 1.out $ cat sage_fourier.mac fc_all(n):=fc_ab(-1,n,-%pi,(-%pi)/2)+fc_ab(2,n,-%pi/2,0) +fc_ab(-1,n,0,%pi/2)+fc_ab(2,n,%pi/2,%pi)$ fc_ab(e,n,a,b):=if n = 0 then [integrate(e,x,a,b)/(2*%pi),0] else fc1_ab(e,n,a,b)$ fc1_ab(e,n,a,b):=[integrate(e*cos(n*x),x,a,b)/%pi, integrate(e*sin(n*x),x,a,b)/%pi]$ coefs : map (fc_all, makelist (i, i, 0, 15)); fsum : sum (coefs[1 + n][1] * cos (n*x) + coefs[1 + n][2] * sin (n*x), n, 0, 15) ; xx : makelist ((i - 1) * 2 * %pi / 100 - %pi, i, 1, 101), numer; fsum_xx : makelist (''fsum, x, xx), numer; $ cat sage_fourier_helper.mac load ("./sage_fourier.mac"); load ("./sage_fourier.mac"); ... (lots more to make 100 in all) ... load ("./sage_fourier.mac"); load ("./sage_fourier.mac"); map (time, labels (%o)); --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---