Fortran Fortran Help, Please. Waiting online.

  • Thread starter Thread starter kevek
  • Start date Start date
  • Tags Tags
    Fortran
AI Thread Summary
The discussion revolves around the concept of permutations in group theory, specifically how to compose and manipulate permutations using colored balls as an example. It explains the process of permuting positions and how to express these permutations in cycle notation. The participants explore how to calculate powers of permutations, demonstrating that repeated applications eventually lead to the identity permutation. There is a focus on coding in Fortran to implement these concepts, with queries about creating loops and subroutines to check for identity and perform permutation operations. Participants discuss the mechanics of rotating elements within arrays and how to represent these operations programmatically. The conversation highlights the need for clarity in understanding permutation notation and the properties of group operations, as well as the challenges faced in translating mathematical concepts into code. The goal is to create subroutines that can handle multiplication of permutations and their powers effectively.
kevek
Messages
12
Reaction score
0
The "multiplication (*)" in the group is simply performing them after one another.
Take 6 coloured balls. Permute the first and third one. Now permute the third and fifth one (note: by third one I mean the one in the third position, not the third ball which is not in the first position).
You have just composed the permutations (13) and (35). In effect, you have moved the first one to the fifth, the fifth one to the third and the third one to the first, so in cycle notation:
(35) * (13) = (153).
(where the composition o is to be read as: "after").

Then as in any group, a power is simply composing the permutation with itself, e.g.
(13)**2 = (13) * (13) = 1
(153)**2 = (153)(153) = (135)
and working out the order is simply composing until you get the identity, e.g.
(153)**3 = (135)(153) = 1

To print out either do multiplication and take power, they all equal to identity number.

What I can do now is.

first ball
integer x(6)
integer i;
do i = 1,6,1
x(i) =i
end do

finish permutation, if x(i) is 1,2,3,4,5,6 then identity=1
integer flag
flag = 1 !first ball
do i = 1,6,1
if ( x(i) .NE. i ) then
flag = 0
end if
end do

if flag .EQ. 1 identity=1

But I don't know how to create Do Loops, IF block, and Subroutine to To print out either do multiplication and take power, they all equal to identity number.

Can anyone help me please.
 
Technology news on Phys.org
1. I only see pseudo-code to initialize the array, and to check for identity.
I do not see any operators/methods, much less what you'd like to achieve.

2. I am not familiar with the operator * and the (123) notation, therefore the properties you mentioned are not obvious to me since they have not been developed/derived.
for example:
how do I know that (135)(135)=(153) without actually working it out?
 
(a b c), appears to be some type of rotate operator:

() = 1 2 3 4 5 6
(3 5) = 1 2 5 4 3 6
(1 3) = 5 2 1 4 3 6

if(a b c) means to rotate "left" = b->a + c->b + a->c

(3 5) + (1 3) = (1 5 3) => 5->1 + 3->5 + 1-> 3 = 5 2 1 4 3 6 == (1 3 5) + (1 3 5) = (1 3) + (3 5) + (1 3) + (3 5)

(1 3 5) = (3 5 1) = (5 1 3) = left rotate of 1 3 5
(1 5 3) = (5 3 1) = (3 1 5) = right rotate of 1 3 5

It sould be clear that 2 right rotate of 3 things = 1 left rotate of 3 things and vice versa, and that 3 rotates of 3 things = identity.

(a b c d), for example (1 2 4 3) = 2 4 1 3 5 6. Repeating a sequence of a 4 "rotate" 4 times gets you back to the original

1 2 3 4 5 6
2 4 1 3 5 6
4 3 2 1 5 6
3 1 4 2 5 6
1 2 3 4 5 6

I don't understand what you're trying to accomplish though, prove that repeating any sequence of operations enough times and you get back to the original?
 
Last edited:
Thank you for your reply. I don't have any idear how to create subroutine and Do loops. and the (153)(153)=(135) is defined like that. just need to set it into subroutine.
 
Thank you Jeff. for your clearly explanation.
 
your code fragment looks ok to me, except you can just start off with flag = 1. My Fortran is very rusty, but based on your code fragment:

Code:
      integer flag 

      flag = 1
      do i = 1,6,1 
          if ( x(i) .NE. i ) then 
              flag = 0 
          end if 
      end do 

      if (flag .EQ. 1) identity=1
 
Code:
      IMPLICIT REAL(A-H,O-Z), INTEGER(I-L)
      INTEGER X(6)
      INTEGER I
      DO 15 I=1,6
   15 X(I)=I
      WRITE(6,999)IS_IDENTICAL(X)
  999 FORMAT(I5)
      STOP
      END
      INTEGER FUNCTION IS_IDENTICAL(X)
      INTEGER X(6)
      integer flag
      IS_IDENTICAL=0
      flag = 1
      do i = 1,6,1
          if ( x(i) .NE. i ) then
              flag = 0
          end if
      end do

      if (flag .EQ. 1) IS_IDENTICAL=1
      RETURN
      END
This completes what you started according to the given pseudocode, and using Jeff's code. However, as I mentioned earlier, it is not clear what you want to achieve.
 
Jeff Reid said:
(a b c), appears to be some type of rotate operator:

() = 1 2 3 4 5 6
(3 5) = 1 2 5 4 3 6
(1 3) = 5 2 1 4 3 6

if(a b c) means to rotate "left" = b->a + c->b + a->c

(3 5) + (1 3) = (1 5 3) => 5->1 + 3->5 + 1-> 3 = 5 2 1 4 3 6 == (1 3 5) + (1 3 5) = (1 3) + (3 5) + (1 3) + (3 5)

(1 3 5) = (3 5 1) = (5 1 3) = left rotate of 1 3 5
(1 5 3) = (5 3 1) = (3 1 5) = right rotate of 1 3 5

It sould be clear that 2 right rotate of 3 things = 1 left rotate of 3 things and vice versa, and that 3 rotates of 3 things = identity.

(a b c d), for example (1 2 4 3) = 2 4 1 3 5 6. Repeating a sequence of a 4 "rotate" 4 times gets you back to the original

1 2 3 4 5 6
2 4 1 3 5 6
4 3 2 1 5 6
3 1 4 2 5 6
1 2 3 4 5 6

I don't understand what you're trying to accomplish though, prove that repeating any sequence of operations enough times and you get back to the original?

Thank you again. yes it was what i meant. I just want to create 2 subroutin that one contain group (13)**2 = identity. and another one shows group (135)**3 = identity.
hence whatever the group contains (the number inside), it will get the identity after the finite powers of the group.
Thank you
 
Hi Jeff and Mathsmate, I wrote some code. don't know does it right ,can you please check for me?
Can you add (mutliplication '*' e.g.(35) * (13) = (153).) and powers of group(**2 or **3 .e.g.(153)**2 = (153)(153) = (135), and (153)**3 = (135)(153) = 1) into this code. I really don't know how to reload * and **. please.

Subroutine trans(temp, size)
implicit none
integer :: size
integer :: temp(size)
integer :: m, t, i !temp
t = temp(1)
do i=1,size-1
m = temp(i+1)
temp(i+1) = t
t = m
END do
temp(1) = t
END Subroutine trans

Program main
implicit none
integer :: P(6) = (/ 1, 2, 3, 4, 5, 6 /)
integer :: temp(3)
integer :: i
! (153)
write(*, *) 'original numbers is = '
write(*, *) P(1), P(5), P(3)
temp(1) = P(1)
temp(2) = P(5)
temp(3) = P(3)
do i=1, 3
call trans(temp, 3)
write(*, *) "trans ", i, "time(s) is"
write(*, *) temp
END do
write(*, *) 'final numbers is ='
write(*, *) temp
if (temp(1) == P(1) .AND. temp(2) == P(5).AND. temp(3) == P(3)) then
write(*, *) 'they are same again'
END if
stop
END
 
Last edited:
  • #10
You could make this more generic by using a second level of indexing:

Code:
      integer :: s[6]

      size = 3
      s(1) = 1
      s(2) = 3
      s(3) = 5

      tmp     = P(s(1))
      P(s(1)) = P(s(2))
      P(s(2)) = P(s(3))
      P(s(3)) = tmp
 
  • #11
Thank for all your help..:wink:
 

Similar threads

Replies
3
Views
3K
Replies
4
Views
2K
Replies
12
Views
3K
Replies
3
Views
2K
Replies
8
Views
4K
Replies
4
Views
2K
Replies
19
Views
2K
Replies
22
Views
5K
Back
Top