mersenneforum.org IntegerExponent Equivalent in Pari-GP
 User Name Remember Me? Password
 Register FAQ Search Today's Posts Mark Forums Read

 2016-04-09, 21:02 #1 a1call     "Rashid Naimi" Oct 2015 Remote to Here/There 2,243 Posts 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
2016-04-09, 21:09   #2
paulunderwood

Sep 2002
Database er0rr

100628 Posts

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

 2016-04-09, 21:19 #3 a1call     "Rashid Naimi" Oct 2015 Remote to Here/There 2,243 Posts 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.
2016-04-09, 21:20   #4
science_man_88

"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts

Quote:
 Originally Posted by paulunderwood ?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

2016-04-09, 21:32   #5
a1call

"Rashid Naimi"
Oct 2015
Remote to Here/There

224310 Posts

Quote:
 Originally Posted by science_man_88 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

2016-04-09, 21:35   #6
science_man_88

"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts

Quote:
 Originally Posted by a1call 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

2016-04-09, 21:38   #7
paulunderwood

Sep 2002
Database er0rr

2×3×691 Posts

Quote:
 Originally Posted by science_man_88 ??valuation

2016-04-09, 21:40   #8
a1call

"Rashid Naimi"
Oct 2015
Remote to Here/There

8C316 Posts

Quote:
 Originally Posted by science_man_88 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.

2016-04-09, 21:48   #9
science_man_88

"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts

Quote:
 Originally Posted by a1call 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.

 2016-04-09, 21:49 #10 a1call     "Rashid Naimi" Oct 2015 Remote to Here/There 2,243 Posts 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
2016-04-09, 21:55   #11
science_man_88

"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts

Quote:
 Originally Posted by a1call 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)

 Similar Threads Thread Thread Starter Forum Replies Last Post HellGauss Math 5 2012-04-12 14:01 petrw1 Software 0 2009-12-05 04:41 g0ods Software 9 2009-09-15 14:12 fivemack Math 4 2008-03-27 17:58 dsouza123 Programming 25 2005-10-08 05:10

All times are UTC. The time now is 22:05.

Fri May 27 22:05:10 UTC 2022 up 43 days, 20:06, 0 users, load averages: 1.25, 1.58, 1.60

Copyright ©2000 - 2022, 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.

≠ ± ∓ ÷ × · − √ ‰ ⊗ ⊕ ⊖ ⊘ ⊙ ≤ ≥ ≦ ≧ ≨ ≩ ≺ ≻ ≼ ≽ ⊏ ⊐ ⊑ ⊒ ² ³ °
∠ ∟ ° ≅ ~ ‖ ⟂ ⫛
≡ ≜ ≈ ∝ ∞ ≪ ≫ ⌊⌋ ⌈⌉ ∘ ∏ ∐ ∑ ∧ ∨ ∩ ∪ ⨀ ⊕ ⊗ 𝖕 𝖖 𝖗 ⊲ ⊳
∅ ∖ ∁ ↦ ↣ ∩ ∪ ⊆ ⊂ ⊄ ⊊ ⊇ ⊃ ⊅ ⊋ ⊖ ∈ ∉ ∋ ∌ ℕ ℤ ℚ ℝ ℂ ℵ ℶ ℷ ℸ 𝓟
¬ ∨ ∧ ⊕ → ← ⇒ ⇐ ⇔ ∀ ∃ ∄ ∴ ∵ ⊤ ⊥ ⊢ ⊨ ⫤ ⊣ … ⋯ ⋮ ⋰ ⋱
∫ ∬ ∭ ∮ ∯ ∰ ∇ ∆ δ ∂ ℱ ℒ ℓ
𝛢𝛼 𝛣𝛽 𝛤𝛾 𝛥𝛿 𝛦𝜀𝜖 𝛧𝜁 𝛨𝜂 𝛩𝜃𝜗 𝛪𝜄 𝛫𝜅 𝛬𝜆 𝛭𝜇 𝛮𝜈 𝛯𝜉 𝛰𝜊 𝛱𝜋 𝛲𝜌 𝛴𝜎𝜍 𝛵𝜏 𝛶𝜐 𝛷𝜙𝜑 𝛸𝜒 𝛹𝜓 𝛺𝜔