Ask Your Question

RuudH's profile - activity

2020-11-10 17:20:21 +0200 received badge  Notable Question (source)
2020-11-10 17:20:21 +0200 received badge  Popular Question (source)
2020-10-02 13:57:29 +0200 received badge  Popular Question (source)
2018-09-26 19:16:52 +0200 asked a question Latex commands \lfloor and \lceil work, but their counterparts won't.

Encountered a strange problem when using latex in the titles, labels or legends of plots:

a=point2d(xy, title="$\lceil x \lfloor$")

works fine (xy contains a list of points), however:

a=point2d(xy, title="$\rceil x \rfloor$")

gives an error (whatever combination I try). The same happens in the legends and axis labels.

Am I doing something wrong here or is this a bug in latex in the plot texts?

2018-03-29 15:25:31 +0200 commented answer Is it possible to use Arb-library commands directly in Sagemath?

Hey, hey, hey... :-) It does work indeed. Sagemath continues to impress me! I am actually aiming to code the Riemann Xi function (s=x+iy):

s/2*(s-1)*pi^(-s/2)*gamma(s/2)*zeta(s)

using complex Ballfields only.

Thanks B r u n o !

EDIT: Here is the 'ball' code for the Riemann Xi function. It is super fast (e.g. compared to pari)

x=1/3;y=200000
z  = CBF(x,y)
z2 = z/RBF(2)
n1 = RBF(1)
K  = z2*(z-n1)*RBF(pi)^(RBF(-1)*z2)*z2.gamma()*z.zeta()
CIF(K)
2018-03-29 13:54:32 +0200 commented answer Is it possible to use Arb-library commands directly in Sagemath?

Thanks Bruno. This is very helpful! I can now use functions like gamma and zeta as a CBF.method, however could not find how to e.g. add or multiply two CBF's together and get a new CBF, i.e. the basic algebra you could do in Arb doesn't seem to be supported (yet), right?

2018-03-29 00:43:30 +0200 asked a question Is it possible to use Arb-library commands directly in Sagemath?

I would like to use some commands/functions from the high performance/precision Arb-library that in turn builds on the Flint-library. Searching the web, I did find references that some commands from both libraries already underpin directly or indirectly the Sagemath environment, however basic commands like for instance:

arb.pi()

don't seem to be supported (or better, I couldn't get them to work yet).

What I am after is to use Flint and Arb functions within Python like in this example, but then under the Sagemath umbrella. Is this already possible?

Thanks.

2018-03-29 00:27:26 +0200 commented answer Using multiple lines of pari/gp code in a Sage notebook

You're a star, @slelievre! It works perfectly and performs exactly as I wanted. In a dedicated pari-file the loops now function properly. I would have never figured this out myself.

2018-03-27 12:56:04 +0200 commented answer Using multiple lines of pari/gp code in a Sage notebook

@slelievre. Thanks for the detailed explanation. I have followed the instructions but unfortunately end up with an error (see screenshot attached). It seems that the limit.h file can't be found on my machine. Do you have an idea on how to resolve this? https://ibb.co/g2UZ77

2018-03-26 15:50:29 +0200 commented answer Using multiple lines of pari/gp code in a Sage notebook

Thanks for your response! I will try that out, but would appreciate some coaching. I have installed Sage/Jupyter notebook on a MAC and am not sure where exactly I have to type the command $ sage -i pari_jupyter. Is this on the command prompt (Terminal)?

2018-03-26 14:14:18 +0200 received badge  Nice Question (source)
2018-03-25 22:58:41 +0200 asked a question Using multiple lines of pari/gp code in a Sage notebook

I am struggling to get multiple lines of pari/gp code working in a Jupyter Sage notebook.

When I enter:

%%gp
for(x=1,10,print(x))

it all works fine, however when I for instance write:

%%gp
for(x=1,10,{
    print(x);
})

the system just 'hangs' and doesn't return any output. The same issue occurs in the Cocalc Sage cloud environment. I also tried 'pari/gp in your browser' and there it works fine.

Am I doing something wrong or isn't the multi-line pari/gp option supported in Sage?

2018-03-01 20:38:06 +0200 commented answer The use of %gp to switch to Pari/gp commands

Oops. Just realised there probably isn't a code to toggle back, since %%gp turns the entire cell in Pari/GP code and using %gp <command> allows me to mix and match Pari/GP commands and other languages.

2018-03-01 19:58:50 +0200 commented answer The use of %gp to switch to Pari/gp commands

Many thanks for your swift response, Bruno. That is exactly what I was looking for! Have tried it and it works perfectly :-)

Just one more question if I may, what is the code to toggle back from pari/gp to Sage/Python code?

2018-03-01 17:20:08 +0200 asked a question The use of %gp to switch to Pari/gp commands

I am using Sagemath 8.0 on my computer and also have subscribed to Cocalc (the former Sagemathcloud). I currently do quite a bit of programming in Pari/gp and noted that using %gp in the Cocalc-cloud allows me to switch to entering a sequence of Pari/gp commands, however this doesn't seem to work for the PC-version I use. Of course I can circumvent this by transforming each Pari/gp command into a string with pari(' .... '), however that can only be done line by line and produces ugly code.

Is it correct that %gp doesn't work on the PC version and if so, is there another way to write multiple lines of Pari/gp code other than producing line by line strings and/or use the terminal?

Thanks.

2018-02-09 17:54:15 +0200 commented answer Using Sage plotting capability on data from PARI/GP (1)

That's it! Many thanks for your help, tmonteil. I am really impressed by the speed of response and the expertise on this forum :-)

2018-02-09 16:20:43 +0200 asked a question Using Sage plotting capability on data from PARI/GP (1)

This is a short follow-up question from this one.

I would like to produce an implicit plot (a contour plot where the real or imaginary values of a function are zero):

var('x,y,s')
g=real(zeta(s))
implicit_plot(lambda x,y:g(x+y*I),(x,-3,3),(y,-3,3))

This works fine, however I want to use GP/Pari to evaluate the zeta function and therefore wrote:

var('x,y')
g=gp("H(s)=zeta(s)")
implicit_plot(lambda x,y:real_part(g(x+y*I)),(x,-3,3),(y,-3,3))

but then keep getting an error message:

PARI/GP ERROR: at top-level: sage[45020]=sage[16][1] ^--- incorrect type in _[_] OCcompo1 [not a vector] (t_REAL).*

For 'normal' plots like this one:

var('x')
g=gp("H(s)=real(zeta(s))")
plot(lambda x:(g(x)),(x,3,6))

the interface with GP works fine, so I probably do something wrong using multiple variables or complex numbers? It doesn't seem to be zeta-function specific (like the pole at s=1), since it also fails for e.g. the cos-function.

Grateful for any advice on how to make this work.

Thanks!

2018-02-08 20:10:46 +0200 commented answer Using Sage plotting capability on data from PARI/GP

Many thanks! This works very well indeed. I had seen the use of the lambda before, but never related it to calls with PARI/GP objects.

2018-02-08 20:08:36 +0200 received badge  Supporter (source)
2018-02-08 20:08:35 +0200 received badge  Scholar (source)
2018-02-08 20:06:21 +0200 received badge  Student (source)
2018-02-08 20:01:52 +0200 asked a question Using Sage plotting capability on data from PARI/GP

I am trying to plot data in Sage that is generated by a function in PARI/GP, however keep getting type errors.

I use this simple example to illustrate the point:

f=(gp("Z(s)=zeta(s)"))
f(2)

This gives the correct output 1.6449340668482264364724151666460251892 and appears to be a 'normal' floating point number that I can indeed multiply/add with.

However, when I try the following:

plot(f,(2,6))

It keeps coming back with

TypeError: Error executing code in GP

I have studied most of the (limited) info on the Pari/GP interface and did read that PARI/GP always returns a string. I therefore tried to convert the returned value into a float, int etc., however nothing works. I very likely do something wrong (or not allowed) and would be grateful for any advice on what could be the issue here (esp. since f(2) gives the correct numerical floating point result).

Thanks!