{
  "nbformat": 4,
  "nbformat_minor": 5,
  "metadata": {
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3",
      "language": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": "# AGILAB free-threading lab\n\nOriginal AGILAB benchmark notebook, September 19, 2026. BSD-3-Clause (see accompanying LICENSE). Compute Mandelbrot escape counts in pure Python, split the image into independent row tiles, and compare identical results across AGILAB execution modes. This is a CPU benchmark, not a claim that Python loops are the fastest way to render fractals. Reference: https://docs.python.org/3.14/howto/free-threading-python.html\n"
    },
    {
      "cell_type": "code",
      "metadata": {},
      "execution_count": null,
      "outputs": [],
      "source": "def reference_image(width=96, height=64, iterations=100):\n    pixels = []\n    for y in range(height):\n        cy = -1.2 + 2.4 * y / (height - 1)\n        for x in range(width):\n            cx = -2.0 + 3.0 * x / (width - 1)\n            z = 0j\n            c = complex(cx, cy)\n            count = 0\n            while count < iterations and z.real*z.real + z.imag*z.imag <= 4.0:\n                z = z*z + c\n                count += 1\n            pixels.append(count)\n    return pixels\n"
    },
    {
      "cell_type": "code",
      "metadata": {},
      "execution_count": null,
      "outputs": [],
      "source": "pixels = reference_image()\nassert len(pixels) == 96 * 64\nassert min(pixels) >= 0 and max(pixels) <= 100\n"
    }
  ]
}
