• 0 Vote(s) - 0 Average
• 1
• 2
• 3
• 4
• 5
 Creating Hue Plots in Pari-GP JmsNxn Long Time Fellow Posts: 503 Threads: 89 Joined: Dec 2010 05/12/2021, 04:31 AM I've e-mailed sheldonison, but I'm getting the feeling he's super busy. I've scoured throughout the internet looking for help on this. I asked a question on stackoverflow. And now I'm asking this question here. How do you plot complex valued functions in Pari-GP? Particularly; I mean, how do you create hue plots using Pari-GP? Is there something stupid I'm missing here? I've got my Pari-gp code as good as I can get it at this point (there are still some jumps which occur because Pari is always choosing the principal branch; but in limited cases everything is working). Do I make an array of values and use the colour plot function somehow? I'm fairly confused. I'm just wondering how Sheldon produces his graphs in Pari; and I feel I'm missing something stupid..? Any help is greatly appreciated... All of this is reminding me of why I dropped my major from computer science years ago. I god damn hate coding (unless it's theory, of course). Regards, James Gottfried Ultimate Fellow Posts: 787 Threads: 121 Joined: Aug 2007 05/12/2021, 01:11 PM (This post was last modified: 05/12/2021, 01:13 PM by Gottfried.) Hi James,  I don't know at the moment, whether in Sheldon's "fatou.gp" there is also that picture_out routine for creating coloured images for complex coordinates. I remember a similar routine provided by tet-forum member Mike. It takes a matrix of complex values and writes a *.ppm file (some basic graphic-file-format) with rgb-values. File should be findable in appendices of tetration forum.     This is a version from 2010, don't know whether there are updates in the forum available. Kind regards- Gottfried PHP Code:`/* =============================================================================  ** Color graphing system - mike3 - 20.11.10 04:07** Hi.** I thought I'd post the code I use to generate the color graphs from Pari/GP.** Here it is.**** Note: the output is in .PPM format. ** You'll need something else to convert that to .PNG. (I use GIMP.)** ** Also, I might warn you: it takes a LONG time to graph a complex function** with a significantly complicated calculation procedure, as it must be** evaluated at every pixel of the graph.** ** (updated 12/16/2010 -- program was not all good: **   * spurious "func" parameter in MakeGraph and "safetyarg" was missing.)** ------------------------------------------------------------------------------------------ **  ** ============================================================================= *//* =============================== Code: ==================================================== *//* Complex function magnitude/phase plotter. *//* To use:*     1. Define function to graph as func(z).*     2. Load this program.*     3. Execute MakeGraph(width, height, x0, y0, x1, y1, filename) with the parameters given as follows:*        width, height = width/height of image in pixels*        x0, y0, x1, y1 = rectangle of complex plane to graph: x0 + y0i in upper-left corner to x1 + y1i in lower-right corner*        filename = name of file to save as.* Output is in .PPM format.*//* Color conversion (HSB to RGB). */HSB2RGB(hsb) = {       local(H=hsb[1]);       local(S=hsb[2]);       local(B=hsb[3]);       local(HH);       local(F);       local(P);       local(Q);       local(T);       HH = floor(6*H)%6;       F = (6*H) - floor(6*H);       P = B*(1 - S);       Q = B*(1 - (F*S));       T = B*(1 - (1-F)*S);       if(B > 1.0, B = 1.0);       if(B < 0.0, B = 0.0);       if(P > 1.0, P = 1.0);       if(P < 0.0, P = 0.0);       if(Q > 1.0, Q = 1.0);       if(Q < 0.0, Q = 0.0);       if(T > 1.0, T = 1.0);       if(T < 0.0, T = 0.0);       if(HH == 0, return([B, T, P]));       if(HH == 1, return([Q, B, P]));       if(HH == 2, return([P, B, T]));       if(HH == 3, return([P, Q, B]));       if(HH == 4, return([T, P, B]));       if(HH == 5, return([B, P, Q]));       }/* Safe argument. */safetyarg(z) = if(z == 0, 0, arg(z));/* Make graph. */MakeGraph(width, height, x0, y0, x1, y1, filename) = {       xstep = (x1 - x0)/width;       ystep = (y1 - y0)/height;       write(filename, "P3");       write(filename, "# ", filename);       write(filename, width, " ", height);       write(filename, "255");       for(y=0, height-1,           for(x=0, width-1,                  xx = x0+(xstep*x);                  yy = y0+(ystep*y);               z = xx+yy*I;               funcvalue = func(z);               mag = abs(funcvalue);               phase = safetyarg(funcvalue);               H = phase/(2*Pi);               S = 1/(1 + 0.3*log(mag + 1));               B = 1 - 1/(1.1 + 5*log(mag + 1));               RGB = HSB2RGB([H, S, B]);                  Red = floor(RGB[1]*255.0);                  Green = floor(RGB[2]*255.0);                  Blue = floor(RGB[3]*255.0);               write1(filename, Red, " ", Green, " ", Blue, "  ");              );           write(filename, "");       );    } ` Gottfried Helms, Kassel JmsNxn Long Time Fellow Posts: 503 Threads: 89 Joined: Dec 2010 05/13/2021, 01:48 AM (This post was last modified: 05/13/2021, 08:13 AM by JmsNxn.) Thanks so much, Gottfried! This works perfectly; albeit, it's a little slow. I'm going to try and make some graphs now. Regards, James I don't think this is the same program Sheldon uses, but god damned is this better. Here's my solution to the Abel equation with $\log(2)$ multiplier over $-1 \le \Re(z) \le 4$ and $0.5 \le \Im(z) \le 2.5$:     EDIT: This is about 8 digit precision; it may dip to 4 occasionally, but it hovers around 12; so let's just say 8. « Next Oldest | Next Newest »

 Possibly Related Threads... Thread Author Replies Views Last Post PARI/gp Xorter 14 25,448 07/09/2018, 08:54 AM Last Post: Xorter Pari-TTY - update Gottfried 0 3,690 10/13/2007, 04:02 PM Last Post: Gottfried

Users browsing this thread: 1 Guest(s)