Search code examples
plotgraphicslatexpari-gp

Plothraw PARIGP (or similar) doesn't work (latexit crash)


I'm a new user of PARI/GP, and after writing my script, I wanted to make a graph of it. As my function take an integer and return a number, it's closer to a sequence. Actually, I didn't know how to do it, so I read the documentation of PARI/GP, and after that I made some test in order to obtain a graph from a list.

After reading an answer in stackoverflow (Plotting multiple lists in Pari), I wanted to test with the following code:

plothraw([0..200], apply(i->cos(i*3*Pi/200), [0..200]), 0);

But when I do it, it tries to open something on latexit, but then it crash and give me a problem report.

I didn't even know that I had an app named latextit, maybe it was install during the installation of PARI/GP. Anyway, how can I fix this?


Solution

    1. PARI/GP definitely doesn't install latexit.

    2. The way hi-res graphics work on the Win32 version of PARI/GP is to write down an Enhanced Metafile (.EMF) in a temp directory and ask the system to "open" it. When you installed latexit it probably created an association in the registry to let it open .EMF files

    3. i3Pi does not mean what you think, it just creates a new variable with that name. You want i * 3 * Pi instead.

    4. The following constructions both work in my setup

      plothraw([0..200], apply(i->cos(i*3*Pi/200), [0..200]), 0);
      plothraw([0..200], apply(i->cos(i*3*Pi/200), [0..200]), 1);
      

    (the second one being more readable because a red line is drawn between successive points; I have trouble seeing the few tiny blue dots)

    1. Instead of apply, you can use a direct constructor as in

        vector(201, i, cos((i-1) * 3 * Pi / 200))
      

    which of course can be computed more efficiently as

         real( powers(exp(3*I*Pi/200), 200) )
    

    (of course, it doesn't matter here, but compare both commands at precision \p10000 or so ...)