Skip to content

Instantly share code, notes, and snippets.

@tempdeltavalue
Last active October 12, 2022 21:58
Show Gist options
  • Select an option

  • Save tempdeltavalue/4f40fe5f61677b049019beb4c0e32302 to your computer and use it in GitHub Desktop.

Select an option

Save tempdeltavalue/4f40fe5f61677b049019beb4c0e32302 to your computer and use it in GitHub Desktop.
dummy_mandelbrot.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"collapsed_sections": [],
"authorship_tag": "ABX9TyNcL0b8XbRWkDmGvt9PSAQo",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/tempdeltavalue/4f40fe5f61677b049019beb4c0e32302/dummy_mandelbrot.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Ddl_t8Ic_o6g"
},
"outputs": [],
"source": [
"import numpy as np \n",
"import matplotlib.pyplot as plt\n",
"\n",
"side = 1024\n",
"rand_matrix = np.zeros((side, side, 3)) #np.random.rand((side, side, 3) #\n",
"\n",
"\n",
"max_iters = 100\n",
"\n",
"for x in range(side):\n",
" for y in range(side):\n",
" n_x = x / side\n",
" n_y = y / side\n",
"\n",
" iter = 0 \n",
" zx = 0\n",
" zy = 0\n",
"\n",
" while (iter < max_iters):\n",
" nzx = zx**2 - zy**2 + n_x\n",
" nzy = 2 * zx * zy + n_y;\n",
" zx = nzx;\n",
" zy = nzy;\n",
"\n",
" if (zx**2 + zy**2 > 4.0):\n",
" break;\n",
" \n",
" iter += 1\n",
"\n",
" if iter == max_iters:\n",
" rand_matrix[x, y] = [0,0,0];\n",
" else:\n",
" rand_matrix[x, y] = [iter, zx, zy] \n",
" # print(rand_matrix[x, y])\n"
]
},
{
"cell_type": "code",
"source": [
"plt.figure(figsize = (48,48))\n",
"\n",
"plt.imshow(rand_matrix)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000
},
"id": "RjmS3V9q_-5D",
"outputId": "784b8233-39b6-4a05-bfa1-88cf4422a093"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"WARNING:matplotlib.image:Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).\n"
]
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7f032bf31790>"
]
},
"metadata": {},
"execution_count": 52
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"<Figure size 3456x3456 with 1 Axes>"
],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment