Creating Hue Plots in Pari-GP - Printable Version +- Tetration Forum (https://math.eretrandre.org/tetrationforum) +-- Forum: Tetration and Related Topics (https://math.eretrandre.org/tetrationforum/forumdisplay.php?fid=1) +--- Forum: Computation (https://math.eretrandre.org/tetrationforum/forumdisplay.php?fid=8) +--- Thread: Creating Hue Plots in Pari-GP (/showthread.php?tid=1322) Creating Hue Plots in Pari-GP - JmsNxn - 05/12/2021 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 RE: Creating Hue Plots in Pari-GP - Gottfried - 05/12/2021 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, "");       );    } ` RE: Creating Hue Plots in Pari-GP - JmsNxn - 05/13/2021 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$: [attachment=1503] EDIT: This is about 8 digit precision; it may dip to 4 occasionally, but it hovers around 12; so let's just say 8. RE: Creating Hue Plots in Pari-GP - Ember Edison - 09/24/2021 (05/12/2021, 04:31 AM)JmsNxn Wrote: 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 I calculated the value of the function by Pari-GP and then imported the value into Mathematica to export the image. As I mentioned before, I wouldn't have switched to Pari-GP if MMA didn't have very poor support for large number functions. This also has the good thing that if I want to make a super high resolution image, I can do it in parallel and support breakpoints. (By fully manual parallel scheduling, of course) The color scheme I use is Hue[(Abs@rawdata+Pi)/(2 Pi), 1/(1+0.3 Arg@rawdata), 1 - 1/(1.1+5 Arg@rawdata)]. This makes the color scheme of the images I draw look "opposite". https://upload.wikimedia.org/wikipedia/commons/b/ba/Pathological_phenomenon_for_fatou_tetration_when_abs%28base%29_close_to_1.gif https://upload.wikimedia.org/wikipedia/commons/1/1e/Complex_Kneser%27s_Tetration_when_base_is_a_real_number.gif https://upload.wikimedia.org/wikipedia/commons/0/07/Complex_Kneser%27s_Tetration_when_abs%28base%29%3D10%5E6.gif https://upload.wikimedia.org/wikipedia/commons/6/62/Complex_Kneser%27s_Tetration_when_abs%28base%29%3De.gif ps:I am so sorry. is Hue[(Arg@rawdata+Pi)/(2 Pi), 1/(1+0.3 Log@Abs@rawdata), 1 - 1/(1.1+5 Log@Abs@rawdata)]. RE: Creating Hue Plots in Pari-GP - JmsNxn - 09/25/2021 (09/24/2021, 06:27 PM)Ember Edison Wrote: (05/12/2021, 04:31 AM)JmsNxn Wrote: 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 I calculated the value of the function by Pari-GP and then imported the value into Mathematica to export the image. As I mentioned before, I wouldn't have switched to Pari-GP if MMA didn't have very poor support for large number functions. This also has the good thing that if I want to make a super high resolution image, I can do it in parallel and support breakpoints. (By fully manual parallel scheduling, of course) The color scheme I use is Hue[(Abs@rawdata+Pi)/(2 Pi), 1/(1+0.3 Arg@rawdata), 1 - 1/(1.1+5 Arg@rawdata)]. This makes the color scheme of the images I draw look "opposite". https://upload.wikimedia.org/wikipedia/commons/b/ba/Pathological_phenomenon_for_fatou_tetration_when_abs%28base%29_close_to_1.gif https://upload.wikimedia.org/wikipedia/commons/1/1e/Complex_Kneser%27s_Tetration_when_base_is_a_real_number.gif https://upload.wikimedia.org/wikipedia/commons/0/07/Complex_Kneser%27s_Tetration_when_abs%28base%29%3D10%5E6.gif https://upload.wikimedia.org/wikipedia/commons/6/62/Complex_Kneser%27s_Tetration_when_abs%28base%29%3De.gif Woahhhh, those are really cool!