mersenneforum.org  

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

Reply
 
Thread Tools
Old 2012-07-17, 13:52   #2366
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

20C016 Posts
Default

newest idea for the BHP script:

Code:
BHP(n) =until(n==0,print(dp(n));n=n%(10^(length(Str(n))-1)))
admittedly this prints right now it can concat later into a position in a new vector now the problem is keeping only the ones that specifically start with the correct position. of course it may get tricky going to other bases, except for maybe using convert.

Last fiddled with by science_man_88 on 2012-07-17 at 13:54
science_man_88 is offline   Reply With Quote
Old 2012-07-19, 18:43   #2367
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

the closest I could get to what's needed for BHP to be like a human searching is:

Code:
n=33191;
a=Vec(Str(n));
b="";
c=vector(#a,z,[]);
for(x=1,#a,
    for(y=x,#a,
         b=concat(b,a[y]);
         if(isprime(eval(b)),
            c[x]=concat(c[x],eval(b))
           )
        );
    b="")
    ;c
Yes I know some are already yelling to use my and I might later, there was a way with duplicates everywhere to get something like this using one vector call but it would take a while to eliminate duplicates from what I could see. with this layout is the difficulty is in finding ways that work to the total length using values in different elements of the outer vector.
science_man_88 is offline   Reply With Quote
Old 2012-07-19, 20:27   #2368
chalsall
If I May
 
chalsall's Avatar
 
"Chris Halsall"
Sep 2002
Barbados

2·67·73 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
Yes I know some are already yelling to use my and I might later, there was a way with duplicates everywhere to get something like this using one vector call but it would take a while to eliminate duplicates from what I could see.
If a tree falls in a forest and no one is around to hear it, does it make a sound?
chalsall is online now   Reply With Quote
Old 2012-09-08, 21:47   #2369
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

20C016 Posts
Default

Code:
y=1;
a=vector(2000000,n,
             until(isprime(y) && !(y>3 && y%4==3 && isprime(2*y+1)),
                    y=y+1);
             y
            )
this makes a list of prime exponents to check with LL. admittedly I don't know what other conditions to delete them by, I know what it's searching right now is already done.

remade with
Code:
y=y+1
into:
Code:
if(y%6==1,y=y+4,y=y+2)

Last fiddled with by science_man_88 on 2012-09-08 at 22:02
science_man_88 is offline   Reply With Quote
Old 2012-09-08, 23:00   #2370
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

You should use the select command.

Start with a list of primes
Code:
candidates=primes(1000);
Remove primes p with 2p+1 prime unless p is 1 mod 4:
Code:
candidates=select(p -> p%4==1 || !isprime(2*p+1), candidates);
If you're using an older version of gp you need to switch the arguments around:
Code:
candidates=select(candidates, p -> p%4==3 && isprime(2*p+1));
CRGreathouse is offline   Reply With Quote
Old 2012-09-08, 23:12   #2371
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

838410 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
You should use the select command.

Start with a list of primes
Code:
candidates=primes(1000);
Remove primes p with 2p+1 prime unless p is 1 mod 4:
Code:
candidates=select(p -> p%4==1 || !isprime(2*p+1), candidates);
If you're using an older version of gp you need to switch the arguments around:
Code:
candidates=select(candidates, p -> p%4==3 && isprime(2*p+1));
see the thing I like about my code ( though I admit yours is a lot faster) is that it can start at any number ( in any range) the way it was originally stated and can go faster with the optimizations to it I made. doh just figured out the easy way to do that with your script.

Last fiddled with by science_man_88 on 2012-09-08 at 23:22
science_man_88 is offline   Reply With Quote
Old 2012-09-09, 02:42   #2372
cmd
 
cmd's Avatar
 
"(^r'°:.:)^n;e'e"
Nov 2008
;t:.:;^

99910 Posts
Cool

Quote:
Originally Posted by science_man_88 View Post
... into:
Code:
if(y%6==1,y=y+4,y=y+2)
hi, try :
Code:
 y+=if(y%6==1,4,2)
cmd is offline   Reply With Quote
Old 2012-11-17, 01:34   #2373
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

100000110000002 Posts
Default

this came out of someone talking annual capital gains percentage but me interpreting it as interest rate annually:

Code:
gainsversusinterest(a,b,c,d)= (((a/b)/c)*d)^(1/d)
a is the money unit/valued unit between b and the current value, b is the \$value at a given past time, c is the number of time units to gain those \$a, d is the number time units to forecast at this rate into the future, the ^(1/d) is taking the interest rate equivalent compound.

Last fiddled with by science_man_88 on 2012-11-17 at 01:36
science_man_88 is offline   Reply With Quote
Old 2013-06-12, 01:21   #2374
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

203008 Posts
Default

an attempted remake ( and correction at last check) of the FaR script:

Code:
 
FaR(S1,S2,S3) = aa=eval(Vec(S1));for(x=1,#aa,if(vecextract(aa,)==eval(Vec(S2)),))
the problem is though I know a range string works I don't see how to put it into it based on the variables x ,and length of S2, also the actual replacing become hard this way I think, anyone with an idea for the solutions?
science_man_88 is offline   Reply With Quote
Old 2013-06-12, 01:58   #2375
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

135338 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
the problem is though I know a range string works I don't see how to put it into it based on the variables x ,and length of S2, also the actual replacing become hard this way I think, anyone with an idea for the solutions?
If you can be very specific in explaining what you want, I may be able to help.
CRGreathouse is offline   Reply With Quote
Old 2013-06-12, 02:07   #2376
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

20C016 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
If you can be very specific in explaining what you want, I may be able to help.
Quote:
? ?vecextract
vecextract(x,y,{z}): extraction of the components of the matrix or vector x according to y and z. If z is omitted, y represents columns, otherwise y corresponds to rows and z to columns. y and z can
be vectors (of indices), strings (indicating ranges as in "1..10") or masks (integers whose binary representation indicates the indices to extract, from left to right 1, 2, 4, 8, etc.).
This talks of the string range option. I'm trying to use it with a variable x as the starting position and only go as far as the length of the S2 variable further. This is so I can the whole length vector version of S2 to something the same length (instead of looping through each letter), if it gets found then my effort goes to working on the problems of replacing.

edit:

I realized that the vector option was an option but then I still fail to make it work.

Last fiddled with by science_man_88 on 2013-06-12 at 02:14
science_man_88 is offline   Reply With Quote
Reply

Thread Tools


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 22:04.


Fri Aug 6 22:04:29 UTC 2021 up 14 days, 16:33, 1 user, load averages: 3.01, 2.83, 2.71

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.