I'm going to write a modified version of MakeGraph by mike3
#7
Just for shits and giggles. Here is: \(f(z) = \sin(z)\). Where \(-1 \le \Re(z) \le 1\) and \(-1 \le \Im(z) \le 1\). And let's make a 500 by 500 pixel graph. But let's only choose 125 x 125 reference points; which is a "blur factor" of 0.25.

We have to run:

E = for X; for Y; write(X,Y);

For all X,Y in 500 by 500; which creates our default starter speed.

P = for X/0.25; for Y/0.25; F(X,Y)

Where, X only ends up doing 125 loops, same with Y. Because 500*0.25 = 125.

So we write 500x500 times; but we only calculate F 125x125 times.

Then the total time is just:

E + P

Which with large graphs, and large values, reduces times tenfold!!!!! Assuming we don't lose accuracy, or quality of the graph, is a purist's question. Everything looks good enough!

   


This does E = WRITE(500 BY 500) time, plus the addition of O(F(125,125))

And god its fast as fuck, and there's zero difference Big Grin

The code is simple as:

P =
For X=0, 125:
     For Y=0, 125:
           F(X,Y)

E =
For X = 0, 500:
      For Y=0, 500:
           WRITE(X,Y)

Total time to compile is:

E + P

Mike3's time would be written:

MIKE =
For X=0,500:
    For Y=0, 500:
          P = F(X,Y);
          WRITE(P);

Which causes 500 BY 500 evaluations of F(X,Y). Rather than my modest 125 BY 125. And the graphs are indistinguishable.... What I call "blur factor" isn't a jpeg blur. The splining, and graphing, is indistinguishable. So if you take a nice function like F(X,Y) = sin(X + iY), everything behaves perfectly. And even choosing a blur factor of 0.25 still keeps everything beautiful!
Reply


Messages In This Thread
RE: I'm going to write a modified version of MakeGraph by mike3 - by JmsNxn - 02/23/2023, 04:30 PM



Users browsing this thread: 2 Guest(s)