Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

## Post a reply

Write your message and submit
|
Options

## Topic review (newest first)

Agnishom
Yesterday 14:21:56

anonimnystefy
2012-12-23 02:34:47

I am going with (i) first.

The other two will have to wait a bit...

bob bundy
2012-12-23 02:21:08

That's a great fractal.  Well done!

So you could (i) improve the resolution or (ii) add colour or (iii) do a new fractal.

Bob

btw  Is now a good moment to admit I cannot program in Lisp ?  I was bluffing!

anonimnystefy
2012-12-23 01:16:29

Bob, you are brilliant!

The picture is given below.

bob bundy
2012-12-23 01:07:55

Sorry.  Was just about to re-edit that load of rubbish.

(mb-set (+ (- (* x x) (* y y)) (/ (- j (round (/ size 2.0))) 50.0)) (+ (* 2 x y) (/ (- j (round (/ size 2.0))) 50.0)) (1+ nit))
)))

I see no i in that line.

Bob

anonimnystefy
2012-12-23 01:05:55

Hi Bob

The variable x is never reassigned once in the function...

bob bundy
2012-12-23 00:31:27

Ok.  A common mistake which you can easily fix:

There are no comments / remarks / annotation to go with this code.

Bob

LATER EDIT

When you recompute x and y you need to store the new x temporarily whilst computing the new y, else you use the wrong x.

Recommend you don't call mb-set again until you have reset values in some extra lines of code, rather than packing all into a single line.

anonimnystefy
2012-12-22 23:37:22

Hi Bob

I edited my code a little bit:

#### Code:

```(defun mandelbrot (size filename)
(let ((img (make-8-bit-gray-image size size)))
(declare (type 8-bit-gray-image img))
(loop for i from 1 to (1- size) do
(loop for j from 1 to (1- size) do ;these two loops go through all pixels of the image
(labels ((mb-set (x y nit) ;nit is the number of the iteration
(if (or (> (+ (* x x) (* y y)) 2) (> nit 1000)) ;this bit of code checks if the modulo of z is >2
(setf (pixel img i j) (round(/ 255.0 (1+ nit)))) ;if it is, this bit sets the current pixel to the appropriate shade of grey
(mb-set (+ (- (* x x) (* y y)) (/ (- j (round (/ size 2.0))) 50.0)) (+ (* 2 x y) (/ (- j (round (/ size 2.0))) 50.0)) (1+ nit)) ;if not, this bit sends new information into the next iteration
)
))
(mb-set 0.0 0.0 0)
)
)
)
(write-jpeg-file filename img)
)
)```

but it produces the picture below...

bob bundy
2012-12-22 23:31:20

So what does it produce?

Have you worked up to this with simple stuff like draw a line, plot a pixel, shade an area etc.

Bob

anonimnystefy
2012-12-22 10:23:52

Hi Bob

I have wrotten this code: http://pastebin.com/Je8PQMfX which should produce some kind of grayyscale Mandelbrot set, but it doesn't...

anonimnystefy
2012-12-21 20:02:41

Hi Bob

That is the page I found! I will try what I can today...

bob bundy
2012-12-21 14:52:57
anonimnystefy
2012-12-21 11:33:33

Hi Bob

I have a package called "vecto". I am searching for instructions on using it...

anonimnystefy
2012-12-21 06:20:17

I use SBCL for CLisp.

bob bundy
2012-12-20 23:28:22

What version of lisp?  What did you try?  (Just one at this stage)

Bob