Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

I am trying to map this function


to a fairly big list of random rational numbers

I am trying to get this to give me a result of true, so I mapped that above function to

RandomRandomRational[{bound1_, bound2_}, delta_, n_]]

but I don't get true as my result.

I also wanted to try to see if ((-1)^Numerator[q])^(1/Denominator[q])==(-1)^q is an identity or not, so would I do the same as above, but my result should show up negative?

share|improve this question

marked as duplicate by belisarius, Michael E2, Sjoerd C. de Vries, m_goldberg, Yves Klett Oct 25 '13 at 8:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Looks familiar: mathematica.stackexchange.com/q/34427/1783 –  bill s Oct 25 '13 at 2:05
@belisarius- I want to learn a math program for a job so my friend said to try mathematica and if I get used to it go learn python, I think it's called. and bill - I will take a look at that thank you. –  thaibak527 Oct 25 '13 at 2:30
Your friend's counsel (learning Mathematica as a first step for python) doesn't sound efficient to me. –  belisarius Oct 25 '13 at 2:50
He said learning this program is easier than learning python which is why I should learn this one first –  thaibak527 Oct 25 '13 at 20:49
There are two alternatives: 1) Your friend doesn't know enough Mathematica or 2) He's playing with you. –  belisarius Oct 26 '13 at 3:23

1 Answer 1

To answer your specific question, it's easy enough to map the function to a long list of rational numbers. Here's the function:

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

Construct a bunch of "random" rationals from random integers:

num = RandomInteger[{1, 1000}, 1000];
den = RandomInteger[{1, 1000}, 1000];

and apply the function to the list:

f[#] & /@ (num/den)

gives a long list of Trues.

share|improve this answer
I don't think that was what I was looking for but thank you, I think I got it now –  thaibak527 Oct 25 '13 at 2:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.