<?xml version="1.0" encoding="utf-8" standalone="yes"?><?xml-stylesheet href="/style.xsl" type="text/xsl"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Cédric's website</title>
    <link>https://www.cedricbonhomme.org/tags/claude/</link>
    <description>It's all about open source, digital freedom, and art.</description>
    <generator>Hugo</generator>
    <language>en-US</language>
    <lastBuildDate>Mon, 27 Jul 2026 07:00:00 +0000</lastBuildDate>
    <atom:link href="https://www.cedricbonhomme.org/tags/claude/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Challenging Claude&#39;s creativity with IFS fractals and OCaml</title>
      <link>https://www.cedricbonhomme.org/2026/07/27/challenging-claude-with-ifs-fractals/</link>
      <pubDate>Mon, 27 Jul 2026 07:00:00 +0000</pubDate>
      <guid>https://www.cedricbonhomme.org/2026/07/27/challenging-claude-with-ifs-fractals/</guid>
      <description>&lt;p&gt;Sixteen years ago, during a functional programming course, I wrote a small&#xA;OCaml program that draws fractals with&#xA;&lt;a href=&#34;https://github.com/cedricbonhomme/iterated-function-systems&#34;&gt;iterated function systems&lt;/a&gt;&#xA;(IFS). It is one of my oldest repositories still alive, and it has barely&#xA;changed since 2010. I have a long standing affection for both OCaml and&#xA;fractals: I even published a&#xA;&lt;a href=&#34;https://scholar.google.fr/scholar?oi=bibs&amp;amp;cluster=90579809364779260&amp;amp;hl=en&#34;&gt;small work about fractals&lt;/a&gt;&#xA;back in 2008. So when I recently got my hands on Claude Fable 5, Anthropic&amp;rsquo;s&#xA;new model, I thought this dusty little project would make a perfect&#xA;playground. Not to fix bugs or refactor code, but to challenge its&#xA;creativity: could it invent &lt;em&gt;new&lt;/em&gt; IFS fractals?&lt;/p&gt;&#xA;&lt;h2 id=&#34;a-quick-refresher&#34;&gt;A quick refresher&lt;/h2&gt;&#xA;&lt;p&gt;An IFS describes an image as the union of shrunken copies of itself. You give&#xA;a handful of affine transforms (each one a mix of scaling, rotation and&#xA;translation) together with a weight, and the image, the attractor, follows.&#xA;The program draws it with the chaos game: start anywhere, repeatedly pick a&#xA;transform at random and plot the point. A few hundred thousand iterations&#xA;later, the Barnsley fern appears out of twenty-four coefficients.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;https://www.cedricbonhomme.org/images/blog/2026/07/ifs_barnsley.png&#34; alt=&#34;Barnsley Fern&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;The repository originally contained eleven classic fractals: the fern, the&#xA;Sierpiński triangle, a dragon curve, the Koch curve, and so on.&lt;/p&gt;&#xA;&lt;h2 id=&#34;first-challenge-create-something-of-your-own&#34;&gt;First challenge: create something of your own&lt;/h2&gt;&#xA;&lt;p&gt;I told Claude that the Barnsley fern was my favorite and asked whether it&#xA;could define a new fractal, either a known one or one of its own invention.&lt;/p&gt;&#xA;&lt;p&gt;What I found interesting is &lt;em&gt;how&lt;/em&gt; it worked. It cannot open the graphics&#xA;window from its terminal session, so it rewrote the chaos game in a few lines&#xA;of Python, rendered the candidates to PNG images, looked at them, and&#xA;iterated on the coefficients before writing a single line of OCaml. It also&#xA;used the simulation to compute the bounding box of each attractor, so the&#xA;viewport in the OCaml record frames the image correctly on the first try.&lt;/p&gt;&#xA;&lt;p&gt;It came back with two proposals. The first was a known one, the classic maple&#xA;leaf. The second was its own: it composed rotation and scaling matrices by&#xA;hand (a 0.92 contraction with a 20° rotation for the main curl, a smaller&#xA;offset copy for the offshoots) and produced a spiral of spirals that it named&#xA;&lt;code&gt;fiddlehead&lt;/code&gt;, the coiled tip of a young fern frond, as a nod to my favorite&#xA;fractal:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;https://www.cedricbonhomme.org/images/blog/2026/07/ifs_fiddlehead.png&#34; alt=&#34;Fiddlehead&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;I asked whether it was really its creation, because the result looked&#xA;familiar to me. The answer was honest and, I think, exactly right: the&#xA;coefficients are its own, but the recipe (one dominant contracting rotation&#xA;plus small offset copies) is a well known way to build spiral attractors. In&#xA;fact the &lt;code&gt;galaxy&lt;/code&gt; fractal that has been sitting in my own file since 2010&#xA;uses the same architecture. Convergent evolution rather than a copy.&lt;/p&gt;&#xA;&lt;h2 id=&#34;second-challenge-the-vegvísir&#34;&gt;Second challenge: the vegvísir&lt;/h2&gt;&#xA;&lt;p&gt;Then I raised the difficulty. Could it draw something like the vegvísir, the&#xA;Icelandic &amp;ldquo;wayfinder&amp;rdquo; stave that Björk has as a tattoo? I love Björk, so the&#xA;choice was not entirely innocent.&lt;/p&gt;&#xA;&lt;p&gt;Claude&amp;rsquo;s first answer was that, strictly speaking, this is impossible. An IFS&#xA;attractor is a single self-similar set, while the real vegvísir has a&#xA;&lt;em&gt;different&lt;/em&gt; rune at the end of each of its eight arms. That asymmetry is&#xA;simply out of reach. I appreciated getting the mathematical limitation before&#xA;the workaround.&lt;/p&gt;&#xA;&lt;p&gt;The workaround is clever, though. The first transform is a pure 45° rotation&#xA;with scale 1.0. It is not a contraction and draws nothing by itself: it only&#xA;teleports points between the eight arms, so whatever the other transforms&#xA;create gets replicated all around the circle. The remaining transforms draw a&#xA;single arm: a thin shaft, two crossbars (each crossbar being a squashed,&#xA;rotated copy of the entire symbol, which decorates it with rune-like detail&#xA;for free), a miniature of the whole symbol at the tip, and a small copy to&#xA;fill the center.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;https://www.cedricbonhomme.org/images/blog/2026/07/ifs_vegvisir.png&#34; alt=&#34;Vegvísir&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;The result is not a vegvísir. It is more of an eight-armed rune compass whose&#xA;every arm ends in an infinitely recursive copy of the whole. But I like it a&#xA;lot, and the family resemblance is there.&lt;/p&gt;&#xA;&lt;h2 id=&#34;third-challenge-something-really-new-from-nature&#34;&gt;Third challenge: something really new, from nature&lt;/h2&gt;&#xA;&lt;p&gt;The vegvísir experiment made me think. It is funny that, most of the time,&#xA;things from nature (flowers, ferns, leaves) make the best IFS candidates. So&#xA;for the last challenge I simply asked for an idea: something really new,&#xA;maybe from nature.&lt;/p&gt;&#xA;&lt;p&gt;Claude proposed two candidates, prototyped both, and kept both.&lt;/p&gt;&#xA;&lt;p&gt;The first, &lt;code&gt;sunflower&lt;/code&gt;, is phyllotaxis distilled to &lt;em&gt;two&lt;/em&gt; transforms. One&#xA;rotates by the golden angle, 137.508°, the angle real plants use to place&#xA;successive seeds and florets, while contracting slightly toward the center.&#xA;Because the golden angle is the &amp;ldquo;most irrational&amp;rdquo; angle, consecutive buds&#xA;never line up into spokes; they fill the disk evenly, exactly as in a real&#xA;sunflower head or a romanesco. The other transform plants a bud at the rim,&#xA;and since every bud is a copy of the whole attractor, each one is a rosette&#xA;made of rosettes:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;https://www.cedricbonhomme.org/images/blog/2026/07/ifs_sunflower.png&#34; alt=&#34;Sunflower&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;The second, &lt;code&gt;lace&lt;/code&gt;, is Queen Anne&amp;rsquo;s lace (wild carrot), whose flower is an&#xA;umbel: a dome of stalks radiating from one point, each stalk ending in a&#xA;smaller umbel, each of those in smaller umbels still. An umbrella made of&#xA;umbrellas. Five transforms place shrunken, slightly rotated copies of the&#xA;entire plant along the rim of a dome, and a sixth squashes the whole image&#xA;into the thin stem:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;https://www.cedricbonhomme.org/images/blog/2026/07/ifs_lace.png&#34; alt=&#34;Queen Anne&amp;rsquo;s lace&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;This one is my favorite of the batch. It looks like something picked on the&#xA;side of a road, yet it is entirely described by thirty-six numbers.&lt;/p&gt;&#xA;&lt;h2 id=&#34;why-nature-wins&#34;&gt;Why nature wins&lt;/h2&gt;&#xA;&lt;p&gt;Claude&amp;rsquo;s explanation of why plants work so well deserves to be repeated. A&#xA;plant does not follow a blueprint of its final shape; it grows by repeating&#xA;simple local rules: sprout, shrink, turn, repeat. Its final form is the&#xA;accumulation of the same rule applied at every scale, which is exactly what&#xA;an IFS attractor is. The fern is not &lt;em&gt;like&lt;/em&gt; a fractal, it is the fixed point&#xA;of a handful of affine maps, and so, in a very real sense, are the plants&#xA;themselves. That is why the most convincing images in the collection take so&#xA;few numbers to describe, and why Barnsley needed only four transforms to&#xA;capture a fern.&lt;/p&gt;&#xA;&lt;p&gt;Designed symbols, on the other hand, resist. The vegvísir struggled precisely&#xA;because it was drawn by human hands to &lt;em&gt;mean&lt;/em&gt; something, not grown by a rule.&#xA;Nature is self-similar because growth is iteration. Culture, mostly, is not.&lt;/p&gt;&#xA;&lt;h2 id=&#34;closing-thoughts&#34;&gt;Closing thoughts&lt;/h2&gt;&#xA;&lt;p&gt;My sixteen-year-old toy project went from eleven fractals to sixteen over&#xA;breakfast and a good coffee, and the README now explains the chaos game far&#xA;better than I ever bothered to. What struck me the most was not the speed but&#xA;the method: simulate first, look at the result, be honest about what is&#xA;original and what is not, and know when a challenge is mathematically&#xA;impossible before bending it into something achievable.&lt;/p&gt;&#xA;&lt;p&gt;Everything is on GitHub:&#xA;&lt;a href=&#34;https://github.com/cedricbonhomme/iterated-function-systems&#34;&gt;https://github.com/cedricbonhomme/iterated-function-systems&lt;/a&gt;.&#xA;If you have OCaml installed, &lt;code&gt;draw lace 300000;;&lt;/code&gt; is a nice way to spend&#xA;a couple of seconds.&lt;/p&gt;&#xA;</description>
    </item>
  </channel>
</rss>
