![]() |
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]=="_")[/CODE] |
[QUOTE=science_man_88;224913]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.[/QUOTE] 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=science_man_88;224914]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).[/QUOTE] What are you trying to do that would require a function inside a function? [QUOTE=science_man_88;224914]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]=="_")[/CODE][/QUOTE] 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! |
[QUOTE=CRGreathouse;224916]
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![/QUOTE] why not just Mersenne_Primes(n) ? the n would still have to be found later though. |
[QUOTE=science_man_88;224918]why not just Mersenne_Primes(n) ? the n would still have to be found later though.[/QUOTE]
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.) |
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)[/CODE]? that's the problem we need the code to make the problem into something it can understand before handing it the reins. |
[QUOTE=3.14159;224909]Seeing as it works just fine for small numbers (I would rarely need it for large integers), it works for me![/QUOTE]
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. |
well i showed how I'd break it down logically myself can we get the script to do the same.
|
[QUOTE=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.
[/QUOTE] Yeah, it seems to work just fine with me, up until the 10[sup]30[/sup] range. Also: Improved the precision. For 1987021, there are ≈372006 bases which pass it as a pseudoprime. |
@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. |
[QUOTE=3.14159;224923]Yeah, it seems to work just fine with me, up until the 10[sup]30[/sup] range.
Also: Improved the precision.[/QUOTE] If it works for you up to 10^30 then your precision is set to at least, say, 30 decimal digits. :smile: Again, I don't see the point in roundtripping: more time, possible precision errors. |
[QUOTE=3.14159;224924]@CRG: I found the weakness in your program: It depends on factoring n.[/QUOTE]
Not really a weakness. The naive method requires n-1 modular exponentiations mod n, taking time [TEX]O(n\log^2n)[/TEX] or so. If Pari factored the numbers by trial division it would take time [TEX]O(\sqrt n)[/TEX] 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=3.14159;224924]What if n = something like 8929916458641913352287532945770212899164203997 * 4483710071772199066536995719064666355529706337783587 ?[/QUOTE] 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. |
| All times are UTC. The time now is 22:21. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.