Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

This is my code:

 

NEUZMinus:= proc(Unten, Oben, f,G,Liste,n)::real;
  #Unten:= Untere Intervallgrenze; Oben:= Obere Intervallgrenze; f:= zu integrierende Funktion;
  #G:= Gewicht; n:= Hinzuzufügende Knoten;
  local i;
  with(LinearAlgebra);     
  with(ListTools);
  Basenwechsel:=proc(Dividend, m);
 
  print(Anfang,Dividend,p[m]);
  Koeffizient:=quo(Dividend, p[m],x);

  Rest:=rem(Dividend, p[m],x);
 
  if m=0 then
    Basenwechsel:=[Koeffizient];
  else

    Basenwechsel:=[Koeffizient,op(Basenwechsel(Rest,m-1))];
   
  end if;
 
  end proc;
p[-1]:=0;
p[0]:=1;
for i from 1 to (numelems(Liste)+n)*2 do
  p[i]:=(x^i-add(int(x^i*p[j]*diff(G,x),x=Unten..Oben)*p[j]/int(p[j]^2*diff(G,x),x=Unten..Oben),j=0..i-1));
  print(p[i]);
c[i-1]:=coeff(p[i],x,i)/coeff(p[i-1],x,i-1);
d[i-1]:=(coeff(p[i],x,(i-1))-coeff(p[i-1],x,(i-2)))/coeff(p[i-1],x,(i-1));
if i <> 1 then
  e[i-1]:=coeff(p[i]-(c[i-1]*x+d[i-1])*p[i-1],x,i-2)/coeff(p[i-2],x,i-2);
else
  e[i-1]:=0;
end if;
end do;
print(Liste[1],numelems(Liste));
Hn:=mul(x-Liste[i],i=1..numelems(Liste));
print(Hn);
 Koeffizienten:=Reverse(Basenwechsel(Hn,n)); #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
print(Koeffizienten,HIER);


print(c,d,e);
a[0][0]:=1;
a[1][0]:=x;
a[1][1]:=-e[1]*c[0]/c[1]+(d[0]-d[1]*c[0]/c[1])*x+c[0]/c[1]*x^2;
for s from 2 to numelems(Liste)+n do
  a[s][0]:=x^s;
  a[s][1]:=-e[s]*c[0]/c[s]*x^(s-1)+(d[0]-d[s]*c[0]/c[s])*x^s+c[0]/c[s]*x^(s+1);
    print (coeff(a[s][1],x,s),as1s);
end do;
for s from 2 to numelems(Liste)+n do
  for j from 2 to s do
    
      print(c[j-1]*sum(coeff(a[s][j-1],x,k-1)/c[k-1]*x^k,k=abs(s-j)+2..s+j));  print(sum((d[j-1]-c[j-1]*d[k]/c[k])*coeff(a[s][j-1],x,k)*x^k,k=abs(s-j)+1..s+j-1));  print(c[j-1]*sum(e[k+1]*coeff(a[s][j-1],x,k+1)/c[k+1]*x^k,k=abs(s-j)..s+j-2));print(e[j-1]*sum(coeff(a[s][j-2],x,k)*x^k,k=s-j+2..s+j-2));

     a[s][j]:=c[j-1]*sum(coeff(a[s][j-1],x,k-1)/c[k-1]*x^k,k=abs(s-j)+2..s+j)+sum((d[j-1]-c[j-1]*d[k]/c[k])*coeff(a[s][j-1],x,k)*x^k,k=abs(s-j)+1..s+j-1)-c[j-1]*sum(e[k+1]*coeff(a[s][j-1],x,k+1)/c[k+1]*x^k,k=abs(s-j)..s+j-2)+e[j-1]*sum(coeff(a[s][j-2],x,k)*x^k,k=abs(s-j)+2..s+j-2);

      
   
    
  end do;
end do;
for s from 0 to numelems(Liste)-1 do
  for j from 0 to s do
    print(a[s][j], Polynom[s][j]);
  end do;
end do;
M:=Matrix(n,n);
V:=Vector(n);
 
  for s from 0 to n-1 do
    for j from 0 to s do
      M(s+1,j+1):=sum(coeff(a[s][j],x,k)*Koeffizienten[k+1],k=0..n);
      if s<>j then
        M(j+1,s+1):=M(s+1,j+1);
      end if;
      print(M,1);
    end do;
    print(testb1);print(coeff(a[n][s],x,2));print(Koeffizienten[3]);print(testb2);
    V(s+1):=-sum(coeff(a[n][s],x,k)*Koeffizienten[k+1],k=0..n);
    
    print(M,V);
  end do;
print(M,V);
K:=LinearSolve(M,V);
K(n+1):=1;
print(K);

print(test2,coeff(a[max(3,2)][min(1,2)],x,2));
print(Koeffizienten[3]);
for l from 0 to n do
  for m from 0 to numelems(Liste)do
    print(Koeffizienten[m+1]*coeff(a[7][l],x,m),a[7][l],m,Koeff,Koeffizienten[m+1])
  end do;
end do;
for l from 0 to n do
  print(K(l+1)*add(Koeffizienten[m+1]*coeff(a[max(k,l)][min(k,l)],x,m),m=0..numelems(Liste)));
end do;
    nNeu:=add(p[k]*add(K(l+1)*add(Koeffizienten[m+1]*coeff(a[max(k,l)][min(k,l)],x,m),m=0..numelems(Liste)),l=0..n),k=numelems(Liste)..numelems(Liste)+n);
fsolve(nNeu);
Em:=add(p[i]*K[i+1],i=0..n);
Hnm:=Hn*Em;
KnotenHnm:=fsolve(Hnm);
print(Hn,alt,Em,neu,Hnm);
print(Testergebnis,nNeu);
print(fsolve(Hnm),fsolve(nNeu));
KoeffizientenHnm:=Reverse(Basenwechsel(Hnm,n+numelems(Liste)));  #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
print(KoeffizientenHnm);
h0:=int(diff(G,x),x=Unten..Oben);
b[n+numelems(Liste)+2]:=0;
b[n+numelems(Liste)+1]:=0;
  for i from 1 to n+numelems(Liste) do
    for j from n+numelems(Liste) by -1 to 1 do
      print(test21);
      b[j]:=KoeffizientenHnm[j]+(d[j]+KnotenHnm[i]*c[j])*b[j+1]+e[j+1]*b[j+2];
  print(test22);
    end do;
    print(test23);
    gxi:=quo(Hnm,x-KnotenHnm[i],x);
   print(test24);
    Gewichte[i]:=c[1]*b[2]*h0/gxi(i);
   
    Delta[i]:=c[1]*b[2];
  end do;
print(KnotenHnm);
print(Gewichte);
sum(Knoten[k]*Gewichte[k],k=1..n+numelems(Liste));
end proc

With the first use of the subprocedure Basenwechsel, everything works fine. With the input

NEUZMinus(-1,1,x,x,[-sqrt(3/5),0,sqrt(3/5)],4)

I get the result [0,0,0,1,0] correctly.

The following time I use it, the polynomial is different, and m is 7 in that case, so the list should have 8 entries, it just returns the same [0,0,0,1,0] again, however. Changing the polynomial in the first application to say 5*Hn results in [0,0,0,5,0] in both cases again. The procedure seems to have saved the old values and never overwrites them. How can I fix this? I have highlighted the use of the procedure with exclamation marks.

 

Thank you in advance!

P.S.: The lengthy result is this:

NEUZMinus(-1,1,x,x,[-sqrt(3/5),0,sqrt(3/5)],4)

                               x
                              2   1
                             x  - -
                                  3
                             3   3  
                            x  - - x
                                 5  
                          4   3    6  2
                         x  + -- - - x
                              35   7   
                        5   5      10  3
                       x  + -- x - -- x
                            21     9    
                     6    5    5   2   15  4
                    x  - --- + -- x  - -- x
                         231   11      11   
                   7   35      105  3   21  5
                  x  - --- x + --- x  - -- x
                       429     143      13   
                8    7     28   2   14  4   28  6
               x  + ---- - --- x  + -- x  - -- x
                    1287   143      13      15   
              9    63      84   3   126  5   36  7
             x  + ---- x - --- x  + --- x  - -- x
                  2431     221      85       17   
         10    63     315   2   210  4   630  6   45  8
        x   - ----- + ---- x  - --- x  + --- x  - -- x
              46189   4199      323      323      19   
         11    33      55   3   330  5   330  7   55  9
        x   - ---- x + --- x  - --- x  + --- x  - -- x
              4199     323      323      133      21   
    12    33     198   2   2475  4   660  6   495  8   66  10
   x   + ----- - ---- x  + ---- x  - --- x  + --- x  - -- x  
         96577   7429      7429      437      161      23    
 13    429       2574   3   1287  5   1716  7   429  9   78  11
x   + ------ x - ----- x  + ---- x  - ---- x  + --- x  - -- x  
      185725     37145      2185      805       115      25    
     14     143      1001   2   1001  4   1001  6   1001  8
    x   - ------- + ------ x  - ---- x  + ---- x  - ---- x
          1671525   111435      6555      1035      345    

         1001  10   91  12
       + ---- x   - -- x  
         225        27    
                           1   (1/2)   
                         - - 15     , 3
                           5           
               /    1   (1/2)\   /    1   (1/2)\
               |x + - 15     | x |x - - 15     |
               \    5        /   \    5        /
           /    1   (1/2)\   /    1   (1/2)\   4   3    6  2
   Anfang, |x + - 15     | x |x - - 15     |, x  + -- - - x
           \    5        /   \    5        /       35   7   
                            3   3     3   3  
                   Anfang, x  - - x, x  - - x
                                5         5  
                                   2   1
                       Anfang, 0, x  - -
                                       3
                          Anfang, 0, x
                          Anfang, 0, 1
                     [0, 0, 0, 1, 0], HIER #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                            c, d, e
                            0, as1s
                            0, as1s
                            0, as1s
                            0, as1s
                            0, as1s
                            0, as1s
                           4   2    4
                           -- x  + x
                           15        
                               0
                            4    9   2
                          - -- - -- x
                            45   35   
                               1  2
                             - - x
                               3   
                           9   3    5
                           -- x  + x
                           35        
                               0
                          12      16  3
                        - --- x - -- x
                          175     63   
                               1  3
                             - - x
                               3   
                      12   2   8   4    6
                      --- x  + -- x  + x
                      175      45        
                               0
                        4     8   2   25  4
                     - --- - --- x  - -- x
                       175   175      99   
                          12   2   4   4
                        - --- x  - -- x
                          175      15   
                           16  4    6
                           -- x  + x
                           63        
                               0
                          16   2   25  4
                        - --- x  - -- x
                          245      99   
                               1  4
                             - - x
                               3   
                      16   3   40   5    7
                      --- x  + --- x  + x
                      245      231        
                               0
                     64       640   3   36   5
                  - ---- x - ----- x  - --- x
                    3675     14553      143   
                          64   3   4   5
                        - --- x  - -- x
                          945      15   
                  64   2   16   4   72   6    8
                 ---- x  + --- x  + --- x  + x
                 3675      385      455        
                               0
                64      144   2    40   4   49   6
             - ----- - ----- x  - ---- x  - --- x
               11025   13475      1001      195   
                     24   4   9   6   144   2
                   - --- x  - -- x  - ---- x
                     539      35      8575   
                           25  5    7
                           -- x  + x
                           99        
                               0
                         400   3   36   5
                       - ---- x  - --- x
                         6237      143   
                               1  5
                             - - x
                               3   
                     400   4   20   6    8
                     ---- x  + --- x  + x
                     6237      117        
                               0
                    80   2    500   4   49   6
                 - ---- x  - ----- x  - --- x
                   4851      11583      195   
                          20   4   4   6
                        - --- x  - -- x
                          297      15   
                  80   3    40   5   7   7    9
                 ---- x  + ---- x  + -- x  + x
                 4851      1001      45        
                               0
                64        640   3   28   5   64   7
             - ----- x - ----- x  - --- x  - --- x
               14553     63063      715      255   
                     4   5   9   7    80   3
                   - -- x  - -- x  - ---- x
                     91      35      4851   
           64    2    640   4   16   6   160   8    10
          ----- x  + ----- x  + --- x  + ---- x  + x  
          14553      63063      455      1071         
                               0
           64      128   2    80   4   224   6   81   8
        - ----- - ----- x  - ---- x  - ---- x  - --- x
          43659   49049      9009      5967      323   
               640   4   16   6   16  8    1280   2
            - ----- x  - --- x  - -- x  - ------ x
              63063      405      63      305613   
                          36   6    8
                          --- x  + x
                          143        
                               0
                         100   4   49   6
                       - ---- x  - --- x
                         1573      195   
                               1  6
                             - - x
                               3   
                     100   5   28   7    9
                     ---- x  + --- x  + x
                     1573      165        
                               0
                   1600   3   336   5   64   7
                 - ----- x  - ---- x  - --- x
                   99099      7865      255   
                          48   5   4   7
                        - --- x  - -- x
                          715      15   
                1600   4   28   6   144  8    10
                ----- x  + --- x  + --- x  + x  
                99099      715      935         
                               0
              320   2    140   4   2352   6   81   8
           - ----- x  - ----- x  - ----- x  - --- x
             77077      14157      60775      323   
                    12   6   9   8    180   4
                  - --- x  - -- x  - ----- x
                    275      35      11011   
           320   3    320   5   32   7   216   9    11
          ----- x  + ----- x  + --- x  + ---- x  + x  
          77077      33033      935      1463         
                               0
       256        5120    3    1152   5    4608   7   100  9
    - ------ x - ------- x  - ------ x  - ------ x  - --- x
      231231     2081079      133705      124355      399   
               64   5   256   7   16  9    25600   3
            - ---- x  - ---- x  - -- x  - ------- x
              6435      6545      63      6243237   
   256    2    320    4    1280   6    800   8   100  10    12
  ------ x  + ------ x  + ------ x  + ----- x  + --- x   + x  
  231231      127413      153153      24871      693          
                               0
   256      64    2    32000    4    1120   6    900   8   121  10
- ------ - ----- x  - -------- x  - ------ x  - ----- x  - --- x  
  693693   99099      15162147      138567      24871      483    
       8000    4    160   6    600   8   25  10    8000    2
    - ------- x  - ----- x  - ----- x  - -- x   - ------- x
      3270267      18513      16093      99       7630623   
                          49   7    9
                          --- x  + x
                          195        
                               0
                         588   5   64   7
                       - ---- x  - --- x
                         9295      255   
                               1  7
                             - - x
                               3   
                     588   6   112  8    10
                     ---- x  + --- x  + x  
                     9295      663         
                               0
                   980   4    5488   6   81   8
                - ----- x  - ------ x  - --- x
                  61347      129285      323   
                         196   6   4   8
                       - ---- x  - -- x
                         2925      15   
               980   5   2352   7   189   9    11
              ----- x  + ----- x  + ---- x  + x  
              61347      60775      1235         
                               0
            2240   3    84672   5    4032   7   100  9
         - ------ x  - ------- x  - ------ x  - --- x
           552123      8690825      104975      399   
                     48   7   9   9    756   5
                  - ---- x  - -- x  - ----- x
                    1105      35      46475   
         2240   4    896   6    7776   8   40   10    12
        ------ x  + ----- x  + ------ x  + --- x   + x  
        552123      94809      230945      273          
                               0
      64    2    22400   4    127008   6   1080   8   121  10
   - ----- x  - ------- x  - -------- x  - ----- x  - --- x  
     61347      9386091      15011425      29393      483    
              1792   6    48   8   16  10    2240   4
           - ------ x  - ---- x  - -- x   - ------ x
             182325      1235      63       552123   
  64    3    22400   5    1120   7    600   9   385   11    13
 ----- x  + ------- x  + ------ x  + ----- x  + ---- x   + x  
 61347      9386091      138567      19019      2691          
                               0
    256        51200    3    13440   5    2560   7    5500   9
 - ------ x - -------- x  - ------- x  - ------ x  - ------ x
   920205     84474819      6605027      323323      153387   

      144  11
    - --- x  
      575    
      22400   5    4320   7   1000   9   25  11    56000    3
   - ------- x  - ------ x  - ----- x  - -- x   - -------- x
     9386091      508079      27027      99       54660177   
  256    2     7168    4    13440   6    80000    8   100   10
 ------ x  + -------- x  + ------- x  + -------- x  + ---- x  
 920205      11471889      6605027      10669659      3289    

      504   12    14
    + ---- x   + x  
      3575          
                               0
    256       3072    2    112000    4    112000   6    8100    8
- ------- - -------- x  - --------- x  - -------- x  - ------- x
  2760615   19119815      217965891      59445243      1062347   

     264   10   169  12
   - ---- x   - --- x  
     7475       675    
     89600    4    13440   6    21600   8   140   10   36   12
 - --------- x  - ------- x  - ------- x  - ---- x   - --- x  
   149134557      6605027      2719717      3887       143    

        768    2
    - ------- x
      2924207   
                        1, Polynom[0][0]
                        x, Polynom[1][0]
                     1    2               
                     - + x , Polynom[1][1]
                     3                    
                        2               
                       x , Polynom[2][0]
                    4       3               
                    -- x + x , Polynom[2][1]
                    15                      
                 4   2    4   4                
                 -- x  + x  + --, Polynom[2][2]
                 21           45               
             Matrix(%id = 18446745693991291350), 1
                             testb1
                               0
                               0
                             testb2
          Matrix(%id = 18446745693991291350),

            Vector[column](%id = 18446745693991291470)
             Matrix(%id = 18446745693991291350), 1
             Matrix(%id = 18446745693991291350), 1
                             testb1
                               0
                               0
                             testb2
          Matrix(%id = 18446745693991291350),

            Vector[column](%id = 18446745693991291470)
             Matrix(%id = 18446745693991291350), 1
             Matrix(%id = 18446745693991291350), 1
             Matrix(%id = 18446745693991291350), 1
                             testb1
                              16
                              ---
                              245
                               0
                             testb2
          Matrix(%id = 18446745693991291350),

            Vector[column](%id = 18446745693991291470)
             Matrix(%id = 18446745693991291350), 1
             Matrix(%id = 18446745693991291350), 1
             Matrix(%id = 18446745693991291350), 1
             Matrix(%id = 18446745693991291350), 1
                             testb1
                               0
                               0
                             testb2
          Matrix(%id = 18446745693991291350),

            Vector[column](%id = 18446745693991291470)
          Matrix(%id = 18446745693991291350),

            Vector[column](%id = 18446745693991291470)
           Vector[column](%id = 18446745693991291830)
                                  9
                           test2, --
                                  35
                               0
                           7             
                       0, x , 0, Koeff, 0
                           7             
                       0, x , 1, Koeff, 0
                           7             
                       0, x , 2, Koeff, 0
                           7             
                       0, x , 3, Koeff, 1
                     49   6    8             
                  0, --- x  + x , 0, Koeff, 0
                     195                     
                     49   6    8             
                  0, --- x  + x , 1, Koeff, 0
                     195                     
                     49   6    8             
                  0, --- x  + x , 2, Koeff, 0
                     195                     
                     49   6    8             
                  0, --- x  + x , 3, Koeff, 1
                     195                     
                112  7    9   588   5             
             0, --- x  + x  + ---- x , 0, Koeff, 0
                663           9295                
                112  7    9   588   5             
             0, --- x  + x  + ---- x , 1, Koeff, 0
                663           9295                
                112  7    9   588   5             
             0, --- x  + x  + ---- x , 2, Koeff, 0
                663           9295                
                112  7    9   588   5             
             0, --- x  + x  + ---- x , 3, Koeff, 1
                663           9295                
         2352   6   189   8    10    980   4             
      0, ----- x  + ---- x  + x   + ----- x , 0, Koeff, 0
         60775      1235            61347                
         2352   6   189   8    10    980   4             
      0, ----- x  + ---- x  + x   + ----- x , 1, Koeff, 0
         60775      1235            61347                
         2352   6   189   8    10    980   4             
      0, ----- x  + ---- x  + x   + ----- x , 2, Koeff, 0
         60775      1235            61347                
         2352   6   189   8    10    980   4             
      0, ----- x  + ---- x  + x   + ----- x , 3, Koeff, 1
         60775      1235            61347                
    896   5    7776   7   40   9    11    2240   3             
0, ----- x  + ------ x  + --- x  + x   + ------ x , 0, Koeff, 0
   94809      230945      273            552123                
    896   5    7776   7   40   9    11    2240   3             
0, ----- x  + ------ x  + --- x  + x   + ------ x , 1, Koeff, 0
   94809      230945      273            552123                
    896   5    7776   7   40   9    11    2240   3             
0, ----- x  + ------ x  + --- x  + x   + ------ x , 2, Koeff, 0
   94809      230945      273            552123                
   2240    896   5    7776   7   40   9    11    2240   3     
  ------, ----- x  + ------ x  + --- x  + x   + ------ x , 3,
  552123  94809      230945      273            552123        

    Koeff, 1
                               0
                               0
                               0
                               0
                               0
/    1   (1/2)\   /    1   (1/2)\       155   10  2    4       
|x + - 15     | x |x - - 15     |, alt, --- - -- x  + x , neu,
\    5        /   \    5        /       891   9                

  /    1   (1/2)\   /    1   (1/2)\ /155   10  2    4\
  |x + - 15     | x |x - - 15     | |--- - -- x  + x |
  \    5        /   \    5        / \891   9         /
 Testergebnis,

      2459840   5    80254400        188027200   3    2240   7
   - --------- x  - ----------- x + ----------- x  + ------ x
     193795173      44766684963     19185722127      552123   
-0.9604912687, -0.7745966692, -0.4342437493, 0., 0.4342437493,

  0.7745966692, 0.9604912687, -1.435338337, -0.8946894490,

  -0.5176357564, 0., 0.5176357564, 0.8946894490, 1.435338337
                        [0, 0, 0, 1, 0] #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                             test21
Error, (in NEUZMinus) invalid subscript selector

 

I want to contnue the simulation from the point (time) that the event accure 

how can I do it ?

 

Hello there, 

When I tried to solve a set of equations, represented in a matrix form, Maple complained. After the matrix form was decomposed to row by row and solve was attempted, Maple became happy. I wonder if I can solve the set of equations in a matrix form. 


 

Goal: solve this set of equations in terms of Xl12/Xl23/Xl13

X1 = 0.5 * ( Xl12 + Xl13 - Xl23 )
X2 = 0.5 * ( Xl12 + Xl23 - Xl13 )
X3 = 0.5 * ( Xl13 + Xl23 - Xl12 )

X:=<X1, X2, X3>;

Vector(3, {(1) = X1, (2) = X2, (3) = X3})

(1)

Xeq:= X = <1/2*(xl12 + xl13-xl23), 1/2*(xl12 + xl23-xl13), 1/2*(xl13 + xl23-xl12)>;

(Vector(3, {(1) = X1, (2) = X2, (3) = X3})) = (Vector(3, {(1) = (1/2)*xl12+(1/2)*xl13-(1/2)*xl23, (2) = (1/2)*xl12+(1/2)*xl23-(1/2)*xl13, (3) = (1/2)*xl13+(1/2)*xl23-(1/2)*xl12}))

(2)

solve(Xeq, {xl12, xl13, xl23});

Error, invalid input: solve expects its 1st argument, eqs, to be of type {`and`, `not`, `or`, algebraic, relation(algebraic), ({list, set})({`and`, `not`, `or`, algebraic, relation(algebraic)})}, but received (Vector(3, {(1) = X1, (2) = X2, (3) = X3})) = (Vector(3, {(1) = (1/2)*xl12+(1/2)*xl13-(1/2)*xl23, (2) = (1/2)*xl12+(1/2)*xl23-(1/2)*xl13, (3) = (1/2)*xl13+(1/2)*xl23-(1/2)*xl12}))

 

Did not work.

solve({X1=1/2*(xl12 + xl13-xl23), X2=1/2*(xl12 + xl23-xl13), X3=1/2*(xl13 + xl23-xl12)}, {xl12, xl13, xl23});

{xl12 = X1+X2, xl13 = X3+X1, xl23 = X2+X3}

(3)

Did work.

 


 

Download Q_20200609.mw

I want to shade the function y=x*ln(x) on the domain of (0,1].

It would seem that if a package is loaded at the "top-level" via with() and the worksheet also has a procedure definition which contains a 'uses' statement for the same package (OK, admittedly a bit redundant), the commands from the relevant package actually "go missing".

See the output from test4() in the attached.

I can't believe that this is deliberate, because when trying to 'compartmentalise' code, then a 'uses' statement in a procedure seems like a good idea. To have this fail because the "top-level" worksheet contains a with() statement loading the same package seems perverse.

Please don't post workarounds - I already know several ways to do achieve it. I'm trying to find out if this behaviour is "deliberate" or a "bug". If the latter, it has been around for a long time because I have checked all the way back to Maple 18: every version exhibits the same behaviour

  restart:

  kernelopts(version);
  test1:= proc(M::Matrix)
               uses LinearAlgebra:
               return MatrixInverse(M):
          end proc:
  test2:= proc(M::Matrix)
               return LinearAlgebra:-MatrixInverse(M):
          end proc:
  with(LinearAlgebra):
  test3:= proc(M::Matrix)
               return MatrixInverse(M):
          end proc:
  test4:= proc(M::Matrix)
               uses LinearAlgebra:
               return MatrixInverse(M):
          end proc:
  test1( Matrix( [[1,2],[3,4]]));
  test2( Matrix( [[1,2],[3,4]]));
  test3( Matrix( [[1,2],[3,4]]));
  test4( Matrix( [[1,2],[3,4]]));

`Maple 2020.0, X86 64 WINDOWS, Mar 4 2020, Build ID 1455132`

 

Matrix(2, 2, {(1, 1) = -2, (1, 2) = 1, (2, 1) = 3/2, (2, 2) = -1/2})

 

Matrix(2, 2, {(1, 1) = -2, (1, 2) = 1, (2, 1) = 3/2, (2, 2) = -1/2})

 

Matrix(2, 2, {(1, 1) = -2, (1, 2) = 1, (2, 1) = 3/2, (2, 2) = -1/2})

 

MatrixInverse(Matrix(%id = 18446744074373391174))

(1)

 

Download usewith.mw

Please everybody, help me to make phaseportrait 3D

Maple's pdsolve() is quite capable of solving the PDE that describes the motion of a single-span Euler beam.  As far as I have been able to ascertain, there is no obvious way of applying pdsolve() to solve multi-span beams.  The worksheet attached to this post provides tools for solving multi-span Euler beams.  Shown below are a few demos.  The worksheet contains more demos.

 

A module for solving the Euler beam with the method of lines

beamsolve

 

The beamsolve proc solves a (possibly multi-span) Euler beam equation:``

"rho ((&PartialD;)^2u)/((&PartialD;)^( )t^2)+ ((&PartialD;)^2)/((&PartialD;)^( )x^2)(EI ((&PartialD;)^(2)u)/((&PartialD;)^( )x^(2)))=f"

subject to initial and boundary conditions.  The solution u = u(x, t) is the

transverse deflection of the beam at point x at time t, subject to the load
density (i.e., load per unit length) given by f = f(x, t). The coefficient rho 

is the beam's mass density (mass per unit length), E is the Young's modulus of

the beam's material, and I is the beam's cross-sectional moment of inertia

about the neutral axis.  The figure below illustrates a 3-span beam (drawn in green)
supported on four supports, and loaded by a variable density load (drawn in gray)
which may vary in time.  The objective is to determine the deformed shape of the
beam as a function of time.


The number of spans, their lengths, and the nature of the supports may be specified

as arguments to beamsolve.

 

In this worksheet we assume that rho, E, I are constants for simplicity. Since only
the product of the coefficients E and I enters the calculations, we lump the two

together into a single variable which we indicate with the two-letter symbol EI.

Commonly, EI is referred to as the beam's rigidity.

 

The PDE needs to be supplied with boundary conditions, two at each end, each

condition prescribing a value (possibly time-dependent) for one of u, u__x, u__xx, u__xxx 
(that's 36 possible combinations!) where I have used subscripts to indicate

derivatives.  Thus, for a single-span beam of length L, the following is an admissible

set of boundary conditions:
u(0, t) = 0, u__xx(0, t) = 0, u__xx(L, t) = 0, u__xxx(t) = sin*t.   (Oops, coorection, that last
condition was meant to be uxxx(L,t) = sin t.)

Additionally, the PDE needs to be supplied with initial conditions which express

the initial displacement and the initial velocity:
"u(x,0)=phi(x),   `u__t`(x,0)=psi(x)."

 

The PDE is solved through the Method of Lines.  Thus, each span is subdivided into

subintervals and the PDE's spatial derivatives are approximated through finite differences.

The time derivatives, however, are not discretized.  This reduces the PDE into a set of

ODEs which are solved with Maple's dsolve().  

 

Calling sequence:

        beamsolve(L, n, options)

 

Parameters:

        L:  List of span lengths, in order from left to right, as in [L__1, L__2 .. (), `L__&nu;`].

        n The number of subintervals in the shortest span (for the finite difference approximation)

 

Notes:

• 

It is assumed that the spans are laid back-to-back along the x axis, with the left end
of the overall beam at x = 0.

• 

The interior supports, that is, those supports where any two spans meet, are assumed
to be of the so-called simple type.  A simple support is immobile and it doesn't exert
a bending moment on the beam.  Supports at the far left and far right of the beam can
be of general type; see the BC_left and BC_right options below.

• 

If the beam consists of a single span, then the argument L may be entered as a number
rather than as a list. That is, L__1 is equivalent to [L__1].

 

Options:

        All options are of the form option_name=value, and have built-in default values.

        Only options that are other than the defaults need be specified.

 

        rho: the beam's (constant) mass density per unit length (default: rho = 1)

        EI: the beam's (constant) rigidity (default: EI = 1)

        T: solve the PDE over the time interval 0 < t and t < T (default: T = 1)

        F: an expression in x and t that describes the applied force f(x, t)  (default: F = 0)
        IC: the list [u(x, 0), u__t(x, 0)]of the initial displacement and velocity,  as
                expressions in x (default: IC = [0,0])

        BC_left: a list consisting of a pair of boundary conditions at the left end of
                the overall (possibly multi-span beam.  These can be any two of
                u = alpha(t), u_x = beta(t), u_xx = gamma(t), u_xxx = delta(t). The right-hand sides of these equations

                can be any expression in t.  The left-hand sides should be entered literally as indicated.

                If a right-hand side is omitted, it is taken to be zero.   (default: BC_left = [u, u_xx] which

                corresponds to a simple support).

        BC_right: like BC_left, but for the right end of the overall beam (default: BC_right = "[u,u_xx])"

 

The returned module:

        A call to beamsolve returns a module which presents three methods.  The methods are:

 

        plot (t, refine=val, options)

                plots the solution u(x, t) at time t.  If the discretization in the x direction

                is too coarse and the graph looks non-smooth, the refine option

                (default: refine=1) may be specified to smooth out the graph by introducing

                val number of intermediate points within each discretized subinterval.

                All other options are assumed to be plot options and are passed to plots:-display.

 

        plot3d (m=val, options)

                plots the surface u(x, t).  The optional m = val specification requests

                a grid consisting of val subintervals in the time direction (default: "m=25)"

                Note that this grid is for plotting purposes only; the solution is computed

                as a continuous (not discrete) function of time. All other options are assumed

                to be plot3d options and are passed to plots:-display.

 

        animate (frames=val, refine=val, options)

                produces an animation of the beam's motion.  The frames option (default = 50)

                specifies the number of animation frames.  The refine option is passed to plot
                (see the description above. All other options are assumed to be plot options and
                are passed to plots:-display.

Note:

        In specifying the boundary conditions, the following reminder can be helpful.  If the beam

        is considered to be horizontal, then u is the vertical displacement, `u__x ` is the slope,  EI*u__xx

        is the bending moment, and EI*u__xxx is the transverse shear force.

 

A single-span simply-supported beam with initial velocity

 

The function u(x, t) = sin(Pi*x)*sin(Pi^2*t) is an exact solution of a simply supported beam with

"u(x,0)=0,   `u__t`(x,0)=Pi^(2)sin(Pi x)."  The solution is periodic in time with period 2/Pi.

sol := beamsolve(1, 25, 'T'=2/Pi, 'IC'=[0, Pi^2*sin(Pi*x)]):
sol:-animate(size=[600,250]);

The initial condition u(x, 0) = 0, u__t(x, 0) = 1  does not lead to a separable form, and

therefore the motion is more complex.

sol := beamsolve(1, 25, 'T'=2/Pi, 'IC'=[0, 1]):
sol:-animate(frames=200, size=[600,250]);


 

A single-span cantilever beam

 

A cantilever beam with initial condition "u(x,0)=g(x),  `u__t`(x,0)=0," where g(x) is the
first eigenmode of its free vibration (calculated in another spreadsheet).  The motion is
periodic in time, with period "1.787018777."

g := 0.5*cos(1.875104069*x) - 0.5*cosh(1.875104069*x) - 0.3670477570*sin(1.875104069*x) + 0.3670477570*sinh(1.875104069*x):
sol := beamsolve(1, 25, 'T'=1.787018777, 'BC_left'=[u,u_x], 'BC_right'=[u_xx,u_xxx], 'IC'=[g, 0]):
sol:-animate(size=[600,250]);

If the initial condition is not an eigenmode, then the solution is rather chaotic.

sol := beamsolve(1, 25, 'T'=3.57, 'BC_left'=[u,u_x], 'BC_right'=[u_xx,u_xxx], 'IC'=[-x^2, 0]):
sol:-animate(size=[600,250], frames=100);


 

A single-span cantilever beam with a weight hanging from its free end

 

sol := beamsolve(1, 25, 'T'=3.57, 'BC_left'=[u,u_x], 'BC_right'=[u_xx,u_xxx=1]):
sol:-animate(size=[600,250], frames=100);


 

A single-span cantilever beam with oscillating support

 

sol := beamsolve(1, 25, 'T'=Pi, 'BC_left'=[u=0.1*sin(10*t),u_x], 'BC_right'=[u_xx,u_xxx]):
sol:-animate(size=[600,250], frames=100);


 

A dual-span simply-supported beam with moving load

 

Load moves across a dual-span beam.

The beam continues oscillating after the load leaves.

d := 0.4:  T := 4:  nframes := 100:
myload := - max(0, -6*(x - t)*(d + x - t)/d^3):
sol := beamsolve([1,1], 20, 'T'=T, 'F'=myload):
sol:-animate(frames=nframes):
plots:-animate(plot, [2e-3*myload(x,t), x=0..2, thickness=1, filled=[color="Green"]], t=0..T, frames=nframes):
plots:-display([%%,%], size=[600,250]);


 

A triple-span simply-supported beam with moving load

 

Load moves across a triple-span beam.

The beam continues oscillating after the load leaves.

d := 0.4:  T := 6: nframes := 100:
myload := - max(0, -6*(x - t)*(d + x - t)/d^3):
sol := beamsolve([1,1,1], 20, 'T'=T, 'F'=myload):
sol:-plot3d(m=50);
sol:-animate(frames=nframes):
plots:-animate(plot, [2e-3*myload(x,t), x=0..3, thickness=1, filled=[color="Green"]], t=0..T, frames=nframes):
plots:-display([%%,%], size=[600,250]);

z3d;


 

A triple-span beam, moving load falling off the cantilever end

 

In this demo the load move across a multi-span beam with a cantilever section at the right.

As it skips past the cantilever end, the beam snaps back violently.

d := 0.4:  T := 8: nframes := 200:
myload := - max(0, -6*(x - t/2)*(d + x - t/2)/d^3):
sol := beamsolve([1,1,1/2], 10, 'T'=T, 'F'=myload, BC_right=[u_xx, u_xxx]):
sol:-animate(frames=nframes):
plots:-animate(plot, [1e-2*myload(x,t), x=0..3, thickness=1, filled=[color="Green"]], t=0..T, frames=nframes):
plots:-display([%%,%], size=[600,250]);


 


Download worksheet: euler-beam-with-method-of-lines.mw

 

f:= (ln(4x-4)/4)-(ln(4x+4)/4)+(arctan(x)/2)

When I do plots([f(x),f(x)-2,f(x)+2]), the graphs don't extend infinitely like I want. They stop just themselves. How get I the plots to extended more? I attached a picture. 

it really confused, with generating different sample some times the command fsolve is working and some times don't . is there any other way to solve this system of equations. because I am going to generate 1000 samples and for each sample, I supposed to solve this system.
 

``

with(LinearAlgebra):
NULL

 

 

``

f[1] := VectorCalculus:-`+`(VectorCalculus:-`+`(VectorCalculus:-`+`(VectorCalculus:-`+`(VectorCalculus:-`*`(VectorCalculus:-`+`(n_x, n_y), 1/theta1), VectorCalculus:-`-`(sum(VectorCalculus:-`*`(VectorCalculus:-`*`(VectorCalculus:-`+`(theta2, -1), x[t]), 1/VectorCalculus:-`+`(VectorCalculus:-`*`(VectorCalculus:-`*`(theta1, theta2), x[t]), 1)), t = 1 .. n_x))), VectorCalculus:-`-`(sum(VectorCalculus:-`*`(VectorCalculus:-`*`(VectorCalculus:-`+`(2, R_x[t]), x[t]), 1/VectorCalculus:-`*`(VectorCalculus:-`+`(VectorCalculus:-`*`(VectorCalculus:-`*`(theta1, theta2), x[t]), 1)^VectorCalculus:-`+`(1, VectorCalculus:-`-`(1/theta2)), VectorCalculus:-`+`(VectorCalculus:-`+`(VectorCalculus:-`+`(VectorCalculus:-`*`(VectorCalculus:-`*`(theta1, theta2), x[t]), 1)^(1/theta2), -1), theta3))), t = 1 .. n_x))), VectorCalculus:-`-`(sum(VectorCalculus:-`*`(VectorCalculus:-`*`(VectorCalculus:-`+`(theta2, -1), y[T]), 1/VectorCalculus:-`+`(VectorCalculus:-`*`(VectorCalculus:-`*`(theta1, theta2), y[T]), 1)), T = 1 .. n_y))), VectorCalculus:-`-`(sum(VectorCalculus:-`*`(VectorCalculus:-`*`(VectorCalculus:-`+`(2, R_y[T]), y[T]), 1/VectorCalculus:-`*`(VectorCalculus:-`+`(VectorCalculus:-`*`(VectorCalculus:-`*`(theta1, theta2), y[T]), 1)^VectorCalculus:-`+`(1, VectorCalculus:-`-`(1/theta2)), VectorCalculus:-`+`(VectorCalculus:-`+`(VectorCalculus:-`+`(VectorCalculus:-`*`(VectorCalculus:-`*`(theta1, theta2), y[T]), 1)^(1/theta2), -1), theta4))), T = 1 .. n_y))):

N_x := 30:

n_x := 30:

NULL

R_x := [seq(0, nl = 1 .. 30)];

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

 

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

(1)

`&lambda;&lambda;` := 5; -1; QQ := 1; -1; `&alpha;&alpha;1` := 2; -1; `&alpha;&alpha;2` := 4

4

(2)

W := GenerateUniform(n_x, 0, 1):
``

fsolve({f[1], f[2], f[3], f[4]}, {theta1 = 0 .. infinity, theta2 = 0 .. infinity, theta3 = .5 .. infinity, theta4 = .5 .. infinity})

 

(3)

``

``


 

Download ask_maple.mw

I just need someone to explain to me why the following occurs:

 

 

 

showstat(rand)


rand := proc(r::{posint, numeric .. numeric}, $)
   1   if nargs = 0 then
   2     RandomTools:-MersenneTwister:-GenerateInteger()
       else
   3     try
   4       if type(r,('numeric') .. ('numeric')) then
   5         if rhs(r) < lhs(r) then
   6           error "invalid range, end points are out of order"
             elif not type(r,('integer') .. ('integer')) then
   7           return () -> RandomTools:-Generate(float(('range') = r,('method') = ('uniform')))
             end if
           end if;
   8       return RandomTools:-MersenneTwister:-NewGenerator(('range') = r)
         catch :
   9       error
         end try
       end if
end proc

 

NULL

showstat(RandomTools:-MersenneTwister:-GenerateInteger)


RandomTools:-MersenneTwister:-GenerateInteger := proc({range::{integer, integer .. integer} := 1000000000000}, $)
local bits, divisor, offset;
   1   if nargs = 0 then
   2     return MTKernelInterface(4)
       end if;
   3   if type(range,'integer') then
   4     divisor := range;
   5     offset := 0
       else
   6     if rhs(range) < lhs(range) then
   7       error "illegal range, end points out of order"
         end if;
   8     if lhs(range) = rhs(range) then
   9       return lhs(range)
         end if;
  10     offset := lhs(range);
  11     divisor := rhs(range)-offset+1
       end if;
  12   if divisor = 0 then
  13     return offset
       end if;
  14   bits := MTKernelInterface(5,divisor);
  15   MTKernelInterface(6,divisor,bits)+offset
end proc

 

NULL

showstat(MTKernelInterface)

Error, (in showstat) procedure name expected

 

``

``

 

 

Download rand_showstat.mw

Does maple provide any method for finding the saddle point of a function? Thank you

I am trying to write maple program for Gauss Siedel method. I needed two for loop. One for running the iterative method and the other for checking where (the number of iteration required) the results converge.

Please, I need help. 

 

Thanks. 

Hi guys! I'm having trouble using int with a few expressions, for example:

is returning

however simpler expressions such as

int(x^2 + x, x)

or int(x/2 + 1/2, x)

are working correctly and returning 

respectively. I'm using Maple 2020 in worksheet mode using Math 2D Input/Output.

Here's my screen, any help would be much appreciated thanks!

Hi,

I'm trying to solve for Double Inequality. (1.1) and (1.3) combined.

Thanks in Advance
 

Example: Solving a Double Inequality

 

-3 <= 6*x-1

0 <= 6*x+2

(1.1)

"(->)"

[[-1/3 <= x]]

(1.2)

6*x-1 < 3

6*x < 4

(1.3)

"(->)"[[x < 2/3]]

"ex1(x):=6 x-1"

proc (x) options operator, arrow, function_assign; 6*x-1 end proc

(1.4)

"->"

 

"->"

"ex2(y):=3"

proc (y) options operator, arrow, function_assign; 3 end proc

(1.5)

"ex3(y):=-3"

proc (y) options operator, arrow, function_assign; -3 end proc

(1.6)

NULL


 

Download Double_Inequality.mw

First 417 418 419 420 421 422 423 Last Page 419 of 2097