News for hackers. Stuff that matters.
Re:The quest to decode the Mandelbrot set by infogulch on Saturday January 27, 2024 @05:52AM (#39154483)
Making a program to render a view of the Mandelbrot set is a fun exercise, I recommend it.

I found a viewer that works in the browser:

> Mandelbrot Viewer is a universal (desktop and mobile) vanilla JS implementation of a plain Mandelbrot set renderer – supporting mouse, touch and keyboard interaction.

https://mandelbrot.silversky.dev/

Re:The quest to decode the Mandelbrot set by QuadmasterXLII on Saturday January 27, 2024 @07:28AM (#39154978)
If you want to keep zooming in the browser and have snappy gpu accelerated performance while basically never hitting “reached limit of numerical precision,” check out https://mandeljs.hgreer.com . The math to make this possible gets pretty funky: I go over the tricks I used at https://www.hgreer.com/JavascriptMandelbrot/
Re:The quest to decode the Mandelbrot set by sapiogram on Saturday January 27, 2024 @01:42PM (#39158457)
No scrolling with the scroll wheel though :(
Re:The quest to decode the Mandelbrot set by QuadmasterXLII on Saturday January 27, 2024 @01:52PM (#39158559)
The whole thing is a tower of spaghetti bit hacks in the name of depth and speed. Embarassingly, it actually can't actually render zoom levels that aren't powers of two and I'm not sure how to change that.
Re:The quest to decode the Mandelbrot set by LoganDark on Saturday January 27, 2024 @07:17PM (#39161220)
Can you make it so that the position you clicked stays at the same position after each zoom, rather than centering it on your cursor? That way you can click multiple times to zoom in on the same point.
Re:The quest to decode the Mandelbrot set by tda on Sunday January 28, 2024 @02:00AM (#39163188)
Thanks for creating this, I had some fun exploring the set. What does the scale parameter stand for?
Re:The quest to decode the Mandelbrot set by QuadmasterXLII on Sunday January 28, 2024 @05:53AM (#39164409)
The color of each pixel is

    fragColor = vec4(vec3(cos(c), cos(1.1214 * c) , cos(.8 * c)) / 2. + .5, 1.);
Where c is the number of iterations divided by the scale.
Re:The quest to decode the Mandelbrot set by tweetle_beetle on Sunday January 28, 2024 @03:08PM (#39169332)
That really is very fast!

(I don't know if this is a known compromise of your technique (I couldn't find it mentioned), but I occassionally get a ring of varying thickness centred in the render with an inverted coluring to the rest of the pixels, or sometimes a solid colour. It varies is size and comes and goes without an obvious correlation to zoom level.)

Re:The quest to decode the Mandelbrot set by QuadmasterXLII on Sunday January 28, 2024 @05:08PM (#39170300)
Yeah, I've been chasing that for a while. I've traced it to subnormal float handling. Here's the scenario: if you multiply the 32 bit float float 1 x 2^-127 by 1/8, you can't get 1x2^-130 because 130 isn't representable in a 8 bit exponent. On the CPU or a modern GPU, this is special cased to result in a "subnormal" float: .125 x 2^-127. However, this adds a ton of extra complexitity to the FPU. Old GPUs just gave up and say "It's zero." WebGL standardized on the old GPU behavior, so a modern GPU running webgl sets a flag to behave like the old GPUs.

I'm representing complex numbers as (real_mantissa + i * imag_mantissa) * 2^exp where real_mantissa and imag_mantissa are themselves 32 bit floats, and I can reduce the frequency of the colored rings in my shader by keeping the mantissas around ~1000 instead of ~1 (and reducing the exponent to keep the value the same) so that they are less likely to go subnormal, but I can't seem to get rid of the colored rings entirely.

I don't actually know the pathway through the code from subnormal underflow -> colored rings, but if you run a CUDA renderer with the same algorithm, the rings appear when you set the flag for "round subnormal floats to zero."

Re:The quest to decode the Mandelbrot set by rini17 on Monday January 29, 2024 @07:29AM (#39175485)
Wow nice! Though I seem to get artifacts both in Brave and Firefox on Android: https://imgur.com/a/vo2ZVOQ

https://mandeljs.hgreer.com/?;re=-0.751165720536567020384363...

Re:The quest to decode the Mandelbrot set by brazzy on Saturday January 27, 2024 @06:07AM (#39154554)
Here's my attempt done a long time ago, not very polished:

https://brazzy.de/en/Mandelbrot.php

Even for that, the actual Mandelbrot calculations were the smaller part. It's really amazing how such a trivially simple formula spawns such endless complexity.

Re:The quest to decode the Mandelbrot set by rnentjes on Saturday January 27, 2024 @07:24AM (#39154962)
I'll add my julia attempt that animates and works with webgl:

http://julia.perses.games/

Re:The quest to decode the Mandelbrot set by swayvil on Saturday January 27, 2024 @09:01AM (#39155581)
Complexity is trivial. That's the lesson here. It's human perception that's special. It's special in that it has an uncommonly low bar on what's considered impressively complex.

Which implies something important, no doubt.

Re:The quest to decode the Mandelbrot set by crazygringo on Saturday January 27, 2024 @10:55AM (#39156556)
I made quite a sophisticated viewer as a teen, but boy was it slow to run back then, back on a 486.

Now people write viewers that run lighting fast in a browser thanks to WebGPU! Like:

https://www.reddit.com/r/fractals/comments/o7l4bm/please_try...

Re:The quest to decode the Mandelbrot set by IronBacon on Saturday January 27, 2024 @12:15PM (#39157449)
I remember as a teen I did mine in 68000 assembly on a Commodore Amiga to get it reasonable fast considering it was running on a 16 MHz CPU — i would say a few seconds to draw the canonical image — but IIRC it reached pretty fast the limit of math precision.

At that time I didn't know what was a complex number, but was fascinated by the whole concept of fractals and how complex structures could be created with a relative simple program.

Re:The quest to decode the Mandelbrot set by Baeocystin on Saturday January 27, 2024 @03:27PM (#39159498)
A few seconds? Wow! I did a science fair project on the Mandelbrot set using my Amiga 2000, and it took me a good 45+ minutes to generate a single 320x200 color image. IIRC, I wrote the generator in some variant of Pascal, and was so happy with the performance increase over Basic on my C=128...

I ran in to the precision limit pretty quickly, same as you. I didn't understand computers well enough to know that's what the problem was, and I remember spending hours pouring over my code, trying to figure out where the bug was. Good times. :D

Re:The quest to decode the Mandelbrot set by vardump on Sunday January 28, 2024 @05:46AM (#39164366)
The difference is probably you used floats and he/she used fixed point (integers). Of course that way you do run out of precision very quickly.

Software emulated floats on Amiga 2000 were really, really slow.

Re:The quest to decode the Mandelbrot set by IronBacon on Sunday January 28, 2024 @03:06PM (#39169317)
If I'm not confusing it with something else, I seem to recall that when zooming on the set the calculation was nearly instantaneous. As you said, good times! ^__^

I still have that A500 but who knows where I put those floppies, I'm tempted to turn it on but I'm scared the PSU will blow itself...

Re:The quest to decode the Mandelbrot set by snvzz on Sunday January 28, 2024 @08:04PM (#39171672)
A500 PSUs (particularly the 2nd one) are the most reliable and powerful.

The A500 themselves are built like tanks. Chances are it just works.

But watch out for trapdoor expansion. Most likely has a varta barrel battery in it, which will eventually leak and damage the expansion, and possibly also the computer itself.

I would recommend opening that trapdoor and removing/inspecting anything installed there as soon as possible.

These barrel batteries are only used to keep RTC, and the board will be fine w/o.

Re:The quest to decode the Mandelbrot set by BeetleB on Saturday January 27, 2024 @12:26PM (#39157568)
I did it in QuickBasic (also on a 486).

Now that's slow.

Re:The quest to decode the Mandelbrot set by chihuahua on Saturday January 27, 2024 @06:40PM (#39161000)
I typed in a BASIC program for a C-64 from a computer magazine. That was a popular mechanism for software distribution back then.

I thought "this will never work", but I was amazed that it did in fact work. I remember letting it run overnight to find a complete 160x200 4-color image the next morning. Just clearing the screen using a loop to fill 8192 bytes with 0s took over a minute.

Everything about the computers at the time was so terrible, I don't feel any nostalgia for those days or that technology.

Re:The quest to decode the Mandelbrot set by dekhn on Sunday January 28, 2024 @02:58PM (#39169241)
The one I wrote in BASIC on my Apple IIe never finished, it hadn't even got the interesting bits of the set after a day or so and I needed to play games.

FRACTINT was great because I could use my 286 and it was fairly fast because used integer whenever possible.

Re:The quest to decode the Mandelbrot set by matt-attack on Monday January 29, 2024 @04:41PM (#39183098)
I did it in High School on my crappy TI programmable calculator. Took for ever to calculate but it worked.