Question: Maple takes extraordinary long, potentially infinite, time to plot

Hello,

I've just asked maple to plot a(s) from s=0 ..10 where a(s) is the absaolute value of a complex piecewise function. When I enter the command to plot:

> plot(a(s), s = 0 .. 10, discont = true);

maple just shows 'Evaluating' and fails to produce anything. I've left it for up to 20 minutes without any result. Maple has successfully plotted very similar things before in a matter of seconds so I don't think time is an issue here. The full script is as follows:

 

> x := 5.180070098;
                          5.180070098
> y := -8.852276351;
                          -8.852276351
> k := 10.25650636;
                          10.25650636


> f := proc (s) options operator, arrow; piecewise(0 < s and s <= 2, (1+I*k/y)*((1+I*k/x)*exp(I*x*s)/(1-I*k/x)+exp(-I*x*s))/(1-I*k/y), 2 < s and s <= 5, exp(-(2*I)*x)*((1+I*k/y)*exp(I*y*(s-2))/(1-I*k/y)+exp(-I*y*(s-2))), 5 < s and s <= 7, exp(-(3*I)*y)*((1+I*k/x)*exp(I*x*(7-s))/(1-I*k/x)+exp(-I*x*(7-s))), 7 < s and s <= 10, (1+I*k/x)*((1+I*k/y)*exp(I*y*(10-s))/(1-I*k/y)+exp(-I*y*(10-s)))/(1-I*k/x)) end proc;
              /                 
              |                 
              |                 
              |                 
              |                 
              |                 
              |                 
s -> piecewise|0 < s and s <= 2,
              |                 
              |                 
              \                 

            //    I k\                         \ 
            ||1 + ---| exp(I x s)              | 
  /    I k\ |\     x /                         | 
  |1 + ---| |-------------------- + exp(-I x s)| 
  \     y / |          I k                     | 
            |      1 - ---                     | 
            \           x                      / 
  ----------------------------------------------,
                         I k                     
                     1 - ---                     
                          y                      

  2 < s and s <= 5,

              //    I k\                                     \ 
              ||1 + ---| exp(I y (s - 2))                    | 
              |\     y /                                     | 
  exp(-2 I x) |-------------------------- + exp(-I y (s - 2))|,
              |             I k                              | 
              |         1 - ---                              | 
              \              y                               / 

  5 < s and s <= 7,

              //    I k\                                     \ 
              ||1 + ---| exp(I x (7 - s))                    | 
              |\     x /                                     | 
  exp(-3 I y) |-------------------------- + exp(-I x (7 - s))|,
              |             I k                              | 
              |         1 - ---                              | 
              \              x                               / 

  7 < s and s <= 10,

            //    I k\                                       \\
            ||1 + ---| exp(I y (10 - s))                     ||
  /    I k\ |\     y /                                       ||
  |1 + ---| |--------------------------- + exp(-I y (10 - s))||
  \     x / |              I k                               ||
            |          1 - ---                               ||
            \               y                                /|
  ------------------------------------------------------------|
                                I k                           |
                            1 - ---                           |
                                 x                            /
> g := unapply(f(s), s);
s -> piecewise(0 < s and s <= 2, (-0.1461827924 - 0.9892575960 I)

  ((-0.5935269332 + 0.8048141273 I) exp(5.180070098 I s)

   + exp(-5.180070098 I s)), 2 < s and s <= 5, (-0.5935269301

   + 0.8048141296 I) ((-0.1461827924 - 0.9892575960 I) exp(-8.85\

  2276351 I (s - 2)) + exp(8.852276351 I (s - 2))),

  5 < s and s <= 7, (0.1461827943 + 0.9892575957 I) ((
-0.5935269332 + 0.8048141273 I) exp(5.180070098 I (7 - s))

   + exp(-5.180070098 I (7 - s))), 7 < s and s <= 10, (
-0.5935269332 + 0.8048141273 I) ((-0.1461827924 - 0.9892575960 I)

  exp(-8.852276351 I (10 - s)) + exp(8.852276351 I (10 - s))))
> a(s):=abs(g(s));
s -> |g(s)|

> with(plots);
> plot(a(s), s = 0 .. 10, discont = true);

 

Thankyou for your time.

Please Wait...