Generation

generate functionSun, 13 Nov 2022

Mandelbrot set

function mandelbrot($real, $imaginary) { $constant = new \stdClass(); $constant->real = $real; $constant->imaginary = $imaginary; $z = new \stdClass(); $z->real = 0; $z->imaginary = 0; for ($i = 0; $i < 4; $i++) { $z->real = $z->real * $z->real - $z->imaginary * $z->imaginary + $constant->real; $z->imaginary = 2 * $z->real * $z->imaginary + $constant->imaginary; } return ($z->real * $z->real + $z->imaginary * $z->imaginary) < 4; } for ($row = -100; $row < 100; $row++) { for ($column = -100; $column < 100; $column++) { echo mandelbrot($column / 100, $row / 100) ? '1'

Questions about programming?Chat with your personal AI assistant