expression evaluation



On 28/05/2012 7:10 PM, Ruslan Mullakhmetov wrote:
> Hi guys,
>
>    Could you suggest how to overcome non-proper evaluation. And generally, is maxima capable to simplify such expression?
>
>    The expression: cos( %pi n x) at point x=1/2. That should be 0.
>
> Here the trace:
>
> -------------------------------------------------------
> (%i1) declare(n, integer);
> (%o1)                                done
> (%i2) cos( %pi * n * x);
> (%o2)                            cos(%pi n x)
> (%i3) ev( %, x=1/2,pred, expand, simp,eval );
>                                        %pi n
> (%o3)                             cos(-----)
>                                          2
> (%i4)
> ------------------------------------------------------
>
> At point x=1 everything calculates:
>
> -------------------------------------------------------
> (%i1) declare(n, integer);
> (%o1)                                done
> (%i2) cos( %pi * n * x);
> (%o2)                            cos(%pi n x)
> (%i3) ev( %, x=1,pred, expand, simp,eval );
>                                           n
> (%o3)                               (- 1)
> (%i4)
> -------------------------------------------------------
cos(%pi n x) at point x=1/2
  =  0 when n=4*m+1 and n=4*m+3
  =  1 when n=4*m
  = -1 when n=4*m+2

(%i1) declare(m, integer);
(%o1)                                done
(%i2) ex:cos(%pi*n/2);
                                       %pi n
(%o2)                             cos(-----)
                                         2
(%i3) ex,n=4*m;
(%o3)                                  1
(%i4) ex,n=4*m+1;
                                   %pi (4 m + 1)
(%o4)                         cos(-------------)
                                         2
(%i5) expand(%);
(%o5)                                  0
(%i6) ex,n=4*n+2;
                                   %pi (4 n + 2)
(%o6)                         cos(-------------)
                                         2
(%i7) ex,n=4*m+3;
                                   %pi (4 m + 3)
(%o7)                         cos(-------------)
                                         2
(%i8) expand(%);
(%o8)                                  0