140 Reputation

14 years, 222 days

if and for loops (nested)...

Maple

At the moment I'm trying to find the smallest difference between two things (of form E[i] i goes from 1 to n)  and input them in a list. To do this I need to use nested loops but I'm not sure of the best kind/way to do this. I have been experimenting with for and if loops so far

for instance, this is my most recent effort.

for i from 2 to n do;

a := abs(E[i]-E[1]);

for j from 2 to n do;

if i <> j then ;

b := abs(E[i]-E[j]);

end if;

if b < a then a := b end if;

end do;

Generating GUE Random Matrices and their...

Maple

I have been trying to do this for some while now but am not having much luck.

Basically what I need is a hermitian matrix, with real values on the diagonals X~N(0,1) and complex values on the off diagonals X~N(0,1/2)+i*N(0,1/2)

Obviously as its hermitian I need Xij = Xji*

I have tried a few things but can't get anything to work correctly, in my latest attempt I decided to try and construct the 2x2 case from scratch using if and for loops;

for i to n do

for j to n do

if i <> j then

loop within a loop i not equal to j...

Maple

I need to write a loop within a loop for something like this;

for i from 1 to n for j from i to n do;
A[i,j]:= rand();
A[j,i]:= A[i,j]

end do; end do;

(just random sample code, not what I need to do)

But I don't want the loop to carry this out for when i=j ie. A[i,i] for i = 1 to n. How can I do this?

Generate a random variable VALUE with no...

Maple

I want to generate values which have a N(0,1) distribution (and also some which have a N(0,1/2)+I*N(0,1/2))

I have found the RandomVariable(Normal(0,1)) command but this just tells me things like _R44 and I need the numerical value.

Please can you help? (with both distribution cases)

Create random rational numbers between 0...

Maple

I have only found rand() which gives me integer values and I need to generate (a lot of)  random rational numbers.

The boundary (0,2) doesn't really matter but I do need the numbers to at least go up to 2. Else any rational will do.

Thankyou.

 1 2 Page 1 of 2
﻿