Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: primitive root error

  • To: mathgroup at smc.vnet.net
  • Subject: [mg128131] Re: primitive root error
  • From: danl at wolfram.com
  • Date: Tue, 18 Sep 2012 03:39:58 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <k2ub15$h9h$1@smc.vnet.net> <20120915073839.53E3C6859@smc.vnet.net>

On Sunday, September 16, 2012 2:23:26 AM UTC-5, Andrzej Kozlowski wrote:
> On 15 Sep 2012, at 09:38, somebody wrote:
> [...]
> >
> > Me, I'd call that a mistake in the documentation. Anyway, you can get the smallest by resorting to a crude, nay, barbaric tactic: invoke Wolfram|Alpha to find all the primitive roots.
>
> > In[71]:= WolframAlpha["primitive roots of 18", "MathematicaResult"]
> >
> > Out[71]= {5, 11}
> [...]
> >
>
> This does indeed seem a little barbaric since:
>
>
> WolframAlpha["primitive roots of 18", "MathematicaResult"] // Timing
> 
> {1.87481,{5,11}}
> 
> Select[Range[18],
>
>   MultiplicativeOrder[#, 18] == EulerPhi[18] &] // Timing
>
> {0.000347,{5,11}}
>
>
> Andrzej Kozlowski

Might in part be an issue with establishing a connection to Alpha. It was around 4x faster for me. Repeating brings it to around .03 seconds. Given that this involves a round trip to Alpha, the factor of 10 dominance of that vs. the actual computation is not too surprising.

This variant might be noticeably faster than what you tried though. (Note to the uninitiated: Don't try the other method on this).

WolframAlpha["primitive roots of Prime[18]^18",
  "MathematicaResult"] // Timing

It will give the smallest and largest roots, alomg with the total count.

Daniel Lichtblau
Wolfram Research




  • Prev by Date: Re: Speed of VectorPlot3D... What is Rendering?
  • Next by Date: Linear combinations of Expectation of EmpiricalDistribution
  • Previous by thread: Re: primitive root error
  • Next by thread: Re: primitive root error