mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   PARI/GP (https://www.mersenneforum.org/forumdisplay.php?f=155)
-   -   PARI's commands (https://www.mersenneforum.org/showthread.php?t=13636)

science_man_88 2012-07-17 13:52

newest idea for the BHP script:

[CODE]BHP(n) =until(n==0,print(dp(n));n=n%(10^(length(Str(n))-1)))[/CODE]

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.

science_man_88 2012-07-19 18:43

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[/CODE]

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.

chalsall 2012-07-19 20:27

[QUOTE=science_man_88;305180]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.[/QUOTE]

If a tree falls in a forest and no one is around to hear it, does it make a sound?

science_man_88 2012-09-08 21:47

[CODE]y=1;
a=vector(2000000,n,
until(isprime(y) && !(y>3 && y%4==3 && isprime(2*y+1)),
y=y+1);
y
)[/CODE]

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[/CODE] into: [CODE]if(y%6==1,y=y+4,y=y+2)[/CODE]

CRGreathouse 2012-09-08 23:00

You should use the select command.

Start with a list of primes
[code]candidates=primes(1000);[/code]

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);[/code]

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));[/code]

science_man_88 2012-09-08 23:12

[QUOTE=CRGreathouse;310801]You should use the select command.

Start with a list of primes
[code]candidates=primes(1000);[/code]

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);[/code]

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));[/code][/QUOTE]

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.

cmd 2012-09-09 02:42

[QUOTE=science_man_88;310794]... into: [CODE]if(y%6==1,y=y+4,y=y+2)[/CODE][/QUOTE]

hi, try :
[CODE] y+=if(y%6==1,4,2) [/CODE]

science_man_88 2012-11-17 01:34

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)[/CODE]
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.

science_man_88 2013-06-12 01:21

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)),))
[/CODE]

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?

CRGreathouse 2013-06-12 01:58

[QUOTE=science_man_88;343116]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?[/QUOTE]

If you can be very specific in explaining what you want, I may be able to help.

science_man_88 2013-06-12 02:07

[QUOTE=CRGreathouse;343117]If you can be very specific in explaining what you want, I may be able to help.[/QUOTE]

[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.).[/quote]

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.


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

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