Thank you for the plausible explanation. In the first place I was surprised about complexIntegrate doing so much better, but now I can understand why. The background is "computing Fourier coefficients", so I think it will be better using the complex form instead of cos/sin.
BTW do you have any idea what FourierSeries(R, E) and FourierComponent E are for? I can't recognize any functionality regarding to compute Fourier coefficients nor series. Am 11.11.2016 um 01:49 schrieb Waldek Hebisch: > Kurt Pagani wrote: >> >> When integrating sin(x)*cos(2*n*x), n=1,10,20,30, there is a unusual growth >> in run-time. I guess that the cause might be found in trigonometric >> transformations. Is that so? > > Yes. Compare: > > (6) -> complexElementary(normalize(sin(x)*cos(2*20*x))) > > (6) > +---+ 164 +---+ 160 +---+ 4 > x\|- 1 x\|- 1 x\|- 1 > ------- ------- ------- > +---+ 2 +---+ 2 +---+ 2 +---+ > - \|- 1 (%e ) + \|- 1 (%e ) - \|- 1 (%e ) + \|- 1 > --------------------------------------------------------------------------- > +---+ 82 > x\|- 1 > ------- > 2 > 4(%e ) > Type: Expression(Integer) > Time: 14.47 (EV) + 0.01 (OT) = 14.48 sec > > (7) -> complexIntegrate(sin(x)*cos(2*20*x),x) > > +---+ 82 +---+ 80 +---+ 2 > x\|- 1 x\|- 1 x\|- 1 > - 39(%e ) + 41(%e ) + 41(%e ) - 39 > (7) --------------------------------------------------------- > +---+ 41 > x\|- 1 > 6396(%e ) > Type: Expression(Integer) > Time: 0.01 (EV) = 0.01 sec > > 'complexElementary' is doing slightly harder job than needed for > integration, but may give some idea how expensive is such transformation. > >> Of course we can integrate using the parameter "n" followed by evaluation, >> however, I wonder whether this behavior is normal. > > In a sense this normal behavior: FriCAS assumes that it can > expand/transform expressions to more conveniet forms and > such transformations may be costly. In the case above there > are some additional factors: > > - integrator first writes function in terms of tangent and > later converts it to exponential form. This is more expensive > than direct convertion > - apparently during computations FriCAS uses subresultant GCD. > More precisely, sbcl profiler indicates that most of > execution time is spent in subresultant GCD. Subresultant GCD > is much slower than modular version which should be applicable > here. > > -- You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at https://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.