mersenneforum.org  

Go Back   mersenneforum.org > Math Stuff > Computer Science & Computational Number Theory > PARI/GP

Reply
 
Thread Tools
Old 2016-04-09, 21:02   #1
a1call
 
a1call's Avatar
 
"Rashid Naimi"
Oct 2015
Remote to Here/There

2,017 Posts
Default IntegerExponent Equivalent in Pari-GP

Hi,

I can't find an equivalent to IntegerExponent function in Pari-GP.

Is there one?, or should One write his own routine?

Thanks in advance


https://reference.wolfram.com/langua...rExponent.html

http://math.mit.edu/~brubaker/PARI/PARIrefcard.pdf
a1call is offline   Reply With Quote
Old 2016-04-09, 21:09   #2
paulunderwood
 
paulunderwood's Avatar
 
Sep 2002
Database er0rr

32·11·37 Posts
Default

?logint

Quote:
logint(x,b,&z): return the largest integer e so that b^e <= x, where the
parameters b > 1 and x > 0 are both integers. If the parameter z is present,
set it to b^e.
Example:

Code:
? logint(139,2)
7
Of course, you will have take the remainder when divided by the base to see if it divides exactly.

Last fiddled with by paulunderwood on 2016-04-09 at 21:16
paulunderwood is offline   Reply With Quote
Old 2016-04-09, 21:19   #3
a1call
 
a1call's Avatar
 
"Rashid Naimi"
Oct 2015
Remote to Here/There

37418 Posts
Default

Thank you paulunderwood,
That was fast.
For the record that function is missing from the reference card that I linked.
That saves me quite a bit of time.
Thank you again.
a1call is offline   Reply With Quote
Old 2016-04-09, 21:20   #4
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

Quote:
Originally Posted by paulunderwood View Post
?logint



Example:

Code:
? logint(139,2)
7
Of course, you will have take the remainder when divided by the base to see if it divides exactly.
only in later versions of PARI-GP than that refcard URL is good for. 2.75 is the earliest I know of it from ( only because I looked at my old installs). edit: of course before this all that's needed is floor(log(x)/log(y)) where y is the number you want to take the log base as. but built in's are usually faster. see the PARI commands thread for some other things that may help. of course depending on what you plan on doing with the number digits() may also come in handy or even fromdigits() in newer versions. however on reading the other link I think you technically want valuation() not logint as logint doesn't care about divisibility valuation does.

Quote:
(18:29) gp > ??valuation
valuation(x,p):

Computes the highest exponent of p dividing x. If p is of type integer, x must be an integer, an intmod whose modulus is divisible by p, a fraction, a q-adic number with q = p, or a polynomial or power series in which case the valuation is the minimum of the valuation of the coefficients.

If p is of type polynomial, x must be of type polynomial or rational function, and also a power series if x is a monomial. Finally, the valuation of a vector, complex or quadratic number is the minimum of the component valuations.

If x = 0, the result is LONG_MAX (2^{31}-1 for 32-bit machines or 2^{63}-1 for 64-bit machines) if x is an exact object. If x is a p-adic numbers or power series, the result is the exponent of the zero. Any other type combinations gives an error.

The library syntax is long gvaluation(GEN x, GEN p).

Last fiddled with by science_man_88 on 2016-04-09 at 21:30
science_man_88 is offline   Reply With Quote
Old 2016-04-09, 21:32   #5
a1call
 
a1call's Avatar
 
"Rashid Naimi"
Oct 2015
Remote to Here/There

2,017 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
only in later versions of PARI-GP than that refcard URL is good for. 2.75 is the earliest I know of it from ( only because I looked at my old installs). edit: of course before this all that's needed is floor(log(x)/log(y)) where y is the number you want to take the log base as. but built in's are usually faster. see the PARI commands thread for some other things that may help. of course depending on what you plan on doing with the number digits() may also come in handy or even fromdigits() in newer versions. however on reading the other link I think you technically want valuation() not logint as logint doesn't care about divisibility valuation does.
Thank you science_man_88,
That would-have-been/is as good in saving me time.

Last fiddled with by a1call on 2016-04-09 at 21:32
a1call is offline   Reply With Quote
Old 2016-04-09, 21:35   #6
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Quote:
Originally Posted by a1call View Post
Thank you science_man_88,
That would-have-been/is as good in saving me time.
of course if it's used for factoring factor() can do it for all primes you might be able to save yourself time with that also then of course there's factorint() (though that one doesn't have an upper limit to my knowledge and only factors using integers. if you want a list of divisors that are powers there's divsors() and ispower() ( or even fordiv in some versions) if you want to check if something is square free there's an issquare free function etc. edit: and of course if something is squarefree it is also power-free since all powers greater than squares that could divide it are not squarefree.

Last fiddled with by science_man_88 on 2016-04-09 at 21:39
science_man_88 is offline   Reply With Quote
Old 2016-04-09, 21:38   #7
paulunderwood
 
paulunderwood's Avatar
 
Sep 2002
Database er0rr

32·11·37 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
??valuation
paulunderwood is offline   Reply With Quote
Old 2016-04-09, 21:40   #8
a1call
 
a1call's Avatar
 
"Rashid Naimi"
Oct 2015
Remote to Here/There

2,017 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
of course if it's used for factoring factor() can do it for all primes you might be able to save yourself time with that also then of course there's factorint() (though that one doesn't have an upper limit to my knowledge and only factors using integers. if you want a list of divisors that are powers there's divsors() and ispower() ( or even fordiv in some versions) if you want to check if something is square free there's an issquare free function etc.
Thank you,
My current use is not for factoring. Just need to formulate the highest integer power to run my WDP code on Pari-gp.
The only thing I need to figure out now is how to use variables.
a1call is offline   Reply With Quote
Old 2016-04-09, 21:48   #9
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

Quote:
Originally Posted by a1call View Post
Thank you,
My current use is not for factoring. Just need to formulate the highest integer power to run my WDP code on Pari-gp.
The only thing I need to figure out now is how to use variables.
probably would depend on scope and if they are predefined values at first. not to mention if you want to do things in parallel global variables would be NOT a great choice. I'm not even sure what WDP is. one thing that comes to mind is in theory primes are the simplest case if they can't divide by prime power's they don't divide by any power other than 1^n which is always 1.
science_man_88 is offline   Reply With Quote
Old 2016-04-09, 21:49   #10
a1call
 
a1call's Avatar
 
"Rashid Naimi"
Oct 2015
Remote to Here/There

7E116 Posts
Default

Well variables seem straight forward.
Is there a way to save/load scripts/routines/programs?

Thank you.


ETA: WDP = Wolfram Development Platform:

https://develop.wolframcloud.com/app/

Last fiddled with by a1call on 2016-04-09 at 21:51
a1call is offline   Reply With Quote
Old 2016-04-09, 21:55   #11
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Quote:
Originally Posted by a1call View Post
Well variables seem straight forward.
Is there a way to save/load scripts/routines/programs?

Thank you.


ETA: WDP = Wolfram Development Platform:

https://develop.wolframcloud.com/app/
you can have a codes.gp load on start. you'll need to setup your GPRC file to do that though or copy a text file in each time. anything done earlier in a session will still be accessible and in some versions you may even be able to get it from older log files as I can hit back ( or up in my case I think) and see me looking up about fromdigits etc. ( though I don't think that's worth the risk)
science_man_88 is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
An equivalent problem for factorization of large numbers HellGauss Math 5 2012-04-12 14:01
PIV Effective Equivalent curiosities... petrw1 Software 0 2009-12-05 04:41
Dual Core P95 64Bit P4 Equivalent problem g0ods Software 9 2009-09-15 14:12
Is there a finite-field equivalent to the DWT? fivemack Math 4 2008-03-27 17:58
Equivalent code dsouza123 Programming 25 2005-10-08 05:10

All times are UTC. The time now is 13:50.

Fri May 7 13:50:14 UTC 2021 up 29 days, 8:31, 0 users, load averages: 3.25, 3.12, 2.85

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.