# Off Topic > Tips and Tutorials >  >  Strange Attractor Gallery: An Exploration into circular references

## Gregor y

Hi all, so I've been playing around with the whole circular references thing to see what I can convince Excel into "charting" for me. The following fractal images are mostly generated from iterated functional systems(IFS), to which excel's circular reference iteration feature lends itself beautifully.

Notes:In order to run the spreadsheets you will need to go to File>Options>Formulas, and check the box next to Enable iterative calculation each time you restart excel.I've saved all the sheets with calculations turned off you can either use the F9 key each time you want to calculate the sheet or go to File>Options>Formulas>Workbook Calculation and set it back to Automatic.I deleted most of the chart's data table in order to reduce the file size. When you first open the book use the key combo Ctrl+D to fill down the formulas in the chart's data range.Some of the data ranges are big 2,000,000 points, and excel tends to have problems for me with lots of data. So if I were you I wouldn't have any other workbooks open at the same time, just in case excel crashes and you had something you hadn't saved yetTo get a more classical layout of an IFS and to avoid the circular refs altogether you can do the x',y' formulas by just linking one row x',y' to the previous row's x',y' instead of the column-wise x -> x' and y ->y' as I've done(more to come on a later post).The probabilities of the IFS really arent super important they really only just control how fast the IFS converges to the image. Where it is nice to have optimal convergence, you will likely eventually get there given enough points.The majority of IFS I'm using on these posts are linear transforms which can be written in matrix form as:


```
Please Login or Register  to view this content.
```



Ok with that all said, I suppose the best place to start is the classical example of Barnsley's fern. The image for this one took me a while to work out as I knew I had to have the probabilities close to right, but was still getting a horrible stick figure even after a couple million data points. Long story short it was due to my original function selecting formula in column E. I'd first started of using the MATCH function as it was finally a case where I thought I'd found a use for it without adding the 0 (you know the MATCH(....,0)). Well I was wrong again, this form of the formula was over selecting the "stem" function and viola stick figures. So going back to the drawing board I finally settled on the COUNTIF rendition as seen in the file, and well the results came through.

----------


## Richard Buttrey

Neat!  :Cool: 

I look forward to seeing any other fractal patterns you might have - the classic Mandelbrot perhaps?

----------


## Gregor y

With the Fern under my belt I decided to move on to Sierpinsky.

Granted It's been a while for me since the last time I've worked with IFSs and matrix algebra in general, and I figured I could just wing it. Wrong, my inital guess for the system had all the elements of the matricies at 0.5 and I couldn't for the life of me figure out why I was just getting three strings of dots on my chart. Well google to the rescue and yeah it was a simple mistake: b and c should both be 0 not 0.5. Which in retrospect was another one of those well duh moments for me.
Given the Identity matrix:


```
Please Login or Register  to view this content.
```


You want to captrue both the x and y coordinate, and for the Sierpensky the % reduction is the same in both x and y so 50% on the identity:


```
Please Login or Register  to view this content.
```



Sierpinsky triangle:


Sierpinsky Carpet:

----------


## Gregor y

> Neat! 
> 
> I look forward to seeing any other fractal patterns you might have - the classic Mandelbrot perhaps?



huh, I hadn't considerd Mandelbrot and the like, but I suppose you could make it fit in the whole IFS strange attractor theme.

It's going to be hard to get excel to chart it though, and I'm not sure I'll be able to do the colors without VBA. Also I'm not sure that excel really does complex math, but that should be easy enough to emulate in formulas across column data.

Sounds like fun though, I'll see what I can do.

----------


## Gregor y

Speaking of google there are quite a few IFS fractal parameters to be had out there, but I figured I should find one for a tree I rember doing in my chaos class. The closest I could find was one by Paul Bourke who has a great site where he actually lists the parameters so you can try them out for yourself. (excel file not attached due to I don't want to worry about copy right issues on the parameters table. I'm not a lawyer, data tables can sometimes be copyrighted, and I don't want to find out the hard way.)


Moving off the beaten path but still trying to keep it simple, I figured it'd be time to try my hand at some of the 5 point crystals. Basically you can generate these along the same lines as the Sierpinski gaskets: shrink, move, twist, and reflect. As long as you don't move the points too far apart they should end up looking crystalish, if not tweek it a bit and try again.



```
Please Login or Register  to view this content.
```



Generic 5-pointed Crystal:

----------


## Gregor y

Ok, time to come clean. What really got me started off on this tangent was my off topic post in another thread(4245211). However I'm kinda glad I did because it gave me a chance to improve the IFS selector formula in column E, that in turn gave better convergence:


Let's break this project down, and maybe build on what I've mentioned so far:
Design Tab:
I'm sure most can guess where I got the inspiration for using Gregory as my artistic subject matter(now all i need is to turn the data into a DXF file and get somone to lasercut me some awesome business cards).

Once your target design is established you can get a feel for what you can and cannot do. In this case words are great because a word can be thought of in a strictly artistic sense as a line, or stroke if you prefer. And since the characters/glyphs within the word are composed of lines, then the word itself can be used to construct the word. And since that more or less fits the loose definition of a fractal, it makes a good canidate for our whole IFS scheeme. What also helped us along was that my design while it looks complex is really just a group of vertical and horizontal lines, e.g. I don't have to mess around with all those sines and cosines.

Next with Excel's help I got the basic block layout and coordinate system by just merging worksheet cells togeather. Note I put the coordinates near the column/row headers so when I select the merged cells for the line I'm working on, the colum/row headers are highlighted and it makes it easier to read off the adjacent block coordinates.

Formulate Tab:
Somewhere between design and formulation you should know the basic idea of where these "lines" are comming from. The broad goal when designing your matricies is that you are taking the unit square and shrinking it into the line you want to use. So since my design is 29 units long each block length is 1/29 and to get the total block length of a stroke I'm looking at the number of blocks the stroke is long say L times the block length or L * 1/29 or just L/29. The devil that turns out was in the detail for this one was the height or line thickness of the stroke couldn't just be 1/29 too because my design is only 12 units tall, and if I'd gone with a line thickness of 1/29 then I'd really only be using 12/29 of the 1/29 which gives a real thickness of 12/29^2, which was too thin. Well as it turns out crunching through the algebra to streatch the partial full 12/29^2 x 1/29 to fill the 1/29 x 1/29 unit block ends up not beeing so bad after all since the line thickness comes out to be just 1/12 i.e. just one of my design block's height, remember my design is 12 units tall.

armed with this info the next step was to position all the bottom left corners for each line. You need one equation for each stroke, my designe has 27 strokes. I started each with the identity equation 1 0 0 1 0 0, which is basicly the do nothing equation. Then from there I updated the last two being the move X and Y for each stroke so that the bottom left coordinate was in the correct block coordinate e.g. 1 0 0 1 x/29 y/29. Then I went back through and updated the stroke lengths(if you have a lot of strokes, you can do them at the  same time as the previous two, but I tend to get my x/y's crossed so seprate steps works better for me). e.g. len/29 0 0 1 x/29 y/29. Next I went through and updated all the line thicknesses e.g. len/29 0 0 1/12 x/29 y/29. Last I did the rotation swaps:



```
Please Login or Register  to view this content.
```


and there you have it a quick and dirty jump start on building your own IFS words. (yes the second r uses reflections, but you can check the spreadsheet for how I did that by changing the signs).

One more Design note: when you're doing your formulas try to be as true to inside the unit square length as possible, if you're too short all your design lines will come up short of connecting, if you're too long then all the lines will bleed out into the rest of the design. In other words don't have a bunch of blank blocks at the end of your design you'll come up disconnected, don't go outside the last block you'll overlap stuff.

----------


## Pepe Le Mokko

Just wanted to add how the Sierpinski triangle is created.

1. Draw a triangle ( any shape will do)
2. Place a point anywhere in the plane ( in or out of the triangle is OK) P1
3. From that point draw an imaginary line to a random vertex of the triangle
4. Place a point P2 at half the distance between P1 and the chosen vertex
5. Starting from P2 reiterate the process described in 2 3 and 4 again for a large number of times ( usually 10000 is nice)
6. Result is the Sierpinski Triangle

Are there other ways?

----------


## Gregor y

I'm actually glad you asked that question as it takes me back to the foot note in the OP where I eluded to (more on this later).

however before I go down that route allow me to fix the algebra mistake I made in the crystal 5 post. I actually had the matrix multiplication in the wrong order, so the combined matrix formula should instead be



```
Please Login or Register  to view this content.
```


(see attached sheet: crystal 5 repaired)

ok with that out of the way I suppose it's time to pull the old battle axe out of the closet as I have some grinding yet to do.

It's been a while since I've delved into a fractal text book, so if they've caught the following detail in more recent texts, then you can go ahead and just ignore my rant for what it is.

The typical presentation of what these IFSs are doing starts out with a description of starting with any picture(a box, a triangle, a moose, whatever) and shrinking that picture by some amount then translating it to a new position. Then tacking the resulting picture as a whole and doing it again and again and again until you get enough resolution on the fractal image that you can call it a day. Then they go from that general description to the steps you've laid out above. And if you're really lucky they'll mention that the only reason you go from one point to one point instead of from one to all three half way points is because it takes way less time to track one point instead of the three way branching, and then they'll introduce what the probabilities are doing and how by not always following the same route they make the image converge faster when you go from one point to the next.

While this approach is technically not wrong it does IMO gloss over an important point namely that the process is not a micro process, but rather a macro one. Because in each iteration of these steps you are not making a small move, you are actually making a big move each time, but into a more restricted area. And when you focus on the micro details you're kind of looking at the whole process in an inside out sort of way.

And so by taking a random sampling of the unit square as I've done on these worksheets, then iterating the IFS over each point so that each converges individually instead of following a single point along it's random trajectory it makes it a little easier to chain the IFSs together like this:

----------


## Gregor y

> huh, I hadn't considerd Mandelbrot and the like, but I suppose you could make it fit in the whole IFS strange attractor theme.
> 
> It's going to be hard to get excel to chart it though, and I'm not sure I'll be able to do the colors without VBA. Also I'm not sure that excel really does complex math, but that should be easy enough to emulate in formulas across column data.
> 
> Sounds like fun though, I'll see what I can do.



I'm getting closer:

----------


## Gregor y

so to get this one to work you need to fill down columns A and B first then copy/paste them by values, then fill down the other columns:


I'll leave the settings on the chart up to the user. You should be able to kindof zoom in on areas by changing the min/max, but you're going to ultimately be bound by Excel's precision.

----------


## Gregor y

I suppose I ought to do Newton's method at this point too.


Note: to get this graph I really had to convince Excel it had enough memory. Excel kept crashing on me when I did 5,000,000 points, so I ended up haveing to compute it in pieces and copy/paste values as I went.

----------


## Gregor y

How about some Koch curves next

Snowflake:


Dragon:


Snow Dragon?


Dragon Snow?

----------


## Gregor y

xlsx files from previous Koch post

----------


## MrShorty

This is really a nice use of iterative calculations. I'm glad my other spreadsheet could serve as a very small inspiration for this.

My only problem -- Excel 2007 still has a 32000 point limit for 2D plots, so I have cannot use as many data points in my installation.

But the spreadsheet is fairly compact, relatively simple, and calculates fairly quickly (over 50 iterations).

----------


## Gregor y

what an obtuse limitation, i'll see what i can do.

also note that most of these to just ballpark it, shouldn't need more than 5 to 15 itterations to converge.

----------


## MrShorty

> what an obtuse limitation, i'll see what i can do.
> 
> also note that most of these to just ballpark it, shouldn't need more than 5 to 15 itterations to converge.



Don't bother yourself on my account. Several thousand points and your pictures here are enough to see what is happening.

----------


## Gregor y

Sorry I've gotten kind of bussy lately with the end of the year comming up, but I did come up with a solution. It's kinda spread out between multiple versions of spreadsheets as more of a "proof of concept" so I'll need to find the time to pull it together under one sheet.

The gist of it goes along these lines; run the formulas in excel copy/past values as needed, copy the output column data and paste to text editor(I use Context so i'm not sure if notepad can handle the size), save as svg file extension, open in FireFox (not IE, IE works for small files but 100k points gave it an hour to think through the render, and it just couldn't handle the 1m point file.)

Image from FireFox v41.0 (eventually, it took a while to render but at least FF shows the dots going in as the file is loaded, FF ended up with 2.5GB of ram to do this pic)

----------


## jaydee49

Hi, I'm fascinated by your work on excel and upon looking at your spreadsheet for the Barnsley fern I'm still a little bit confused about the formulas you have used to generate your data that excel uses to plot the graph of the ifs. Any chance of a quick explanation of the formulas of each column?
Many thanks

----------


## Gregor y

I was finally able to stack enough minutes togeather to compile the SVG version of the Newton's method sheet.

Same basic fill down process as before, fill down columns A and B, copy paste by values, fill down the other colummns (may need to do a few at a time and copy/paste values as you go), (also note in this spcific case for newton's some points converge very slowly, so you may need to hold of on paste values for columns E through N until the largest value in N is really small) once complete copy the purple stuff in column O and paste into a text editor that can handle that much text and save as a text file, not RTF and definatly not DOC, just raw TXT. Then rename the extension to .svg instead of .txt, which can be hard to do on some Windows boxes because windows by default doesn't show file extensions for known types(you may need to google how to do this). After that right click the svg file, and do open with then choose Firefox (you may need to do "choose defalut program", "Other programs" and search for the firefox executable) -- or i guess it may be easier to just open FireFox and navigate your way to the file, your choice...

----------


## Gregor y

> Hi, I'm fascinated by your work on excel and upon looking at your spreadsheet for the Barnsley fern I'm still a little bit confused about the formulas you have used to generate your data that excel uses to plot the graph of the ifs. Any chance of a quick explanation of the formulas of each column?
> Many thanks



Sure however first you'll need to switch your Excel into Iterative calculation mode for the formulas to work.






```
Please Login or Register  to view this content.
```

----------


## fractals

Looks great! It has an 'artsy' feeling to it with dots that look like paintbrush strokes...  :Smilie: 

Here's the 'classic' Mandelbrot (without attractors):



detailed tutorial: http://slicker.me/fractals/excel.htm

----------


## Gregor y

I was goofing around with the =*MOD*() cell formula today and I stumbled upon this one. I know it doesn't quite fit the theme of strange attractors nor circular references, but both the math and asthetics were so beautiful I just had to add it to the gallery.

Incase you're one of those people who don't like downloading macro books from the internet(and I don't blame you) here is the gist of how to build the spreadsheet yourself.

First the macro to define an equivelent for the following cell formula with a larger range of exponents in cell *B1*:


```
Please Login or Register  to view this content.
```





```
Please Login or Register  to view this content.
```


Next the layout of the spreadsheet:Row 1 is the pallet rowA1.background = rgb(0,60,0)B1.background = rgb(0,176,240)I only started with two colors in my pallet, but I'm going to add more and fiddle with it some to see what else I can find... however I did notice quite a bit of slow down when I added the second colorCell A2 is the modulus valueRowRange(B2:BT2) are the table column headers with the value sequence 1, 2, 3, 4, ..., 71ColumnRange(A3:A146) are the table row headers with the value sequence 1, 2, ..., 144TableRange(B3:BT146) are the table's values given by the formulas '=PowerMod($A3,B$2,$A$2)'Select the whole sheet and set the column widths to 2.29 (roughly the same width as height)Select TableRange(B3:BT146) and add a conditional formatting to match each cell in the palletwhen cell value = $A$1, format background = rgb(0,60,0)when cell value = $B$1, format background = rgb(0,176,240)Basic usage:Set the value of the pallet cell to color the corresponding table valuesSet the pallet cell to -1 to turn off that colorSet the modulus cell $A$2 to select the pixel patternI've adopted the notation Modulus:Color1,Color2,... to index the patterns, so 5:1,-1would be:$A$2.value = 5A1.value = 1B1.value = -1if you had more colors the rest of the pallet's values would be -1 to turn them offi suppose a short hand for 5:1,-1 could also be 5:1 where any color not specified would be implied to be off or -1 (note: 0 is not off)
A short gallery:

Bridge Filler: 5:1,-1 (or 5:1 for short)
Bridge Filler Over Water: 5:1,0
Snow: 13:-1,1
Eye: 13:12
Some others I didn't have enough attachment space forSpace Invader: 11:119:125:125:24Tree 27:129:129:2834:3337:139:12,1

----------


## IonutC

Gregory,

How can i use the excel files you post in order to get those nice pictures. Cos i see only dots and don;t know hot to run them in excel to get those pictures.

----------

