Dynamic systems, bifurcations, procedural worlds

I’m using pgfplots a lot, so I will share some examples today.

Here, I benefit from these features of pgfplots, going beyond base TikZ:

  • Simple plotting with 3d coordinates and axonometric projection
  • Presentation of required coordinate axes
  • Using color gradients
  • Reading in files with externally calculated data

In any case we can use Lua for calculating data. Lua generates the TeX commands for printing, which will be processed in a pgfplots axis environment.

Here are the samples, just click on it to get to the corresponding thread on TeXwelt with full source code.

Lorenz attractor (dynamic system)

While I posted a Python calculated version on TeXwelt.de, Henri added one, which bases on LuaTeX. Let’s see his picture at first:

Lorenz attractor

Of pgfplots I used the transparency feature besides the standard 3d plot, so I got an impression of the density:

Lorenz attractor

Once we calculated the data, the code is simple:

      xmin = -25, xmax = 25,
      ymin = -25, ymax = 25,
      zmin =   0, zmax = 50,
      hide axis,
    \addplot3[mark=none, mesh, shader=interp, color=black, opacity=0.2]
      file { lorenz.dat }; 

Fractal landscapes – the base for producing procedural worlds

Between adjacent points, new points will be calculated, with random but limited variation. Finally we will get a mountainous landscaoe. The calculated points get color according to their height: blue for sea level and below, green for mountains and white above the snowline.

Fractal landscape

Next step: specify nice starting values, for beginning with a certain base structure, such as an island in the water.

Feigenbaum diagram (bifurkations)

This is a classic of the chaos theory und closely related to the Mandelbrot set. Also here, we use transparency for an impression of the point density.

Feigenbaum diagram

I often started such topics on TeXwelt.de. LaTeX support for thesis writers is not the only talking point there. It became established, that TeX connoisseurs post their ideas in shape of a question, often themselves posting the first answer, opening a discussion. The final goal is a knowledge database, built on top of questions and answers.

08. July 2014 by stefan
Categories: Graphics, Mathematics, pgf/TikZ | Leave a comment

Iterated fractals

I recently dealt with  Iterated function systems , in short IFS. Here we got repeated transformations: the space will be mapped onto itself. There can be different map specifications. We do this an infinite number of times :-) and take a look at the set in space, which stays invariant. This can be a fractal object.

Enough of theory, there are great books on it, and Wikipedia provides a nice starting point. How do we generate such a fractal image? The simplest approach is the so called chaos game: wie nehmen einen Punkt her, and apply one of the transformations, randomly chosen. Because we got point sets, which are invariant under those transformations, the mapped point will be in the set again. We take the new point and repeat it, thousands of times, until a clear shape appears.

Let’s do this with the famous Barnsley fern!

But how? We need loops and the possibility of calculating affine transformations. It can be done with pgfmath, but I think it’s hardly readable. So I rather take Lua, integrating a programming language in the classical sense into the macro expansion language TeX. It’s easily written in Lua. I put the transformation parameters and probabilities into a matrix, so it can easily be changed for experiments. Let’s start the chaos game!

For compiling, we need LuaTeX and patience. For testing and playing with parameters and probabilities, it’s recommendable to choose a low number of iterations.

  function barnsley(iterations,options)
    local x = math.random()
    local y = math.random()
    local m = {
        0.0,   0.0,   0.0, 0.16, 0.0,  0.0, 0.01,
       0.85,  0.04, -0.04, 0.85, 0.0,  1.6, 0.85,
        0.2, -0.26,  0.23, 0.22, 0.0,  1.6, 0.07,
      -0.15,  0.28,  0.26, 0.24, 0.0, 0.44, 0.07
    local pm = { m[7], m[7] + m[14], m[7] + m[14] + m[21] }
    if options ~= [[]] then
      tex.sprint("\\draw[" .. options .. "] ")
      tex.sprint("\\addplot coordinates{")
    for i=1, iterations do
      p = math.random()
      if     p < pm[1] then
        case = 0
      elseif p < pm[2] then
        case = 1
      elseif p < pm[3] then
        case = 2
        case = 3
      newx = (m[7*case+1] * x) + (m[7*case+2] * y) + m[7*case+5]
         y = (m[7*case+3] * x) + (m[7*case+4] * y) + m[7*case+6]
         x = newx
      tex.sprint("("..x..","..y..") circle (0.05pt)")
  \directlua{barnsley(100000, [[color=green!50!black,fill]])}
Barnsley fern

On TeXwelt.de I produced variations, printed using pgfplots.

Farn variation Farn variation

Also the famous Sierpinski triangle can be generated using the chaos game instead of the L-System approach, the similar source code is on TeXwelt.de, like linked above:

Sierpinski triangle

Now in three dimensions? :-) No joke – in analogy to the triangle there’s the squarish Sierpinski carpet, wich becomes the so called Menger sponge in three dimensions.

07. July 2014 by stefan
Categories: Graphics, Mathematics, pgf/TikZ | Leave a comment

TeX Live 2014 released – what’s new

TeX Live 2014 has been released and is now available for download. Let’s have a look at the changes.


TeX and MetaFont have been updated. This previously happened 2008, and this year Donald Knuth provided another update. Now we got TeX version 3.14159265, included in TeX Live 2014. Well, the slight changes are essentially invisible: regarding TeX, the only change concerns the “null control sequence”\csname\endcsname, there was a missing space. if somebody wants to try, with this code by Oleg Bulatov, 2008:


you will get a message on the terminal

wunderbar \csname\endcsnamebar

where one would expect just wunderbar bar. Well, that’s fixed now in the print_cs routine! Very nice to see, that the last known TeX bug is so “serious”.

Also MetaFont has been updated to version 2.7182818, which means just a fix of one bug, also discovered in 2008. A classic – a memory leak.

The remaining things are maintainance work. You can read more details about this in Donald Knuth’s article “The TeX tuneup of 2014“.


“Fake spaces” have been introduced. The original TeX does not insert space characters between words. Instead, words and punctuation characters are positioned for optimal full justification without an explicit space character inbetween. This is very good for printing, however today we often read documents on electronic devices such as laptops, tablet computers and smart phones. They use different screen widths, even on the same device it can change when you rotate the device. Text should reflow on-the-fly. For this it’s better to have a space character as a word delimiter.

Continue Reading →

18. June 2014 by stefan
Categories: LaTeX Distributions, TeX Live | Leave a comment

LaTeX2e got an update

Today an update of LaTeX2e has been released on CTAN. The previous update dates back to June 27, 2011. LaTeX2e has been stable for a long time, there are mainly maintenance work and bug fixes.

  • The package fixltx2e got an update: loading the package fixes bugs and improves bad design decisions of previous versions of LaTeX. Such corrections were put into an extra package for backwards compatibility. From this version on, placement arguments for floats will be checked and in case of errors, such as a wrong v in \begin{figure}[tv], an error message will be raised. Furthermore the behavior in case of mixing one- and twocolumn floats has been improved, to fix that it was possible that placement got out of sync.
  • There’s a new package with the name fltrace: the original internal LaTeX code for placing floats has been extracted and information output has been added, which can be switched off and on, to analyze and to understand how LaTeX works when placing the floats. \usepackage{fltrace}\tracefloats activates it.
  • The inputenc package has been improved: there were problems with the Unicode based engines XeTeX and LuaTeX, now it’s compatible with option utf8or ascii, it runs and just issues a warning. Other options, i.e. really incompatible input encodings, cause the compiler to stop with an error message.
  • .ins files, used to extract code files from source files, are now provided for single files instead of complete subfolders, making updates easier.
  • The multicol package got corrections and an extension: code can be run dependent on in which column we currently are.
  • tabularx relaxes restrictions for using \tabularx and \endtabularx in the definition of new environments.
  • showkeys got bug fixes for using at the beginning of list items and with grouping by curly braces within the optional argument of \cite.
  • The color package now provides the command \nopagecolor.
  • In graphicx the command \rotatebox now accepts arguments containing paragraph breaks done by \par or an empty line.
  • Also keyval now can deal with \par and empty lines in values.

Continue Reading →

04. May 2014 by stefan
Categories: LaTeX General, News | Leave a comment

Who want’s to have a TeX or LaTeX book of choice?

After a contest on LaTeX-Community.org ended without contributions, because probably most of us have the prize, the LaTeX Companion, already in the shelf, there’s a new idea. It’s for our very active German speaking TeX community.

Which book would you like to have?

Choose any TeX or LaTeX book and tell us on TeXwelt.de, and you are in the game. The winner will be, who posts the best questions.

Just the sum of votes decides. That’s simply and all readers choice. No Jury. No complaints. No cheating. We would see that.

In the new year the question votes will be counted and the winner will get the book of his or her choice.

Why for questions? Because posting good questions is really hard. Try and you will understand.

05. December 2013 by stefan
Categories: Events, LaTeX General, News | Leave a comment

LaTeX Reference in German available for free

At Lehmanns there’s now a LaTeX reference available for free, written by Herbert Voß, in German language:


You can order it for free as a soft cover book, or download it as PDF file.

On 32 pages the reference lists the most important LaTeX environments and commands with syntax and meaning, and it contains a list of LaTeX counters and lengths.

DANTE members will automatically get it together with the next DTK.

Originally posted on LaTeX-Community.org News.

06. November 2013 by stefan
Categories: LaTeX General, News | Leave a comment

Article contest – win the LaTeX Companion – 10 days left

On LaTeX-Community.org there’s currently a contest: users, who post an article on the web site have the chance to win the LaTeX Companion ebook. A free download code was provided by the author Frank Mittelbach. The ebook version is available as bundle in EPUB, MOBI and PDF format.

The LaTeX Companion

To take part, write a small article and send to stefan@latex-community.org, it will be published on LaTeX-Community.org. The topic of this contest is: Recent developments in LaTeX.

“Recent” may mean some years, it’s not really strict. You can freely choose your topic. The article could be short like a blog post or comprehensive as you like.

The contest will end in 10 days, it will close on November 10, 2013.

You can find all details in the contest announcement.

31. October 2013 by stefan
Categories: Events, LaTeX General | Leave a comment

Packt Publishing promotion: 50% discount for all ebooks

Today is the final day of the Packt Publishing promotion, where you can get 50% discount for all ebooks in the store. They got a lot of books in the store, could be a nice opportunity to shop an interesting book for less money, for you or as a present for your friends. The promo code is: BIG50

They have one LaTeX book available, which was written by me: LaTeX Beginner’s Guide.

30. September 2013 by stefan
Categories: LaTeX General, News | Leave a comment

A new community TeX blog

Again some quiet weeks on my blog. If some people would blog together, there would be active blog life even if somebody would temporarily be too busy with other things. So I liked Patricks idea very much, to set up a community blog together with some TeX friends and who ever likes to join us. I quickly set up a wordpress blog and we chose a friendly bright theme together.

It’s site for people who did not blog yet but would like to do it sometimes, or TeX users like me who blog in English but like to post in German sometimes. Yes, the starting crew is German, from the huge German speaking TeX community, Patrick, Rico, Clemens, Marco, Dominic, and me. First topics? Clever footnotes, maths, xparse, translations, minted, and planned are biblatex and pgfplots.

Curious? Have a look: TeXwelt.de

30. May 2013 by stefan
Categories: News, Online Ressources | Leave a comment

TeX news and articles

It has been a bit quiet here for some weeks. I got a son in February, when my little daugher was not much more than 1 year old, both keep us pretty busy at home. So after my full time job I’m not so often at the computer.

However, I still post about TeX news, answer questions in TeX forums, edit and publish articles. My personal site is just not so important. I rather support LaTeX-Community.org, which is read by more people.

Here are some news of the last months I posted there, in case you missed one:

Contributed articles, which I edited regarding HTML design and published on that site:

More articles are in the works and will appear soon.

LaTeX Community Forum

Do you like reading that TeX and LaTeX site with articles, news, and an active TeX forum? If yes, there are some ways you could support it, for example by

  • Answering some LaTeX questions in the forum. Many questions come in, it seems more than the regulars can handle. There are even a lot of unanswered questions. You could pick one or some and answer. Also answers to older questions are welcome.
  • Adding a link to LaTeX-Community.org on your website or blog. Feel free to use the banner here, but a text link would already be great. So some more users may find the site.
  • Sending us news, if you would notice something in the TeX and LaTeX world. You could also get an account to write posts on the frontpage of the site. Even an article about a topic you like? Very welcome!

01. April 2013 by stefan
Categories: Online Ressources | 1 comment

← Older posts

Newer posts →