News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_ComSoft6128

MANDEL.BAS

Started by ComSoft6128, 06:42, 26 July 19

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ComSoft6128

This short video (program from the WACCI PD library) shows the creation of a Mandelbrot image - look at the top of the image to see the program nearing completion. The program is LISTed at the end of the vid.
This was a royal pain in the backside - in the time this program took to execute (nearly 4 f**king hours :o ) I could have made ten other videos - aargh!

So, not being a programmer I have two questions:

1. Why did this take sooooo long to complete?
2. Why does it switch from Mode 2 to Mode 0?

Cheers,

Peter


TotO

4 hours and the floppy was write protected!  :laugh: :laugh: :laugh:
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

ComSoft6128

#2

Hi TotO

These are 25/30 year old disks and I generally read from them only, also I was hoping to see a colour cycling demo as I have with another mandelbrot program that I possess - that one might be displayed in another later video.

Cheers,

Peter

pelrun

Quote from: ComSoft6128 on 06:42, 26 July 19
1. Why did this take sooooo long to complete?



That's a maths question - the mandelbrot set image is really computationally intensive to generate. It uses a simple formula, but for each point it iterates it many many times and counts how long it takes before the value goes off to infinity (if it's ever larger than 2 this is guaranteed, so that's what it checks for.) Points actually in the set (the green ones in the centre) *never* go off to infinity (the calculation bounces around chaotically forever), so the program has to give up after some number (40 here) for each of those.


https://en.wikipedia.org/wiki/Mandelbrot_set

roudoudou

it take so long because it iterates too much regarding the final resolution
i'v done a Julia in 2 lines of basic which is way faster... (and algo optimised but it's similar to mandelbrot computations)
https://www.youtube.com/watch?v=IkmMaeN9xOo&feature=youtu.be&t=48m37s


My pronouns are RASM and ACE

ComSoft6128

Thank you for the replies,

So the speed of execution would be increased by a more efficient/optimised (machine code?) program and a faster processor.

Got that.

Cheers,

Peter 

roudoudou


It does not need to iterate to 40, just get out at 15 (>14) and put the color without a modulo (expensive division)
Also put a maximum of inner loop instructions in the same lineYou may expect a significant boost in all casesBut as you see, the values of the mandelbrot interval are drawing a symmetrical drawing -> do not compute the mirrored pixels, juste copy them
useless SQR and comparison to 2 -> do only a comparison to 4
...
My pronouns are RASM and ACE

roudoudou


This code compute the full mandelbrot 4 times faster (so x8 faster adding symmetrical drawing) -> 30min :)

There is many mistakes in your code, like computing 200x each values of real and imaginary part for the pixels
My code is doing 400 calculations once for all whereas your code is doing 80.000 calculations producing again and again the same values

10 INPUT"real part ",rpart20 INPUT"imaginary part ",ipart
30 INPUT"size: ",side
40 MODE 0
50 g=side/200
60 DIM rt(200),it(200)
70 FOR x=0 TO 199:xg=x*g:rt(x)=xg+rpart:it(x)=xg+ipart:NEXT:REM tabz
100 FOR y%=0 TO 199:i=it(y%):FOR x%=0 TO 199:rz=0:iz=0:c%=0:r=rt(x%)
110 z=rz*rz-iz*iz+r:iz=2*rz*iz+i:rz=z:IF rz*rz+iz*iz<4 AND c%<14 THEN c%=c%+1:GOTO 110 ELSE PLOT x%+x%,y%+y%,c%
120 NEXT:NEXT:CALL &BB18

My pronouns are RASM and ACE

ComSoft6128

Hi Guys,

With your permission I would like to include a link to this thread with the YouTube video, so that anyone that is interested can read your posts.
Would this be OK with you?
No need to reply - just "like" this post and I will take that as a yes.

Cheers,

Peter

pelrun


Quote from: roudoudou on 14:46, 26 July 19It does not need to iterate to 40, just get out at 15 (>14) and put the color without a modulo (expensive division)


Which is mostly fine for the "full" mandelbrot set at this resolution, but rapidly breaks down when you try to zoom in at the edge of the set, which is where all the interesting fractal patterns are. And doing modulo of a power of two (since we've got 16 inks) is incredibly cheap, just replace it with "AND 15".


Although if you really want to go zooming into the mandelbrot set, it's much nicer to just throw modern computer power at it... http://math.hws.edu/eck/js/mandelbrot/MB.html


AMSDOS

Quote from: ComSoft6128 on 14:29, 26 July 19
Thank you for the replies,

So the speed of execution would be increased by a more efficient/optimised (machine code?) program and a faster processor.

Got that.

Cheers,

Peter


I translated a couple of those BASIC Mandelbrot's from this thread for Hisoft Pascal and got good results from it, there's also a Video by hirudov2d of it as well.


* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Powered by SMFPacks Menu Editor Mod