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. -- Waldek Hebisch -- 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.