Vez96

20 Reputation

0 Badges

0 years, 110 days

MaplePrimes Activity


These are questions asked by Vez96

If I have a procedure that for example produces a list of times it takes to work out the eigenvectors of a random nxn matrix from n=2..9.

Times:=[seq([n,time(LinearAlgebra[Eigenvectors](RandomMatrix(n)))],n=2..9)]:

If I want to make my data more accurate so that it works out the time it takes to find the eigenvector for each different sized matrix multiple times and then takes an average time (for each n), how would I do that?


 

Hi I'm trying to make a procedure that will multiply all the diagonal entries of any random matrix together, this is what I have tried so far:

 

with(LinearAlgebra):
with(ListTools):
Diag := proc(A)
local aux,V,i,n;
V:=[];
n:=RowDimension(A):

for i from 1 to n do 
aux := 1; 
aux := aux*U2(i,i);
end do:


end proc;

but this just produces the last diagoinal entry of the matrix - how do I make the loop multiply the previous number by the next diagonal entry?

another option I've done is to make a list of the diagonal entries, but then I encounter the same problem with multiplication:

Diag:=proc(A)
local n, List;
n:=RowDimension(A);
List:=[seq(A(i,i),i=1..n)]:
end proc:

any help would be greatly appreciated!
 

Hi, I'm stuck on how to create a procedure, 'Arrange' that sorts a list of integers so that the numbers go from smallest to largest. So if I have a list such as: [3,6,1,9,0,4] ,

Arrange([3,6,1,9,0,4]) = [0,1,3,4,6,9]

I have a procedure that produces a sequence where we denote 'x' as the first number in the list, and returns: a list of all the numbers in the list less than x, x, a list of all the numbers greater than x.

i.e. returns: [1, 0], 3, [6, 9, 4]

Arrange := proc(L)
local L1,L2,n,x,i;
L1:=[];
L2:=[];
n:=nops(L):
if n=0 then
print('NULL')
elif n=1 then 
return L[1];
elif n>1 then
x:= L[1];

for i from 2 to n do 
if L[i] < x then
L1:=[L1[],L[i]]:
else 
L2:=[L2[],L[i]]:

end if:
end do:
end if:
return L1,x,L2;

end proc:

could anyone help on how I can expand on this to get the procedure that I want?

 

p.s. I know that there is already an inbuilt 'sort' function in Maple, but I'm trying to create the procedure myself!
 

The Question: 

'Produce a list of the primes p between 2000 and 3000 for which both 2 and 3 generate Fpx ' 

I have my code for producing the list of primes between 2000 and 3000:

p:=nextprime(2000):
primes:=[]:
while p<=3000 do
  primes:=[primes[],p];
  p:=nextprime(p);
end do:
 

I also have  code for finding the order of a number in Fpx


findOrderOf:=proc(g,p)
 local gpwr, i;
  gpwr:=1:
for i from 1 to p-1 do
  gpwr:=gpwr*g mod p; 
if (gpwr = 1) then:
return i;
end if:
end do:
end proc:
 

 

but I don't know how to relate them or how to create the overall code - any advice would be very helpful!!
 

Page 1 of 1