Search code examples
integrationmaple

Complex integration in Maple


The following code takes forever to compute in Maple. Basically, I'm trying to find the mean-square-modulus of a complex-valued function on a circle centered at the origin. How should the code be corrected, or is there an online calculator that can achieve this?

evalf(subs(subs([n=3, p=1.2451, z=exp(x*I)/2], subs(s=(p/2)*(1+1/(4*z)^n), subs(t=s+sqrt(s^2-1/(4*z)^n), w=z*t^(2/n)))), Int(abs(w)^2, x=0..2*Pi)/(2*Pi)));

Solution

  • Is this any use? I mean does it give the expected result? By supplying the integrand as an operator (black box) the evalf/Int engine is prevented from poking at it too expensively. This can save time, although there is risk involved as it might miss key discontinuities for some problems.

    > U:=subs(subs([n=3, p=1.2451, z=exp(x*I)/2],
    >         subs(s=(p/2)*(1+1/(4*z)^n),
    >              subs(t=s+sqrt(s^2-1/(4*z)^n),
    >                   w=z*t^(2/n)))),
    >         Int(X->eval(abs(w)^2,x=X), 0..2*Pi)/(2*Pi)):
    
    > st:=time():
    > evalf(U);
                                 0.3351666815
    
    > time()-st;
                                     0.109
    

    Another (likely less generally useful possibility) might be,

    > restart:
    > U:=subs(subs([n=3, p=1.2451, z=exp(x*I)/2],
    >         subs(s=(p/2)*(1+1/(4*z)^n),
    >              subs(t=s+sqrt(s^2-1/(4*z)^n),
    >                   w=z*t^(2/n)))),
    >         Int(abs(w)^2, x=0..2*Pi)/(2*Pi)):             
    
    > st:=time():
    > simplify(U);
    
                                                    -20
                      0.3351666815 - 0.5131390209 10    I
    
    > time()-st;
                                     3.150