flat assembler
Message board for the users of flat assembler.

Index > Heap > Some mathematical shenanigans :D(complex numbers & fract

Author
Thread Post new topic Reply to topic
fredlllll



Joined: 17 Apr 2013
Posts: 56
fredlllll
I hope that any mathematicians here wont beat me up for this Wink

As some may have noticed i like complex numbers and fractals. and i also like games and fancy pictures. so in my second semester i had to work on a presentation about mandelbrot and this stuff. while doing this i was wondering how to do the mandelbrot in 3d. okay there was the mandelbulp, but for me this was some strange implementation with all that sin cos stuff. and it doest really look like the mandelbrot. so i tinkered with complex numbers in my mind and first tried this:

lets say sqrt(-i) = j. just like sqrt(-1) = i . so i had my "new" complex number which looked like 1+1i+1j. as i continued tinkering i came to the conclusion that this was wrong. so i made up this in my mind:

a complex number consists of a real part and imaginary. each of them have a multiplicator and the "identity" of the dimension: a+b*i where a and b are some numbers and a just has multiplicator 1. so a is a real number. while the second part has a 1 dimensional factor "b" which is also a real number. so the factor of j should be a 2 dimensional one. so i figured out this:

1+1i+(1+1i)j

now j has a complex number as factor. i called this thing "complex number of 2nd grade"

now i used mathematica to figure out the multiplication of such numbers, because i failed two times doing it myself.
so i got this:
c1*c2 = c1.r * c2.r - c1.i * c2.i + c1.j.i * c2.j.r + c1.j.r * c2.j.i +// real part
(c1.i * c2.r + c1.r * c2.i - c1.j.r * c2.j.r + c1.j.i * c2.j.i)*i+//imaginary part
((c1.j.r * c2.r - c1.j.i * c2.i + c1.r * c2.j.r - c1.i * c2.j.i)+(c1.j.i * c2.r + c1.j.r * c2.i + c1.i * c2.j.r + c1.r * c2.j.i)*i)*j // j part

c*.r is the real part, c*.i is the imaginary part and c*.j is the "j"-part containing a normal complex number with r and i.
i didnt figure out the division because i didnt need that for mandelbrot or julia.

So now i have some strange numbers where every mathematician will tell me "sqrt(-i) is already known. what are you doing dumbhead??"
its shenanigans Razz as i said.

but after that i realized, i dont have my 3 dimension i wanted. i have 4 now. so i cant really work with it cant i? of course i can. for 2d graphics i just use a fixed j part for the C, and for 3d i use a line and take the points of this line for each slice of the 3d render.
by now i only have the 2d implementation and guess what. i have a screenshot for you. this was made using the j part 0,3+0,15i. its the 2d representation of a 4d object, so you cant really see some great stuff
i hope ill have the time someday to make a 3d implementation of this Very Happy

and now: let the flamewar begin on how mathematical incorrect this is Wink


Description:
Filesize: 59.89 KB
Viewed: 4254 Time(s)

cnum2.png



_________________
--for science


Last edited by fredlllll on 08 May 2013, 21:05; edited 1 time in total
Post 08 May 2013, 20:46
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6034
Location: Poland
MHajduk
fredlllll

Have you seen this thread: Multithreaded Quaternion Julia Sets renderer?

Fractals in 3D are created by use of quaternion numbers.
Post 08 May 2013, 21:04
View user's profile Send private message Visit poster's website Reply with quote
fredlllll



Joined: 17 Apr 2013
Posts: 56
fredlllll
looks interesting. but i think calculation with quaternions is different isnt it?
Post 08 May 2013, 21:09
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6034
Location: Poland
MHajduk
fredlllll wrote:
looks interesting. but i think calculation with quaternions is different isnt it?
Yes, because in quaternions you have three "imaginary" parts with three imaginary units i, j, k bounded together with specific laws of multiplication while in your example you have only two such imaginary parts. I don't think your proposition is good because there were many attempts to create a field that will strictly correspond to the structure of 3D space and only changing the dimension to 4D allowed to create somehow consistent algebraic structure analogous to R (real numbers in 1D) and C (complex numbers describing transformations of R^2 into itself).
Post 08 May 2013, 21:17
View user's profile Send private message Visit poster's website Reply with quote
fredlllll



Joined: 17 Apr 2013
Posts: 56
fredlllll
i already stated that i have 4 dimensions now and only can show a slice of the 4d object. but even if its "just" a slice it would be a better mandel representation than the mandelbulp (my point of view)
and as the title says, thats all shenanigans. hopefully the 3d will give me "sharper" objects than the quaternion julia thing. it really looks pretty smooth. just too smooth for a fractal.

btw is it mathematical proven that there is no sqrt(-1)?
Post 08 May 2013, 21:37
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6034
Location: Poland
MHajduk
fredlllll wrote:
btw is it mathematical proven that there is no sqrt(-1)?
Who has said that? Not me, for sure. Wink

It's quite opposite, in maths we build a new class of numbers (i.e. complex numbers) assuming that sqrt(-1) does exist in fact.
Post 08 May 2013, 21:44
View user's profile Send private message Visit poster's website Reply with quote
fredlllll



Joined: 17 Apr 2013
Posts: 56
fredlllll
i mean if sqrt(-1) exists in R1. i mean sqrt(-i) exists in C. so if we say we just didnt find the sqrt(-i) and call it j, my mathematics stuff would be correct XD
Post 08 May 2013, 21:45
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6034
Location: Poland
MHajduk
fredlllll wrote:
i mean if sqrt(-1) exists in R1. i mean sqrt(-i) exists in C. so if we say we just didnt find the sqrt(-i) and call it j, my mathematics stuff would be correct XD
No, sqrt(-1) isn't an element of R, it's an element of C.
Post 08 May 2013, 21:52
View user's profile Send private message Visit poster's website Reply with quote
fredlllll



Joined: 17 Apr 2013
Posts: 56
fredlllll
but is it proven that there is no sqrt(-1) in R? someone just said " i dont know it, ill call it i" and complex numbers were born
Post 08 May 2013, 22:27
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2888
Location: [RSP+8*5]
bitRAKE
There is prolly a mapping from quaternions to the 4D space you are using.

Lovely image here of 3D mandlebrot:
http://blog.hvidtfeldts.net/index.php/2011/09/distance-estimated-3d-fractals-v-the-mandelbulb-different-de-approximations/

Mandlebrot fractal is difficult to see in the mandlebulb, but it's in there:
http://upload.wikimedia.org/wikipedia/commons/b/b0/Mandelbulb_p2.jpg

Here there is a programming error which was lost by Mandlebrot:
http://www.bgc.bard.edu/gallery/gallery-at-bgc/past-exhibitions/focus-gallery-4/highlights-focus.html

If the order of values is reversed from zr²-zi² to zi²-zr²; in the calculation of next zr, then the following error is seen.


Description: Software errors are fun. :P
Filesize: 38.34 KB
Viewed: 4197 Time(s)

MandErr.png



_________________
¯\(°_o)/¯ unlicense.org
Post 09 May 2013, 04:54
View user's profile Send private message Visit poster's website Reply with quote
fredlllll



Joined: 17 Apr 2013
Posts: 56
fredlllll
i think i really should start with my 3d implementation XD

oh and does someone know how to render my formular in 3d? because i dont know how to really do it except voxels =/
Post 09 May 2013, 09:52
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6034
Location: Poland
MHajduk
fredlllll wrote:
but is it proven that there is no sqrt(-1) in R? someone just said " i dont know it, ill call it i" and complex numbers were born
First of all, sorry for the belated reply but we had here two thunderstorms and I had to stay off-line (I do it always for security reasons, I just don't want to have my hardware burnt in case something goes wrong). Nevertheless, you may not be interested in my private affairs... never mind. Wink

Your questions are asked in a bit irritating manner but provoke to thinking and hence are valuable. I suspected that you may ask if sqrt(-1) belong to the real numbers set (R) and thought about the possible proof. At first I even wanted to use axiom of Archimedes but after all I realized it isn't so much needed here (we can made far stronger assumption than that used in axiom of Archimedes). The proof is relatively easy and I'm sure that thousands of mathematicians before me made it. Here we go.

Let's assume that a number sqrt(-1) is real. We can name it with any symbol we choose but I think it'll be better to stay with "i" because it's used so long in maths and there is no reason to change it, anyway bear in mind it's only a naming convention.

So, we assume that i = sqrt(-1) is real. The number i has such a feature that if squared gives us -1:

i^2 = -1

Okay. If i is real then it should have its place among other real numbers, in other words it should be greater than some real numbers and at the same time less than others. We can just check the relationship of i to zero:
  • If i >= 0 then

    i^2 >= 0

    i.e.

    -1 >= 0
    but this is just contradiction with what we know about these numbers. Hence i cannot be greater or equal to zero.

  • Let's check now if i < 0.
    If it could be true then for all integer numbers k that are less than zero we will have

    k*i > 0

    Let's square this inequality by sides:

    (k*i)^2 > 0

    i.e.

    k^2 * i^2 > 0

    so

    k^2 * (-1) > 0

    and finally

    k^2 < 0

    But this is impossible because we know from elementary algebra that for every integer number k, doesn't matter negative or non-negative, square of k will be non-negative. Again we get the contradiction, hence i cannot be less than zero.
What exactly does it mean? The number i is neither less nor greater or equal to zero. Such situation is impossible in the set of real numbers where we always can compare numbers. Therefore i, as an incomparable with any real number (similar reasoning like for zero we can make for any real number) cannot be an element of the set of real numbers.
Post 09 May 2013, 18:32
View user's profile Send private message Visit poster's website Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6034
Location: Poland
MHajduk
fredlllll wrote:
lets say sqrt(-i) = j. just like sqrt(-1) = i . so i had my "new" complex number which looked like 1+1i+1j.

(...)

So now i have some strange numbers where every mathematician will tell me "sqrt(-i) is already known. what are you doing dumbhead??"
its shenanigans Razz as i said.

fredlllll wrote:
so if we say we just didnt find the sqrt(-i) and call it j, my mathematics stuff would be correct XD
I'm afraid that I have no good news for you because your "shenanigans" are just ordinary complex numbers on the complex plane. Wink

You may ask what is the value of √¯-i and what kind of number it is. Well, numbers such as 1, i, -1 and -i belong to the unit circle on the complex plane and may be represented in the trigonometric form this way:
  • 1 = 1 + i*0 = cos(0) + i*sin(0)

  • i = 0 + i*1 = cos(π/2) + i*sin(π/2)

  • -1 = -1 + i*0 = cos(π) + i*sin(π)

  • -i = 0 + i*(-1) = cos(3/2 * π) + i*sin(3/2 * π)
The trigonometric form of -i turns out to be useful when you want to calculate √¯-i because you can use here de Moivre's formula:

√¯-i = -i^(1/2) = [cos(3/2 * π) + i*sin(3/2 * π)] ^ (1/2) = cos(1/2 * 3/2 * π) + i*sin(1/2 * 3/2 * π) = cos(3/4 * π) + i*sin(3/4 * π)

Because cos(3/4 * π) = -√¯2/2 and sin(3/4 * π) = √¯2/2

we have that

j = √¯-i = -√¯2/2 + i * √¯2/2

and it is a complex number. Hence also all "shenanigans" of form

a + b*i + c*j = a + b*i + c*(-√¯2/2 + i * √¯2/2) = (a - c*√¯2/2) + (b + c*√¯2/2) * i

are complex too.
Post 09 May 2013, 19:59
View user's profile Send private message Visit poster's website Reply with quote
fredlllll



Joined: 17 Apr 2013
Posts: 56
fredlllll
okay so no sqrt(-1) in R Razz got that.

ejup i already know that there is a complex representation of sqrt(-i) but even if it is a part of a complex number, as shown above it does weird things to the fractal you cant do with a normal complex number as C (maybe because im just shoving them around, but my j presentation is much easier readable than the backconversion to a complex number.).

as already stated its shenanigans and was just made to get a 3d representation of the mandelbrot, which in this case acts as a 4 dimensional object. okay its pseudo-4 dimensional. but its "correct" mathematics. you could also represent a real number as a*3.14159+b*42 and you have 2 pseudo dimensions. and as complex numbers act a bit strange i get this asymmetric thing there.

i just thought i could post it here because someone might want to tinker with the idea Razz and as you see i get some "results" Wink i really wonder how would the mandelbrot look like in 3d using this j stuff (using a line for the jpart)
so maybe someone wants to test it and post a result, or ill test it when i have time for it ^__^
Post 09 May 2013, 21:16
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
Well check this out http://pastebin.com/9JLvNrVg
Post 10 May 2013, 00:40
View user's profile Send private message Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 724
tthsqe
fredlll, interesting ideas, but unfortunately these kinds of issues have been investigated before and are summed up in the Frobenious theorem (http://en.wikipedia.org/wiki/Frobenius_theorem_(real_division_algebras)).

I see that you are multiplying quadruples of real numbers (a,b,c,d) by identifying (a,b,c,d) with the symbol a + b i + c j + d i j and multiplying out using the distributive property. To give the result the same form as what you started with, you used the rules:
Code:
a) i*i = -1
b) j*j = -i
c) i*j = j*i    

The crucial observation is that assumption c) makes your whole multiplication operation commutative, and the Frobenious theorem guaranties that your field is going to be isomorphic to either R or C. Because of assumption a), your field cannot be R, so it is C. The fundamental theorem of algebra then says that b) implies that j has a solution in R+R*i. To sum it up
Code:
j -> (1-i)/Sqrt[2]    

provides an isomorphism of your field to the ordinary C.

Now, I have one comment on your picture.
It should be a simple affine transformation of the ordinary mandelbrot, but clearly it is not.
When calculating the norm of (a,b,c,d) did you simply use a^2+b^2+c^2+d^2 instead of the proper norm obtained by j = (1-i)/Sqrt[2]?

Also, you were VERY close to discovering the quaternions - all you need are the rules
Code:
a) i*i = -1
b) j*j = -1
c) i*j = -j*i    
Post 10 May 2013, 04:18
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2888
Location: [RSP+8*5]
bitRAKE
Here are some awesome (i.e. light-weight and flexible) tools if you want to work on a shader...

Ken Silverman's update of Tigrou's Polydraw
An OpenGL/GLSL scripting tool
http://advsys.net/ken/download.htm

Iñigo Quilez
https://www.shadertoy.com/

Another example, GPU raymarcher of the Mandelbox fractal.
http://rrrola.wz.cz/downloads.html

_________________
¯\(°_o)/¯ unlicense.org
Post 10 May 2013, 06:46
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.