acer

32333 Reputation

29 Badges

19 years, 319 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Do you mean a reduction something like this?

simplify(F, {omega^(N/2)=-1});

For example,

restart; 

N:=6:

F:=Matrix(N,N,(i,j)->omega^((i-1)*(j-1)));

                 [1    1        1        1        1        1   ]
                 [                                             ]
                 [                2        3        4        5 ]
                 [1  omega   omega    omega    omega    omega  ]
                 [                                             ]
                 [        2       4        6        8        10]
                 [1  omega   omega    omega    omega    omega  ]
                 [                                             ]
            F := [        3       6        9        12       15]
                 [1  omega   omega    omega    omega    omega  ]
                 [                                             ]
                 [        4       8        12       16       20]
                 [1  omega   omega    omega    omega    omega  ]
                 [                                             ]
                 [        5       10       15       20       25]
                 [1  omega   omega    omega    omega    omega  ]

simplify(F,{omega^(N/2)=-1});

                  [1     1       1     1     1        1   ]
                  [                                       ]
                  [                 2                    2]
                  [1   omega   omega   -1  -omega  -omega ]
                  [                                       ]
                  [        2                    2         ]
                  [1  omega    -omega  1   omega   -omega ]
                  [                                       ]
                  [1    -1       1     -1    1       -1   ]
                  [                                       ]
                  [                 2                   2 ]
                  [1  -omega   omega   1   -omega  omega  ]
                  [                                       ]
                  [         2                   2         ]
                  [1  -omega   -omega  -1  omega    omega ]

acer

You probably want the second variant below,

restart:
# Understood, you don't want this for reasons made in the parent post
# from which this was branched.
for i from 1 to 10 do
   evalf(Int(y^i, y=-1/2 .. 1/2));
end do;

                                     0.
                                0.08333333333
                                     0.
                                0.01250000000
                                     0.
                               0.002232142857
                                     0.
                               0.0004340277778
                                     0.
                              0.00008877840909

restart:
for i from 1 to 10 do
   evalf(Int(unapply(y^i,y), -1/2 .. 1/2));
end do;

                                     0.
                                0.08333333333
                                     0.
                                0.01250000000
                                     0.
                               0.002232142857
                                     0.
                               0.0004340277778
                                     0.
                              0.00008877840909

restart:
# Now lexical scoping makes the operator y->i be non-evalhf'able
# and so the Nag method fails and it falls bad to another method
# with slightly different roundoff.
proc() local i;
for i from 1 to 10 do
   print(evalf(Int(y->y^i, -1/2 .. 1/2)));
end do;
end proc();

                                            -15
                              1.788630825 10   
                                0.08333333333
                                     0.
                                0.01250000000
                                            -17
                             -9.886887271 10   
                               0.002232142857
                                     0.
                               0.0004340277778
                                            -18
                             -6.604740566 10   
                              0.00008877840909

restart:
# A strange version of expression form, using an unevaluated function call.
for i from 1 to 10 do
   evalf(Int('proc(Y,ii) Y^ii; end proc'(y,i), y=-1/2 .. 1/2));
end do;

                                     0.
                                0.08333333333
                                     0.
                                0.01250000000
                                     0.
                               0.002232142857
                                     0.
                               0.0004340277778
                                     0.
                              0.00008877840909

acer

detV := proc(A::list) local i, j;
            `*`( seq( seq( A[j]-A[i], i=1..j-1), j=1..nops(A)) );
        end proc:

acer

If your Matrix K has real floating-point entries (or real numeric entries and you don't mind applying evalf to it and get real floats) then you could try it instead as,

   Eigenvectors( Matrix(Transpose(K).K, shape=symmetric) );

which should produce purely real eigenvalues, nicely sorted the same way each instance, without small imainary artefacts (due to roundoff).

acer

Do either of these do better? They both ran in under a second for me in Maple 16.01 using the commandline interface of both 64bit OpenSuSE 10.03 and Windows 7. (Your original form in file int41f went away for a long time for me too, on that Linux.)

restart:

CodeTools:-Usage(

  1/(8.397626817*evalf(Int(abs((-52041.81461+60912.87029*I)
      *conjugate(BesselI(8.397626817*I, 1.941747573*Pi*(1+.5150000000*y)))
      +(52041.81461+60912.87029*I)
      *BesselI(8.397626817*I, 1.941747573*Pi*(1+.5150000000*y)))^2*(.515+y),
                        y = -1/2 .. 1/2,method=_d01ajc)))^(1/2)

                  );

restart:

CodeTools:-Usage(

   1/(8.397626817*evalf(Int(y->abs((-52041.81461+60912.87029*I)
      *conjugate(BesselI(8.397626817*I, 1.941747573*Pi*(1+.5150000000*y)))
      +(52041.81461+60912.87029*I)
      *BesselI(8.397626817*I, 1.941747573*Pi*(1+.5150000000*y)))^2*(.515+y),
                            -1/2 .. 1/2)))^(1/2)

                  );

By forcing that method, or by using operator-form for the integrand, some costly preliminary subtask is avoided. (It could be either expanding the Bessel, or checking for discontinuities, when getting expression-form and an unspecified method -- I didn't investigate which might be the case here...)

As for why it "went away" in one interface and not the other, well, I suspect a session-dependent ordering issue where on;y one of them got lucky. (Terms in a SUM dag might be ordered and accessed differently, according to memory address. That's a guess.)

acer

restart:

P:=sum(cadj[i]*vfinal[i], i = c .. d)-(sum(cadj[i]*vinit[i], i = c .. d)):

factor(combine(P));

               d                                  
             -----                                
              \                                   
               )                                  
              /    cadj[i] (-vinit[i] + vfinal[i])
             -----                                
             i = c                                

acer

You cannot use an indexed name as the parameter of a procedure. The parameter name has to be also of type symbol.

There are two kinds of subscripted name, an indexed name and a subliteral (which is an atomic identifier). The latter of those two can be of type symbol, but the former is only of type name and is not of type symbol.

The easy way to get that, in 2D Math entry mode, is to type it using Ctl-Shift-minus instead of Ctl-minus to get the underscore between the base name and the subscript. Eg. the key strokes   c Ctl-Shift-minus A  instead of c Ctl-minus A

You'll have to be careful to enter them the same way, consistently, wherever they are used in the procedure body.


restart:

f := proc (`#msub(mi("c"),mi("A"))`, `#msub(mi("c"),mi("B"))`) options operator, arrow; `#msub(mi("c"),mi("A"))`+`#msub(mi("c"),mi("B"))` end proc

proc (`#msub(mi("c"),mi("A"))`, `#msub(mi("c"),mi("B"))`) options operator, arrow; `#msub(mi("c"),mi("A"))`+`#msub(mi("c"),mi("B"))` end proc

f(x,y);

x+y

lprint(eval(f));

proc (`#msub(mi("c"),mi("A"))`, `#msub(mi("c"),mi("B"))`) options operator, arrow; `#msub(mi("c"),mi("A"))`+`#msub(mi("c"),mi("B"))` end proc

 


Download subliterals.mw

acer

@j.scott.elder The failure upon cut & paste to respect the literal subscript seems undesirable to me too. (I lprinted the pasted 2D input, or pasted in as 1D, getting the same misconversion.)

But it appears to work ok (in Maple 16.01 at least) if the typesetting level is set to "extended" rather than "standard".

You can change that in either of two ways:

1) From the main menubar, select Tools->Options->Display and change the dropdown menu "Typesetting level".

2) Execute the command

          interface(typesetting=extended):

Maple's fsolve seems to have trouble finding some of the roots (considering it ill-conditioned perhaps).

The following gets 85 complex-valued roots for the univariate eq2 (degree 85 in omega). You may want to experiment with Digits=10 and also recompute at some higher working precision (eg. Digits=50, 100,...), and try and check the accuracy. Note, though, that an individual root could be correct to several places and still show a very high forward error if used as a numeric value of omega for evaluation of eq2.

sols := [RootFinding:-Analytic((lhs-rhs)(eq2),
                                omega=-100000-100000*I..100000+100000*I)]:

nops(sols);

acer

You could use single left-quotes (aka name quotes) and have `&not` as a postfix function call, or you could use no quotes for that term (in which case the brackets are superfluous).

with(Logic):

Equivalent( a &implies b, b &or `&not`(a) );

                              true

Equivalent( a &implies b, b &or &not a );

                              true

acer

The first problem is that not-equal is <> rather than != in Maple.

The second problem is that you cannot assign to the formal parameter that way. Easiest is to just use a pair of locals.

Egcd := proc(a, b)
local A, B, temp;
   A,B := a,b;
   while B <> 0 do
      temp := B;
      B := A mod B;
      A := temp;
   end do;
   return A;  
end proc;

acer

This does not seem to be true in the case that q is itself a multiple of 3.

The common factors I(n) and Z(q) may be removed from the two quantities being tested for equality. (The posted question and the uploaded worksheet disagree: one has Ic(n) as a multiplicative term and the other has it as an addititive term. But it doesn't matter which is intended, In both case those common terms may just be removed.)

restart:

X:=1/2*add(  cos(nwt - qptheta - (n-q)*(i-1)*2*Pi/3)
       + cos(nwt + qptheta - (n+q)*(i-1)*2*Pi/3), i=1..3):

# We are given n-q is an integer multiple of 3.
XX:=combine(expand(eval(X, n=q+3*k))) assuming k::integer;

         3                      1                   
   XX := - cos(nwt - qptheta) + - cos(nwt + qptheta)
         2                      2                   

        1    /  8                     \   1    /  4                     \
      + - cos|- - Pi q + nwt + qptheta| + - cos|- - Pi q + nwt + qptheta|
        2    \  3                     /   2    \  3                     /

Y:=3/2*cos(nwt-qptheta):

# We are interested in whether XX=Y, ie. whether XX-Y=0.
Z:=combine(expand(XX-Y));

              1                      1    /  8                     \
         Z := - cos(nwt + qptheta) + - cos|- - Pi q + nwt + qptheta|
              2                      2    \  3                     /

              1    /  4                     \
            + - cos|- - Pi q + nwt + qptheta|
              2    \  3                     /

expand(eval(Z, q=3*j+2)) assuming j::integer;

                                      0

expand(eval(Z, q=3*j+1)) assuming j::integer;

                                      0

expand(eval(Z, q=3*j)) assuming j::integer;

              3                         3                      
              - cos(nwt) cos(qptheta) - - sin(nwt) sin(qptheta)
              2                         2                      

This means that when q (and also n, due to the given properties) is an integer multiple of 3 the two expressions XX and Y are not equal for all nwt and qpdata.

acer

m:=Matrix([[1,2],[3,4]]);

                                      [1  2]
                                 m := [    ]
                                      [3  4]

T:=a.m;

                                       /[1  2]\
                              T := a . |[    ]|
                                       \[3  4]/

eval(T,a=3);

                                   [3   6]
                                   [     ]
                                   [9  12]

eval(T,a=Matrix([[0,-1],[-1,0]]));

                                  [-3  -4]
                                  [      ]
                                  [-1  -2]

acer

One possible approach is to construct a procedure `f` which would build the final 6x6 Matrix by calling `f(M)`, using explicit formulas in terms of all the entries in input 9x9 Matrix `M`.

You might construct such a re-usable procedure by doing the process on a general symbolic 9x9 Matrix and then using `unapply`.

restart:

with(LinearAlgebra):

# These steps are just for making re-usable procedure `f`.
# By making a re-usable procedure `f` you thus avoid the need to
# apply all these steps to each of your many 9x9 input Matrices.
R := Matrix(9,symbol=A):
R := ColumnOperation(R,[1,-1],1)[1..-1,1..-2]:
R :=    RowOperation(R,[1,-1],1)[1..-2,1..-1]:
R := ColumnOperation(R,[1,-1],1)[1..-1,1..-2]:
R :=    RowOperation(R,[1,-1],1)[1..-2,1..-1]:
R := ColumnOperation(R,[1,-1],1)[1..-1,1..-2]:
R :=    RowOperation(R,[1,-1],1)[1..-2,1..-1]:

# Now we can construct a procedure which has all the formulas
# for constructing the final result. Enter eval(f) to see its body.
f:=unapply(R,A):

M:=RandomMatrix(9);

                  [ 88   52  -33  -95   20   25  -22   57   27]
                  [                                           ]
                  [-82  -13  -68  -20  -61   94   45   27    8]
                  [                                           ]
                  [-70   82  -67  -25  -48   12  -81  -93   69]
                  [                                           ]
                  [ 41   72   22   51   77   -2  -38  -76   99]
                  [                                           ]
             M := [ 91   42   14   76    9   50  -18  -72   29]
                  [                                           ]
                  [ 29   18   16  -44   31   10   87   -2   44]
                  [                                           ]
                  [ 70  -59    9   24  -50  -16   33  -32   92]
                  [                                           ]
                  [-32   12   99   65  -80   -9  -98  -74  -31]
                  [                                           ]
                  [ -1  -62   60   86   43  -50  -77   -4   67]

f(M);

                       [  63  -57  135   80  -67  -50]
                       [                             ]
                       [  -2  -13  -68  -20  -61   94]
                       [                             ]
                       [-175   82  -67  -25  -48   12]
                       [                             ]
                       [  26   72   22   51   77   -2]
                       [                             ]
                       [  30   42   14   76    9   50]
                       [                             ]
                       [ 158   18   16  -44   31   10]

acer

P[0] is an indexed name, but it is not distinct from the name P. So when you assign (the eval result) to P you are clobbering P[0]'s earlier value.

Once you assign a Vector to P then Maple produces an error when you subsequently invoke P[0], because at that point P[0] is a indexed reference to the nonexistent 0th entry of Vector P. P[0] is no longer an assigned name.

One way to handle the issue is to use an entirely different name for either P[0] or P. Another related way is to turn P[0] into an "atomic identifier", which is a fancy term that basically means "distinct name".

The 2D Math for the atomic identifier gets displayed as the subscripted P[0], just like P[0] does in the Standard GUI. You can enter the atomic identifier for P[0] in at least three ways. 1) Using the subliteral item in the Layout palette, 2) Typing the usual P_0 while in 2D Math input mode and then applying the right-click context menu item 2-D Math -> Convert To -> Atomic Identifier to that input, and 3) entering it as the keystrokes P Ctl-_ 0 instead of the usual P _ 0. On my keyboard I get Ctl-_ as Ctl-Shift-minus.

acer

First 260 261 262 263 264 265 266 Last Page 262 of 336