Ask Your Question
2

Abstract Algebra Question

asked 2010-12-07 18:00:40 -0500

Mathstudent2010 gravatar image

My teacher gave us an extra credit problem using sage, I am having soo much trouble just trying to get started and was hoping for any sort of help possible. Heres the question: An element a in Z mod n is a square if there is some b element of Z mod n such that a^2 = b. Find the number of squares in Z mod p^(n). Would the code look something like this:

for p^2 = b, let p be prime:

print modulo(Integer(Z): .... This is my first time ever using a computer program. Sage seems very powerful and I expect to use it more during my school break, but if anyone can help me now, I would greatly appreciate it!!!!!

`

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
4

answered 2010-12-08 01:11:45 -0500

kcrisman gravatar image

The earlier comments I believe we made to you in Question 195 still hold! This isn't a homework tutorial. So, once again, I'll give you some hints as to where to find this information, and what the issues are, but no more.

Your syntax is not quite right. You may wish to check out a Python tutorial, such as the official one, Dive into Python (for more experienced programmers), or Think Python, which is truly excellent and truly for beginners, and truly free in that form :)

More specifically, since you haven't defined b, you can't say anything about it. Second, the for statement needs some sort of iterable as its object. The prime_range function, which you can learn more about with

sage: prime_range?

would be useful for getting a set of primes to iterate over; you can use [1..5] to get the set of integers from 1 to 5. Third, you probably want some kind of conditional statement if you are testing whether an element is a square; usually this has the syntax

if b>25:
    print 'yay!'
else:
    print 'boo!'

This would be if you were checking whether b was greater than 25.

Incidentally, the statement of the problem also looks strange; see if you can figure out what seems wrong mathematically with what you wrote.

edit flag offensive delete link more

Comments

coming in clutch kcrisman! Ty man. I think I figured it out now!

Mathstudent2010 gravatar imageMathstudent2010 ( 2010-12-09 13:07:36 -0500 )edit

Well, I don't think I did anything more than give you references to some pretty general Sage stuff. Learning Python will help you a lot. By the way, you should mention to your teacher that you used ask.sagemath.org as a resource; not doing so would be called improper citation of references.

kcrisman gravatar imagekcrisman ( 2010-12-09 16:19:01 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2010-12-07 18:00:40 -0500

Seen: 244 times

Last updated: Dec 08 '10