Problem 10

(Problem posed by Department of Mathematics, Sarada Vilas College)

Problem: Observe the followinng code of maxima and asnwer the questions given below the image:

Questions

  • Which problem is this code trying to solve? (Frame the question for which this code is written)
  • The code seems to be wrong. Can you identify the mistake? Why do you think it is a mistake?
  • Suppose you have identified the mistake, which portion of the code would you like to change?

(Either comment the answer in the comment box or send your solution to dep.math.svc@gmail.com on or before 29th of July, 2026.)

7 comments:

  1. Q. Check whether 2 is the identity element of the ring (Z6,+6,*6).

    The mistake is the use of else in the first if condition , this gives an error in the answer because the final output is decided only in terms of the last iteration (in this case the output is given based on 2*0=0*2=0 , thus the flag value remains 1 ). so inorder to solve this we can modify the code as,
    for i:1 thru n do
    if bo(z[i],e)#z[i] or bo(e,z[i])#z[i] then
    flag:1 $
    if flag=1 then
    Print(e,”is not unity element”)
    else print(e,”is the unity element “)$

    ReplyDelete
  2. 1. To check whether a given element is the identity (unity) element under multiplication modulo 6.
    2.The "flag" is updated inside for every element
    3. Change the "flag" part of the code.

    ReplyDelete
    Replies
    1. Good.

      Regarding your second answer. What if we remove 'else flag:0'. Then also would the flag be updated for every element?

      And how would you change the flag part?

      Delete
    2. No. If 'else flag:0' is removed, flag is not updated for every element.
      flag:1$
      for i:1 thru n do
      if bo(z[i],e) # z[i] or bo(e,z[i]) # z[i] then
      flag:0$

      Delete
    3. No. 'If else flag:0' is removed, flag is not updated for every element.
      flag:1$
      for i:1 thru n do
      if bo(z[i],e) # z[i] or bo(e,z[i]) # z[i] then
      flag:0$

      Delete