MaplePrimes Questions

Hello,

I am trying to parallelize the output of my Maple18 program, such that it is able to write into multiple smaller output files at the same time, rather than into one unique big file spending much time in this operation...

This is the code:

 

 


 

 

 

As you can see from the code, I have tried with different combinations of options. The errors that I get are:

-----------------------------------------

(only one file: "rows-1 < 10000")

Option1A = Error, (in fprintf) string expected for string format

Option1B = Error, (in unspecified) Too many levels of recursion for display

Option2A = OK (but there isn't parallelism here....)

Option2B = OK (but there isn't parallelism here....)

--------

(more than one file: "rows-1 > 10000") 

Option1A = Error, (in fprintf) string expected for string format

Option1B = Error, (in unspecified) Too many levels of recursion for display

Option2A = Error, (in StringTools:-Split) first argument must be a string

Option2B = Error, (in StringTools:-Split) first argument must be a string

-----------------------------------------


Instead, if I simplify the definition of D_vol to one single sum (for exemple 2+2), this is what I get:

-----------------------------------------

(only one file: "rows-1 < 10000")

Option1A = OK (but there isn't parallelism here, and the example is trivial 2+2=4)

Option1B = OK (but there isn't parallelism here, and the example is trivial 2+2=4)

Option2A = OK (but there isn't parallelism here, and the example is trivial 2+2=4)

Option2B = OK (but there isn't parallelism here, and the example is trivial 2+2=4)

--------

(more than one file: "rows-1 > 10000") 

Option1A = OK (but the example is trivial 2+2=4)

Option1B = OK (but the example is trivial 2+2=4)

Option2A = Error, (in StringTools:-Split) first argument must be a string

Option2B = Error, (in StringTools:-Split) first argument must be a string

-----------------------------------------

Can you please help me? Any advice wil be really useful....

Thanks

 

in maple, i can't use print? Help me. Please.

I'm trying to make a Least-Squares curve fitting plot.  I need to sequence two rows from a data file I imported (see attached worksheet GR10_20190130_PSA_TESTS.mw).  More specifically, I need to sequence the data in

X:=Row(T,1) with the data in y:=Row(T,2).  It should look like

([41115.0,6.97],[41257.0,18.9],[41270.0,15.67]...[43495.0,4.06]) when complete.  I tried seq[X_k,Y_k], that didn't work.  Also tried using an index of 1 to 25 (the number of elements in each row), that didn't work.  Any help with this appreciated, thanks in advance!

Les

Hi

For educational needs; I try to animated some statistical concepts with simple statistical commands of Maple on 2018. The WorkSheet  in appendix, gives the desired animations, but with rather heavy procedures. Thanks for your help.

Proc1limitmgf_(1).mw 

Hi !
I made a program that solves a series of system of linear equations of increasing dimension.
Equations with rational numbers. I have a list of equations "liseq1" and a list of variables "lisvar1".
I use the following command :
 
solve(liseq1,lisvar1) ;
 
When the equation system reaches dimension 32, Maple gives me the following error message :
 
"Error, (in LinearAlgebra:-Modular:-IntegerLinearSolve) invalid arguments to iratrecon" .
 
It is an overdetermined system with 33 equations and 32 unknowns .
The variables are defined with the command:
 x: = array (0..31) ;
 
I managed to work around the problem by replacing the variables with the following commands :
 
lissub: = seq (x[i] = x||i, i = 0..31) ;
lisvar2: = subs(lissub, lisvar1) ;
liseq2: = subs(lissub, liseq1) ;
solve (liseq2, lisvar2);
 
If you run the file I sent, Maple sometimes gives the desired answer but in a random way
because if you run the last 3 lines in a different order you will get the answer or the
error message .
 
Something remains in memory. Sorry, but it's a bug.
I have Windows 10, 64 bit with Maple 2018.2.
Regards .

Hello,

I'm a long-time Maple user and have used the CodeGeneration package in the past, but with a recent download of Maple 2018, I'm now getting an error I have never gotten before. Even when I do something simple (see below, for example), I get an error that reads "Error, (in clear) argument `` is incorrect or out of order". And I get this error no matter which language I choose. Any help would be much appreciated.

> with(CodeGeneration)

> R(exp(x))

Thanks!

 

 

Hello,

I do know how to define the finite field F_q=GF(p,k). But know I am looking at the residue class ring R:= \F_q[x]/(f) with f an arbitrary polynomial in F_q[x]  of degree(f)>1. And I need all the calculations over R. My f will be reducible, so R wont be a field. Can anyone help me how I tell Maple to do the arithmetic in R? With the right remainder calculation? And with [f]=[0], so that the sesidue class of f is the same as the residue class of 0?

Thank you very much for any help!!

 

Hello,

I would like to evaluate a funktion f in \F_q[x], where \F_q is a finite field with q=p^k. My algorithm is based on the fast multipoint evaluation algo in J. von zur Gathen/ J. Gerhard Modern Computer Algebra Edition 3. My proc FastEval does the right thing, but I dont know how to reach any of the calculatet values. And I will need all of the values for further procs! I tried it with lists, but (because of the recursive call??) I only get 1 value in the list... Does anyone know how to solve my problem? The return call only stops my proc after the first value has been calculated, that is why i used print. 
Please, can anyone help me? 
This is my first question asked in mapleprimes.com, so please excuse any mistakes.. Also I dont know how to put the maple stuff in here correctly??

I would be really really happy if anyone can help me... 
Kind regards from Germany
Melanie

\sourceon Maple
istZweierpotenz := proc (n::posint)  #checks if n=2^k for any k in N
local k, nTest; 
k := 0; nTest := 1; 
while nTest <= n do 
    if nTest = n then return true 
else nTest := 2*nTest; k := k+1
 end if 
end do;
 return false 
end proc; 

with(ListTools);

SubProdTree := proc (n::posint, u::(seq(anything))) 
local k, j, i, M::(polynom(integer, x)), leftList, rightList, kList; 
if istZweierpotenz(n) = true then k := log[2](n); 
if nops([u]) = n then 
for j to nops([u]) do M[0, j-1] := x-u[j] 
end do; 
for kList from 0 to k do leftList[0, kList] := [M[0, 2*kList]]; rightList[0, kList] := [M[0, 2*kList+1]]
 end do;
 for i to k do for j from 0 to 2^(k-i)-1 do M[i, j] := M[i-1, 2*j]*M[i-1, 2*j+1] 
end do;
 for kList from 0 to 2^(k-i-1)-1 do leftList[i, kList]
:= Flatten([[leftList[i-1, 2*kList]], [rightList[i-1, 2*kList]], M[i, 2*kList]]); rightList[i, kList]
:= Flatten([leftList[i-1, 2*kList+1], rightList[i-1, 2*kList+1], M[i, 2*kList+1]]) 
end do; 
if i = k then kList := 0;
leftList[i, kList] := Flatten([[leftList[i-1, 2*kList]], [rightList[i-1, 2*kList]], M[i, 2*kList]]) 
end if 
end do; 
return leftList[k, 0] 
else 
return false 
end if 
else return false 
end if 
end proc;

GoDownTree := proc (f::polynom, n::posint, l::list, p::posint) 
local func, prim, k, r0, r1, newLeftList, newRightList, numberPoint, newList; 
func := f; 
prim := p; 
numberPoint := n; 
k := log[2](numberPoint); 
newList := l; 
newLeftList := newList[1 .. numberPoint-1]; 
newRightList := newList[numberPoint .. 2*numberPoint-2]; 

if not isprime(prim) then return sprintf("%a ist nicht prim", prim) 
end if; 
if numberPoint < degree(func) then return false 
end if;
 if numberPoint = 1 then print(func) 
else 
r0 := evala(`mod`(Rem(func, newLeftList[-1], x), prim)); 
r1 := evala(`mod`(Rem(func, newRightList[-1], x), prim)); 
GoDownTree(r0, (1/2)*numberPoint, newLeftList, prim); 
GoDownTree(r1, (1/2)*numberPoint, newRightList, prim) 
end if 
end proc;

FastEval := proc (f::polynom, n::posint, p::posint, u::(seq(anything))) local l; 
l := SubProdTree(n, u); 
GoDownTree(f, n, l, p) 
end proc;

G := GF(11, 2); 
a := G:-extension; 
aOut := G:-ConvertOut(a); 
alias(alpha = RootOf(aOut)); 
l := SubProdTree(8, 1, 2, 3, 4, 5, 6, 7, 8); 
GoDownTree(x^2+x+1, 8, l, 11);

                           GF(11, 2)
                     / 2          \       
                     \T  + 6 T + 7/ mod 11
                           2          
                          T  + 6 T + 7
                             alpha
[x - 1, x - 2, (x - 1) (x - 2), x - 3, x - 4, (x - 3) (x - 4), 

  (x - 1) (x - 2) (x - 3) (x - 4), x - 5, x - 6, (x - 5) (x - 6), 

  x - 7, x - 8, (x - 7) (x - 8), (x - 5) (x - 6) (x - 7) (x - 8), 

  (x - 1) (x - 2) (x - 3) (x - 4) (x - 5) (x - 6) (x - 7) (x - 8)

  ]
                               3
                               7
                               2
                               10
                               9
                               10
                               2
                               7
FastEval(x^2+x+1, 8, 11, 1, 2, 3, 4, 5, 6, 7, 8);
                               3
                               7
                               2
                               10
                               9
                               10
                               2
                               7
\sourceoff

Trying to simulate tossing 10 coins. What  am i doing rong? Thanks

 

``

restart

a := Vector[row](1 .. 10)

Vector[row](%id = 18446745395177063238)

(1)

randomize()

for k to 10 do r := rand(1 .. 2); if r < .5 then a[k] := "H" else a[k] := "T"; print(a[k]) end if end do

proc () (proc () option builtin = RandNumberInterface; end proc)(6, 2, 1)+1 end proc

 

Error, cannot determine if this expression is true or false: r < .5

 

a

Vector[row](%id = 18446745395177063238)

(2)

``


 

Download CoinToss.mw

 

 

restart;
solve({12 beta k^2 w alpha[2]+k alpha[2]^2, 56 beta k^2 m w alpha[2]+4 beta k^2 w alpha[1]-4 A k^2 alpha[2]+8 k m alpha[2]^2+2 k alpha[1] alpha[2]0, 104 beta k^2 m^2 w alpha[2]+16 K beta k^2 w alpha[2]+16 beta k^2 m w alpha[1]-20 A k^2 m alpha[2]+28 k m^2 alpha[2]^2-2 A k^2 alpha[1]+14 k m alpha[1] alpha[2]+2 k alpha[0] alpha[2]+k alpha[1]^2-2 w alpha[2], 56 k alpha[2]^2 m^3+42 k alpha[1] alpha[2] m^2+6 m (2 k alpha[0] alpha[2]+k alpha[1]^2-2 w alpha[2])+96 w k^2 beta alpha[2] m^3+40 w k^2 beta alpha[2] K m-40 A k^2 alpha[2] m^2-4 A K k^2 alpha[2]+2 k alpha[0] alpha[1]+2 k alpha[2] beta[1]-2 w alpha[1]+4 w k^2 beta alpha[1] K+4 (8 K beta k^2 w alpha[2]-2 A k^2 alpha[1]) m+24 w k^2 beta alpha[1] m^2,70 k alpha[2]^2 m^4+70 k alpha[1] m^3 alpha[2]+15 m^2 (2 k alpha[0] alpha[2]+k alpha[1]^2-2 w alpha[2])+5 (-4 A K k^2 alpha[2]+2 k alpha[0] alpha[1]+2 k alpha[2] beta[1]-2 w alpha[1]) m+80 w k^2 beta alpha[2] K m^2-40 A k^2 alpha[2] m^3+44 w k^2 beta alpha[2] m^4+4 w k^2 beta alpha[2] K^2-2 A k^2 alpha[1] K+k alpha[0]^2+2 k alpha[1] beta[1]+2 k alpha[2] beta[2]-2 w alpha[0]+16 w k^2 beta alpha[1] K m+6 (8 K beta k^2 w alpha[2]-2 A k^2 alpha[1]) m^2+16 w k^2 beta alpha[1] m^3-4 w k^2 beta beta[1] m+2 A k^2 beta[1]+4 w k^2 beta beta[2],56 k alpha[2]^2 m^5+70 k alpha[1] alpha[2] m^4+20 m^3 (2 k alpha[0] alpha[2]+k alpha[1]^2-2 w alpha[2])+10 (-4 A K k^2 alpha[2]+2 k alpha[0] alpha[1]+2 k alpha[2] beta[1]-2 w alpha[1]) m^2+80 w k^2 beta alpha[2] K m^3-20 A k^2 alpha[2] m^4+8 w k^2 beta alpha[2] m^5+4 (4 K^2 beta k^2 w alpha[2]-2 A K k^2 alpha[1]+k alpha[0]^2+2 k alpha[1] beta[1]+2 k alpha[2] beta[2]-2 w alpha[0]) m+24 w k^2 beta alpha[1] K m^2+4 (8 K beta k^2 w alpha[2]-2 A k^2 alpha[1]) m^3+4 w k^2 beta alpha[1] m^4+2 k alpha[0] beta[1]+2 k alpha[1] beta[2]-2 w beta[1]-4 w k^2 beta beta[1] m^2+4 w k^2 beta beta[1] K+4 A k^2 beta[1] m-8 w k^2 beta beta[2] m+4 A k^2 beta[2],28 k alpha[2]^2 m^6+42 k alpha[1] alpha[2] m^5+15 m^4 (2 k alpha[0] alpha[2]+k alpha[1]^2-2 w alpha[2])+10 (-4 A K k^2 alpha[2]+2 k alpha[0] alpha[1]+2 k alpha[2] beta[1]-2 w alpha[1]) m^3+40 w k^2 beta alpha[2] K m^4-4 A k^2 alpha[2] m^5+6 (4 K^2 beta k^2 w alpha[2]-2 A K k^2 alpha[1]+k alpha[0]^2+2 k alpha[1] beta[1]+2 k alpha[2] beta[2]-2 w alpha[0]) m^2+16 w k^2 beta alpha[1] K m^3+(8 K beta k^2 w alpha[2]-2 A k^2 alpha[1]) m^4+3 (2 k alpha[0] beta[1]+2 k alpha[1] beta[2]-2 w beta[1]) m-8 w k^2 beta beta[1] K m+2 A k^2 beta[1] m^2+2 A k^2 beta[1] K+2 k alpha[0] beta[2]+k beta[1]^2-2 w beta[2]+16 w k^2 beta beta[2] K+(8 K beta k^2 w beta[1]+4 A k^2 beta[2]) m,8 k alpha[2]^2 m^7+14 k alpha[1] alpha[2] m^6+6 m^5 (2 k alpha[0] alpha[2]+k alpha[1]^2-2 w alpha[2])+5 (-4 A K k^2 alpha[2]+2 k alpha[0] alpha[1]+2 k alpha[2] beta[1]-2 w alpha[1]) m^4+8 w k^2 beta alpha[2] K m^5+4 (4 K^2 beta k^2 w alpha[2]-2 A K k^2 alpha[1]+k alpha[0]^2+2 k alpha[1] beta[1]+2 k alpha[2] beta[2]-2 w alpha[0]) m^3+4 w k^2 beta alpha[1] K m^4+3 (2 k alpha[0] beta[1]+2 k alpha[1] beta[2]-2 w beta[1]) m^2+2 (2 A K k^2 beta[1]+2 k alpha[0] beta[2]+k beta[1]^2-2 w beta[2]) m-4 w k^2 beta beta[1] K m^2+4 w k^2 beta beta[1] K^2-8 w k^2 beta beta[2] K m+4 A k^2 beta[2] K+2 k beta[1] beta[2],k m^8 alpha[2]^2+2 k m^7 alpha[1] alpha[2]+m^6 (2 k alpha[0] alpha[2]+k alpha[1]^2-2 w alpha[2])+(-4 A K k^2 alpha[2]+2 k alpha[0] alpha[1]+2 k alpha[2] beta[1]-2 w alpha[1]) m^5+(4 K^2 beta k^2 w alpha[2]-2 A K k^2 alpha[1]+k alpha[0]^2+2 k alpha[1] beta[1]+2 k alpha[2] beta[2]-2 w alpha[0]) m^4+(2 k alpha[0] beta[1]+2 k alpha[1] beta[2]-2 w beta[1]) m^3+(2 A K k^2 beta[1]+2 k alpha[0] beta[2]+k beta[1]^2-2 w beta[2]) m^2+(4 K^2 beta k^2 w beta[1]+4 A K k^2 beta[2]+2 k beta[1] beta[2]) m+12 w k^2 beta beta[2] K^2+k beta[2]^2},{k,w, alpha[0], alpha[1], beta[1], alpha[2], beta[2]});
Error, missing operation
 

I get trig expressions which are long but contain structure,  The simplest example might be the following which is nothing but a.b where a and b are two unit vectors in polar coordinates.

cos(`&theta;a`)*cos(theta;b)+sin(`&theta;a`)*cos(`&phi;a`)*sin(theta;b)*cos(phi;b)
+sin(`&theta;a`)*sin(`&phi;a`)*sin(theta;b)*sin(phi;b)

 

Whereas the above is easy to identify, in general the structures are not evident.

Question 1  Is there a way to extract such vectors from long trig expressions? I am most interested in identifying inner, cross and outer products of unit vectors contained in these expressions.

Question 2 I would like to apply trig formulae, double angles etc, selectively.  That is apply the formula to only some of the quantities present, say only on the angles theta;a, and theta;b, but not on the phi's.  How is that done?

Thanks

I tried three commands for uniform random distribution. The memory used by sequence created by Generate(distribution(Uniform(0, 1))) is very high. But this is the command which can bring randomness while doing metropolis algorithm. The other two commands consume very less memory but cannot bring randomness. I need the one which can inject randomness and at the same time uses less memory. Thank you. 

 

DISTRIBUTION.mw

Let A=(a_{i,j}) be an nxn non-singular matrix over GF(2). Assume that we have a positive integer number s and an irreducible polynomial f of degree n over GF(2). 

My question: How to get nxn binary matrices such as A provided that the characteristic polynomial  of these matrices over GF(2) is f and also sum(a_{i,j}) is equal to s with 1<=i<=n and 1<=j<=n.

For example, consider n=8 and s=10 and f= x^8+x^7+x^5+x+1. Then I applied the following Maple code to generate the mentioned matrices. 

restart
with(LinearAlgebra):

randomize(); 
 roll := rand(1 .. 64);
 roll1 := rand(1 .. 8); 
 roll2 := rand(9 .. 16);
 roll3 := rand(17 .. 24);
 roll4 := rand(25 .. 32);
 roll5 := rand(33 .. 40);
 roll6 := rand(41 .. 48);
 roll7 := rand(49 .. 56); 
 roll8 := rand(57 .. 64);

u := 1; while u > 0 do 
L := [roll(), roll1(), roll2(), roll3(), roll4(), roll5(), roll6(), roll7(), roll8(), roll()];
if nops({L[]}) = 10 then
A := Matrix(8, 8, 0); s := 0;
for i to 8 do
for j to 8 do 
s := (i-1)*8+j; 
if evalb(`in`(s, L)) then A[i, j] := 1 end if
end do; end do;
if Determinant(A) <> 0 then
if evalb(`in`(sort(`mod`(Factor(CharacteristicPolynomial(A, x)), 2))[x^8+x^7+x^5+x+1]))
then print(A, sort(`mod`(Factor(CharacteristicPolynomial(A, x)), 2))); 
u := 0 end if; end if; 
unassign('A, s, i, j') 
end if; end do; 
unassign('u, i')

with my computer, it takes less than one minute to generate an 8x8 desired non-singular binary matrix as follows

  \left[
 \begin {array}{cccccccc}
 0&0&1&0&0&0&0&0\\
 0&1&1&0&0&0&0&0\\
 0&0&0&1&0&0&0&0\\
 0&1&0&0&0&0&1&0\\
 1&0&0&0&0&0&0&0\\
 0&0&0&0&1&0&0&0\\
 0&0&0&0&0&0&0&1\\
 0&0&0&0&0&1&0&0
 \end {array} 
 \right]

I wish I could find a systematic method to find these kind of matrices. 

Thanks for any suggestions 

restart;
l := -2;
                               -2
m := 1;
                               1
k := sqrt(-1/(6*beta))/l;
                                    (1/2)
                         1  /   6  \     
                       - -- |- ----|     
                         12 \  beta/     
w := (1/5)*alpha/(beta*l);
                              alpha 
                           - -------
                             10 beta
a[2] := -12*sqrt(-1/(6*beta))*alpha*m^2/(5*l*l);
                                 (1/2)      
                      1  /   6  \           
                    - -- |- ----|      alpha
                      10 \  beta/           
a[0] := 0;
                               0
a[1] := 0;
                               0
F := -l*C[1]/(m*(C[1]+cosh(l*(xi+xi[0]))-sinh(l*(xi+xi[0]))));
                             2 C[1]                      
       --------------------------------------------------
       C[1] + cosh(2 xi + 2 xi[0]) + sinh(2 xi + 2 xi[0])
beta := -2;
                               -2
alpha := 3;
                               3
C[1] := -1/1000;
                               -1 
                              ----
                              1000
xi[0] := 1;
                               1
xi := k*x-t*w;
                        1   (1/2)     3   
                      - -- 3      x - -- t
                        12            20  

u := a[0]+a[1]*F+a[2]*F*F;
   /   (1/2)\//        /   1  
 - \3 3     / |2500000 |- ----
              \        \  1000

          /1  (1/2)     3        /  1   (1/2)     3   \   \
    + cosh|- 3      x + -- t - 2 |- -- 3      x - -- t|[0]|
          \6            10       \  12            20  /   /

          /1  (1/2)     3        /  1   (1/2)     3   \   \\  \
    - sinh|- 3      x + -- t - 2 |- -- 3      x - -- t|[0]||^2|
          \6            10       \  12            20  /   //  /


plot3d(u, x = -3 .. 3, t = -3 .. 3);
Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct
 

I hope you can help me. I like to use the Workbook feature in Maple 2018. I save variables in one document to use them in another document as well. If, however, the value of the variable changes, I have to delete the variable in the variable manager each time and save it again.
Is there a command I can use to delete and re-save the saved variables?

First 532 533 534 535 536 537 538 Last Page 534 of 2234