#๐Ÿ”’ How to make a julia set - beginer

145 messages ยท Page 1 of 1 (latest)

supple lance
sonic orbitBOT
#

@supple lance

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

hidden robin
# supple lance

I've never done Julia Sets, but I have done Mandelbrot Sets many times, and they're a similar algorithm afaik.

supple lance
#

idk what afaik means?

hidden robin
#

"as far as I know"

supple lance
#

i was doing mandelbrot sets but it was too hard

#

i thoguht an easier equations would be easier

hidden robin
#

I don't think they're too different. I think Julia sets are just a generalization of Mandelbort Sets.

cedar mountain
# supple lance

it seems as if you meant realNum * (realNum-1) instead of realNum * realNum-1

hidden robin
#

I'll see if I can find some code that shows the algorithm I've used previously.

supple lance
#

so ik mines wrong

#

idk what im doing

hidden robin
#

Also, Python has a complex number type btw. You don't need to do the complex number math yourself.

supple lance
#

im confused

#

isnt complex numbers just a number times swrtof -1

hidden robin
#

!e

print(1+2j, type(1+2j))
sonic orbitBOT
supple lance
#

what maths is needed

hidden robin
supple lance
#

really? i thought c is the comlex number

#

u only ever add it?

hidden robin
#

Ah, I was thinking of the limit test. You can square the complex result when checking if the point is going off to infinity.

supple lance
#

is c constant in mandelbrot

#

?

formal thunder
# supple lance really? i thought c is the comlex number

C is how complex number set is usually marked, so small c is sometimes used as "some complex number"
Just like natural number set is N and n is used to mean "some natural number"
We're talking about actual values, not variable names, here.

hidden robin
#

c is the point being tested iirc, so ya, for each point, c remains the same.

formal thunder
supple lance
hidden robin
#

I don't know why it's set up like that, but those are the rules.

supple lance
#

yea i

#

ik

#

is something like this correct

#

as the mandelbrot set

#

or nah\

#

it cant be that easy

hidden robin
sonic orbitBOT
#

src/logic/mandelbrot_iteration.rs line 20

pub fn test_point(initial: ComplexPoint, max_iterations: u32, infinity_limit: u32) -> u32 {```
hidden robin
# supple lance i dont really udnerstand

Nvm, I'm realizing now that I haven't actually looked at the formal Mandelbrot definition in forever and have just been re-translating my old algorithm every time I redo the project. My algorithm actually seems different than the formal definition. I have no idea where I got it from at this point.

#

I originally wrote that core algorithm like 10 years ago from some source.

supple lance
#

ok

#

can anyone explain howe to get this to work

#

like what ive done wrong

delicate zodiac
# supple lance

you would have to check for the modulus for the number "z" after each iteration, and if it is over 2 then "c" is not part of the set.
If after the maxIterations the modulus of z does not go over 2, we consider c to be part of the set

#

Doing this over different values for "c" will get you the mandlebrot set

supple lance
#

so the mandelbrot set hasincreased resolution with more valeus of c?

delicate zodiac
#

yes, essentially

#

each c gives you 1 pixel

supple lance
#

and what is a good jump between each value of c

#

like should i add 0.01to c each time or smth

delicate zodiac
#

yes that seems good

supple lance
#

allrighhty

#

and then how much iterations for each

delicate zodiac
#

since python is not very quick, something between 25-50 should be good

#

also you do have to vary the complex component of c as well

supple lance
#

btw wdym by the modulus of z

#

like u need 2 numbers

delicate zodiac
supple lance
#

yes but u said modulus of z

#

thats not possible

#

like z modulus what

delicate zodiac
#

so modulus here means "distance of complex number from (0, 0) on the complex graph",

supple lance
#

ohh k

delicate zodiac
#

and not "remainder" (ik its kinda confusing)

supple lance
#

wouldnt that just be equal to c

#

cuzi didnt really include acomplex number

delicate zodiac
#

yeah here it would be the value of the number it self,
but for a general complex number its value would be (a^2 + b^2)^.5 where the number is z=a+bi

formal thunder
formal thunder
#

!e print(abs(3+4j))

sonic orbitBOT
delicate zodiac
supple lance
#

how is3+4j 5

delicate zodiac
#

as (3^2 + 4^2)^(0.5) = 25^0.5 = 5

formal thunder
supple lance
#

is something like this correct

#

@formal thunder

formal thunder
#

No. You'd want to iterate each point maxIter times. Not maxIter iterations and going only up with the points

And each point is 2d - each point has real and imaginary part. While your c is just c+0j

supple lance
#

yea if i add the j its breaks

formal thunder
#

It's not "add the j", j character is part of the literal value

formal thunder
#

Do you know what literal is in programming? It's value that is read, well, literally. String literal is quotes+stuff between the quotes. Int literal is just a number.

Complex literal has either just imaginary part, so it has to be some number and j. Or real+imaginary part.
Like 4+3j above is a literal with real part. Or you'd want to use 1j to convert something to imaginary part (e.g. a*1j).

supple lance
#

i added the j

#

i really dont understand how i change it to make it work

#

each time the results do like 1iteration before passing abs2

formal thunder
formal thunder
supple lance
#

yea

supple lance
#

changing that wont change anything

formal thunder
#

It's about what each variable means (where it's used), not how many times the loop iterates over

supple lance
#

yea

#

so whats wrong with the variables

formal thunder
#

I wrote it in that message. You'd want to change c in the outer loop, while the inner loop only calculates all z values for the given c

#

As you yourself said before the code - c is constant for the given z calculation

supple lance
#

then the second loops is repeating the same equation 50 times

#

should i removeit

formal thunder
#

Why do you think it's the same?

supple lance
#

this code is repeated maxiter times

#

ohh

formal thunder
#

Does this code also "repeats the same equation 50 times" or not?

x = 2
for i in range(10):
  x = x*x
supple lance
#

shoot uea

#

nvm

#

im stupid

#

watching a stream, doign hw and this at same time

formal thunder
supple lance
#

idk

#

doing this to learn

#

i feel like i know most of the basics

formal thunder
#

Define "most of the basics"

supple lance
#

like arrays

#

functions

#

that kindastuff

formal thunder
sonic orbitBOT
#

This module defines an object type which can compactly represent an array of basic values: characters, integers, floating-point numbers. Arrays are sequence types and behave very much like lists, except that the type of objects stored in them is constrained. The type is specified at object creation time by using a type code, which is a single character. The following type codes are defined:

supple lance
#

like lis

#

list

formal thunder
#

List is not an array

supple lance
#

ok

#

very similiar

#

and i basically meant array

#

like numpy.array([])

#

^^^

formal thunder
# supple lance that kindastuff

Set? Dict? Classes?
For this here you'd also need to at least understand complex number basics, you didn't even understand how abs works on them nor what j is.

supple lance
#

ik what it is

#

someone said modulus

#

then said thats what abs is

#

when i think it is %

#

anyway thanks for ur help

#

im pretty busy this week but maybe next wekend ill try do some more of this stuff

#

cya

formal thunder
# supple lance someone said modulus

Because that IS the alternative name for absolute value. And with complex numbers when modulus is used often, saying "modulus of z" is shorter "absolute value of z"

supple lance
#

ok

sonic orbitBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.