mersenneforum.org  

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

Reply
 
Thread Tools
Old 2010-08-11, 14:26   #232
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

hard part about this now is mostly with if 2 functions need to be embedded with each other later (I've already worked out how to print 2 functions one after the other but not inside each other).

oh and one step i missed to check for names that use underscore instead of space we'd need a way to turn all spaces into underscores

I think it would just be a vector read and replace operation myself.

Code:
if(v[i]==" ",v{i]=="_")

Last fiddled with by science_man_88 on 2010-08-11 at 14:36
science_man_88 is offline   Reply With Quote
Old 2010-08-11, 14:45   #233
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

135338 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
so the basic idea I have of the process required is:

1)read for updates
2)send request to next part of script
3)find function names that can be understood in the text (if none exist give error and/or print questions the script has about the request)
4)print out code for functions if they are found to be in the database.
5) post code to Mersenne forums website.
Sounds good. #3 is the hard part, #4 is the part I suggested working on. #1 and #5 are doable but not very useful until the others are done. (Also, compared to #2 and #3 those steps are fairly unfun.)

I think your first task should be #0: split the large tasks #2 and #3 into smaller subtasks (5-10 tasks each, if you can manage).

Quote:
Originally Posted by science_man_88 View Post
hard part about this now is mostly with if 2 functions need to be embedded with each other later (I've already worked out how to print 2 functions one after the other but not inside each other).
What are you trying to do that would require a function inside a function?

Quote:
Originally Posted by science_man_88 View Post
oh and one step i missed to check for names that use underscore instead of space we'd need a way to turn all spaces into underscores

I think it would just be a vector read and replace operation myself.

Code:
if(v[i]==" ",v{i]=="_")
Yes, that would work, and the resulting vector can be concatenated back to a string. But if you start with a string "What are the first 10 Mersenne primes?" you don't really want to call the function What_are_the_first_10_Mersenne_primes, but rather something like firstMersenne(10). It's not an easy problem by any means!

Last fiddled with by CRGreathouse on 2010-08-11 at 14:49
CRGreathouse is offline   Reply With Quote
Old 2010-08-11, 14:55   #234
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post

Yes, that would work, and the resulting vector can be concatenated back to a string. But if you start with a string "What are the first 10 Mersenne primes?" you don't really want to call the function What_are_the_first_10_Mersenne_primes, but rather something like firstMersenne(10). It's not an easy problem by any means!
why not just Mersenne_Primes(n) ? the n would still have to be found later though.

Last fiddled with by science_man_88 on 2010-08-11 at 14:56
science_man_88 is offline   Reply With Quote
Old 2010-08-11, 15:04   #235
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
why not just Mersenne_Primes(n) ? the n would still have to be found later though.
Either name would be fine. I'm just saying that you don't want a new function name for every English sentence -- there are too many valid sentences. (There are maybe half a million words in English. If you recognize 10,000 of those, and if only 1% of those are valid at a given point in the sentence, then there are 10^22 10-word sentences... writing one function per second, this would take 3 trillion lifetimes to finish.)
CRGreathouse is offline   Reply With Quote
Old 2010-08-11, 15:08   #236
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

203008 Posts
Default

check modified post against vector of functions in database if it doesn't contain one of them or it still can't make sense of it all it's returns an error or questions respectively

Code:
first_Mersenne_Primes(n)=Mersenne_Primes(n)
?

that's the problem we need the code to make the problem into something it can understand before handing it the reins.

Last fiddled with by science_man_88 on 2010-08-11 at 15:12
science_man_88 is offline   Reply With Quote
Old 2010-08-11, 15:11   #237
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
Seeing as it works just fine for small numbers (I would rarely need it for large integers), it works for me!
Really? I would expect it to be used only for reasonably large numbers. I've run it on all odd numbers below 10^10, for example, which is easily large enough to have trouble with roundoff.
CRGreathouse is offline   Reply With Quote
Old 2010-08-11, 15:19   #238
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

well i showed how I'd break it down logically myself can we get the script to do the same.
science_man_88 is offline   Reply With Quote
Old 2010-08-11, 15:24   #239
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

32208 Posts
Default

Quote:
Originally Posted by CRGreathouse
Really? I would expect it to be used only for reasonably large numbers. I've run it on all odd numbers below 10^10, for example, which is easily large enough to have trouble with roundoff.
Yeah, it seems to work just fine with me, up until the 1030 range.

Also: Improved the precision.

For 1987021, there are ≈372006 bases which pass it as a pseudoprime.

Last fiddled with by 3.14159 on 2010-08-11 at 15:28
3.14159 is offline   Reply With Quote
Old 2010-08-11, 15:29   #240
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

110100100002 Posts
Default

@Sm88: Did you define what the Mersennes are? (Or at least Mersenne_Primes(n)?)

@CRG: I found the weakness in your program: It depends on factoring n.

What if n = something like 8929916458641913352287532945770212899164203997 * 4483710071772199066536995719064666355529706337783587 ?

Your program is rendered useless unless n is easily factored.

Last fiddled with by 3.14159 on 2010-08-11 at 15:37
3.14159 is offline   Reply With Quote
Old 2010-08-11, 15:35   #241
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
Yeah, it seems to work just fine with me, up until the 1030 range.

Also: Improved the precision.
If it works for you up to 10^30 then your precision is set to at least, say, 30 decimal digits.

Again, I don't see the point in roundtripping: more time, possible precision errors.
CRGreathouse is offline   Reply With Quote
Old 2010-08-11, 15:38   #242
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

175B16 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
@CRG: I found the weakness in your program: It depends on factoring n.
Not really a weakness. The naive method requires n-1 modular exponentiations mod n, taking time O(n\log^2n) or so. If Pari factored the numbers by trial division it would take time O(\sqrt n) which is vastly better (~1000 trillion times better around 10^30 where you were just calculating). Of course Pari actually uses better methods, so it's faster yet.

Edit: You edited this following quote into your above post, so I'll edit in my reply.
Quote:
Originally Posted by 3.14159 View Post
What if n = something like 8929916458641913352287532945770212899164203997 * 4483710071772199066536995719064666355529706337783587 ?
The naive method would test all ~4e97 bases. Each base would require the calculation of b^(n-1) mod n. These take about a millisecond each, for a total of ~4e94 seconds or ~1e85 lifetimes. Factoring n, if it wasn't written as above, could be done in a few hours. Big win for 'my' method.

Last fiddled with by CRGreathouse on 2010-08-11 at 15:43
CRGreathouse is offline   Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why do I sometimes see all the <> formatting commands when I quote or edit? cheesehead Forum Feedback 3 2013-05-25 12:56
Passing commands to PARI on Windows James Heinrich Software 2 2012-05-13 19:19
Ubiquity commands Mini-Geek Aliquot Sequences 1 2009-09-22 19:33
64-bit Pari? CRGreathouse Software 2 2009-03-13 04:22
Are these commands correct? jasong Linux 2 2007-10-18 23:40

All times are UTC. The time now is 06:55.


Fri Aug 6 06:55:00 UTC 2021 up 14 days, 1:23, 1 user, load averages: 2.48, 2.66, 2.72

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.