1

everyone. This is another quick question about pari-gp.

I've written my main file such that two different functions work better if \ps 100 or \ps 36; and so I want to specify to some functions, before running, so that locally we can say \ps 100 or \ps 36.

By this I want a function with similar functionality as localprec--but with series precision as opposed to digit precision. This would mean we could have something like this,

\ps 100
/*....a bunch of code here....*/

my_local_function(var) = {
    localserprec(36); /*sets local series precision to 36, only for this function*/
    
    /*bunch of code here....*/
}

The 100 series precision functions never interact with the 36 series precision functions except when dropping down to 36. We never try to go from 36 to 100, so there should be no real problem.

Any help or comments is greatly appreciated.

Richard Diagram
  • 209
  • 1
  • 7

2 Answers2

3

If I understand your question correctly, you want something like this:

my_local_function(var, {d=36}) = {
    my(old_precision = default(seriesprecision));
    default(seriesprecision, d);

    /* bunch of your code here.... */

    default(seriesprecision, old_precision);    
}

This will set d as the series precision locally applying only to your function body as you expected.

Piotr Semenov
  • 1,761
  • 16
  • 24
  • That's exactly what I'm looking for! Thanks, again! – Richard Diagram Aug 25 '21 at 22:13
  • 1
    @RichardDiagram You're welcome! By the way, what pari-gp project are you working on if no secret? – Piotr Semenov Aug 26 '21 at 08:10
  • I'm programming a tetration calculator. The only known existing calculator is really Sheldon Levenstein's fatou.gp program--which is made off of Kneser's solution to tetration. I've constructed an alternative method of making a holomorphic/real-valued tetration--but I need a decent calculator to numerically verify that it is in fact not Kneser's tetration. So far all the evidence is pointing towards this being a novel tetration. I'm a mathematician by trade, and haven't done real programming in a while. This would disprove a conjecture that Kneser is the only "good" tetration. – Richard Diagram Aug 26 '21 at 22:34
  • 1
    I'm currently just optimizing it and creating more "quality of life" alterations so it's easier to manipulate. This thread https://math.eretrandre.org/tetrationforum/showthread.php?tid=1327 is the first beta, and this thread https://math.eretrandre.org/tetrationforum/showthread.php?tid=1344 is the second beta. It gives a synopsis of the math too. You can also read the preprint Limits Of A Family; Of asymptotic solutions to the tetration equation here https://arxiv.org/abs/2104.01990 – Richard Diagram Aug 26 '21 at 22:41
  • 1
    @RichardDiagram Wow, great! Nice to hear that this helps you to do the complex math research. It is very interesting. If I can help you, please reach me on LinkedIn or GitHub. I'm the only Piotr Semenov there :) – Piotr Semenov Aug 30 '21 at 09:15
  • Will do, if anything comes up! Thanks again! – Richard Diagram Aug 31 '21 at 01:34
1

The code I use is (It is self-explained)

Serprec(n) = if(type(n) == "t_INT" && n > 0,
             default(seriesprecision,n); default(seriesprecision),
             default(seriesprecision));

If n is omitted or invalid, it returns current series precision. A valid value sets series precision to n terms.

An example, a component-wise multiplication of two vectors. It modifies series precision, but restores it before exit.

mult_vec(A,B,n1=#B) = 
{    
my(n = min(#B,min(n1,#A)), q = vector(n), p = Serprec());
Serprec(n);
q = Vec(serconvol(Ser(A),Ser(B)));
Serprec(p);
return(q);
}
Jorge Zuniga
  • 121
  • 4
  • OH! This is really nice. I'm currently finalizing a large program which used the first answer; but this will definitely help. It's a much more direct way of grabbing and holding the series precision then moving it. This is great!!!! – Richard Diagram Apr 04 '22 at 07:39