Posts: 624
Threads: 102
Joined: Dec 2010
I've emailed 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 PariGP? Particularly; I mean, how do you create hue plots using PariGP? Is there something stupid I'm missing here?
I've got my Parigp 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
Posts: 795
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 tetforum member Mike. It takes a matrix of complex values and writes a *.ppm file (some basic graphicfileformat) with rgbvalues. 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 upperleft corner to x1 + y1i in lowerright 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  (1F)*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, height1, for(x=0, width1, 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
Posts: 624
Threads: 102
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 multiplier over and :
EDIT: This is about 8 digit precision; it may dip to 4 occasionally, but it hovers around 12; so let's just say 8.
Posts: 72
Threads: 7
Joined: May 2019
09/24/2021, 06:27 PM
(This post was last modified: 09/29/2021, 04:12 PM by Ember Edison.)
(05/12/2021, 04:31 AM)JmsNxn Wrote: I've emailed 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 PariGP? Particularly; I mean, how do you create hue plots using PariGP? Is there something stupid I'm missing here?
I've got my Parigp 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 PariGP and then imported the value into Mathematica to export the image.
As I mentioned before, I wouldn't have switched to PariGP 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/c...e_to_1.gif
https://upload.wikimedia.org/wikipedia/c...number.gif
https://upload.wikimedia.org/wikipedia/c...10%5E6.gif
https://upload.wikimedia.org/wikipedia/c...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)].
Posts: 624
Threads: 102
Joined: Dec 2010
(09/24/2021, 06:27 PM)Ember Edison Wrote: (05/12/2021, 04:31 AM)JmsNxn Wrote: I've emailed 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 PariGP? Particularly; I mean, how do you create hue plots using PariGP? Is there something stupid I'm missing here?
I've got my Parigp 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 PariGP and then imported the value into Mathematica to export the image.
As I mentioned before, I wouldn't have switched to PariGP 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/c...e_to_1.gif
https://upload.wikimedia.org/wikipedia/c...number.gif
https://upload.wikimedia.org/wikipedia/c...10%5E6.gif
https://upload.wikimedia.org/wikipedia/c...29%3De.gif
Woahhhh, those are really cool!
