0

How can Newton's basin of attraction be created from a data file?

I got 10000 points in the range -2, 2 and their zeros for complex function z^3-1. I'd like to plot them with three different colors to create basin of convergence.

Data I've obtained from my program is available here. The format is like this:

(-0.422468,1.36075) (-0.5,0.866025)
(1.19376,1.1324) (1,-6.76273e-19)
...

First two numbers in "( )" are complex start points, the second two are the zero that it converges to. Zeros are exact to the level of e-10, I can easily change it to e-16.

Schorsch
  • 7,761
  • 6
  • 39
  • 65
xxxxx
  • 159
  • 9

1 Answers1

3

From what I understand, I would try something like:

plot 'yourdata.dat' using 1:2:(arg($3+$4*{0,1})) '(%lf,%lf) (%lf,%lf)' palette

The string '(%lf,%lf) (%lf,%lf)' is the format of your data, so that gnuplot can read it as a file of four columns. Then, you can select the columns to be plotted with using 1:2:(arg(...)); in this case, the x-axis is the real part of the starting points (column 1), and the y-axis is its imaginary part (column 2). The third part of using, arg($3+$4*{0,1}), and the option palette are used to chose the color depending on the phase of the complex zero (columns $3 and $4).

vagoberto
  • 2,372
  • 20
  • 30
  • I have never seen that trick for stating the data file format in the plot command like that, and I thought that I knew gnuplot pretty well. Is that documented in the gnuplot documention somewhere? That is remarkable that it can be done that way. – Matthew Jan 16 '16 at 00:52
  • You are the boss vagoberto, it's so much appreciated, working like a charm! – xxxxx Jan 17 '16 at 21:12