# Number theory: Problem involving rational numbers

Use RandomRat to test whether ((-1)^(1/Denominator[q]))^Numerator[q] is identical with (-1)^q. Use 25000 rational numbers between 1 and 500000. Use Delta =10^-10 and Map it to a large list of random rational numbers. If you always get True you have evidence for the identity.

Then, show that

((-1)^Numerator[q])^(1/Denominator[q])==(-1)^q


is not an identity.

So far this is what I have:

RandomRat := ((-1)^(1/Denominator[q]))^(Numerator[q])
(-1)^q == RandomRat


I'm not sure if that's correct so far because I think I'd have to use pure functions and then how would I use the 25000 rational numbers between 1 and 500000 from here?

-

Be careful. You cannot prove an identity through a finite number of tests!

However, you can test the identity directly.

ClearAll[q]
((-1)^(1/Denominator[q]))^Numerator[q] === (-1)^q


True

In fact, the two terms have the same underlying representation:

((-1)^(1/Denominator[q]))^Numerator[q] // FullForm
(-1)^q // FullForm


Power[-1, q]
Power[-1, q]

-
I'm not sure I follow –  Sam Oct 21 '13 at 3:12
You said, "Use RandomRat to test whether ((-1)^(1/Denominator[q]))^Numerator[q] is identical with (-1)^q." But because q comes from an infinite set, you would need to test ((-1)^(1/Denominator[q]))^Numerator[q] == (-1)^q for infinitely many values of q, which is impossible. (btw, I didn't prove that the equation is an identity. However, I did show that Mathematica regards the statement as an identity.) –  David Carraher Oct 21 '13 at 10:01
I think the main question I have regarding this question is testing this using the given of.... 25000 rational numbers between 1 and 500000. Use Delta =10^-10 and Map it to a large list of random rational numbers –  Sam Oct 23 '13 at 0:29
I don't see how Delta has to do with anything the question is asking, but it's being asked and I was wondering if anyone can clarify it –  Sam Oct 23 '13 at 0:29
@Sam I usually think it's the teacher's job to clarify his or her questions. If it's from a textbook, then perhaps there's some context you're overlooking or it's a poorly worded question. –  Michael E2 Oct 24 '13 at 11:54

First, the beginning of the statement "Use RandomRat..." strongly indicates to the reader that a function RandomRat has already been defined and a solution should implement that particular function. If this problem is copied from a class or book, then the definition should be in the problem, in class, or in the book. The rest of the problem leads me to guess that RandomRat should be returning a random rational number. I further suspect that Delta is an argument to this function. You can't really generate random rational numbers in an interval with imposing some limitation on the distribution; I suspect in this case limiting the size of the denominators is done by passing Delta as the second argument of Rationalize.

Here is my interpretation: First, a list ratlist of 25000 random rational numbers.

SeedRandom[1];
Delta = 10^-10;
ratlist = Rationalize[#, Delta] & /@ RandomReal[{1, 500000}, 25000];


We can Map (/@) the first test onto this list:

Function[{q}, ((-1)^(1/Denominator[q]))^Numerator[q] == (-1)^q] /@
ratlist // DeleteDuplicates
(* {True} *)


That the second equation is not an identity is shown by most rational numbers, such as q -> 2/3.

-
+1 For the helpful comments (and speculation about the author's aims) at the beginning of your posting. –  David Carraher Oct 24 '13 at 12:41

Here I check the first 25000 rats instead of 25000 random rats.

test1[q_] := (-1)^q == ((-1)^(1/Denominator[q]))^(Numerator[q]);
test2[q_] := (-1)^q == ((-1)^(Numerator[q]))^(1/Denominator[q]);
list = Union@Flatten@Outer[#1/#2 &, Range[#], Range[#]] &@203;
test1 /@ list // Union
test2 /@ list // Union


If you have a long list of rats, you can use RandomChoice to get a random one.

Alternatively, you could construct a random rat

RandomRat:=#1/#2 & @@ RandomInteger[{1, 500000}, 2]

-
What do I do with the delta=10^-10 part? –  Sam Oct 23 '13 at 0:27
I don't understand what the delta was for, unless he was asking you to choose rational numbers from the list list=Range[1,500000,10^-10] –  Timothy Wofford Oct 24 '13 at 18:26