 • May 18, 2021, 04:45:46 PM

### Author Topic: (Question) Fractal in 3D associated with z^3-1  (Read 305 times)

0 Members and 1 Guest are viewing this topic.

#### r-lnr

• Fractal Freshman
• • Posts: 3 ##### (Question)Fractal in 3D associated with z^3-1
« on: April 26, 2021, 05:24:01 PM »
Hello guys,
Recently, I've been interested in doing 3D Fractals. After several attempts to code such a fractal, I come for help.
I have tried to use the following method : you have a fixe point P=(x,y,z) with z>0, for points of the form A=(x,y,w=0), you calculate w'=-k/u^3 for some k (e.g. 0.75), and then, if -k/u^3 is not near enough the altitude w you shift A on the line (AP) (and the direction, depending on w>w' or w'>w) and you iterat the process until w and w' are near enough.
To accelerate the computing of the points, I have used this reference http://www.fractalforums.com/mathematics/convergent-distance-estimation-t1566/ instead of using a constant shift distance.
However, I'm not familiar with fractals and thus I am wondering :

-How much iteration should the process of getting from A=(x,y,w=0) a point near enough the surface take ? I have been stopping the calculation at more than 1000 iterations with a precision of 0.0001 for w-w'. Do you think I should lower (at least in a first time) the precision ?

- For the distance estimation, it seems the relation is K=ln(|zn+1-zn|)|zn+1-zn|/|dzn+1-dzn| with dzn+1=dznP(zn)P''(zn)/(P'(zn)^2) and zn+1 and zn are near enough. However, i don't understand what value of dz0 should be taken (right now i have taken z1-z0), especially since it matters a lot in the estimation of the distance and so in my algorithm. Also should the shift be done of exactly the distance, or some constante times the distance (e.g. 0.9*distance) ?

-Do you know any cool ressources to learn that I could use that use this method ?

#### youhn ##### Re: Fractal in 3D associated with z^3-1
« Reply #1 on: April 27, 2021, 10:07:29 AM »
Real fractals (as defined in maths) require an infinite number of iterations, just like integrals and derivatives require infinity for full precision. Fractals are the result of functions, and not all functions are analytical. Therefore some things are basically impossible to fully compute.

Luckily our time is finite, which makes things more pragmatic. Since "real" fractals do not exist in reality, we can only use approximations. Effectiveness is relative to purpose and desire. You don't need more exactness if the result is good enough.

Some resource for the 2D case:
https://en.wikipedia.org/wiki/Newton_fractal
https://mathematica.stackexchange.com/questions/149164/basins-of-attraction-when-using-newtons-method-to-solve-x3-1-0
http://paulbourke.net/fractals/newtonraphson/

Did you try any 2D fractals, before you started working on 3D fractals? Can you share any of your work, code or pretty pictures?

#### r-lnr

• Fractal Freshman
• • Posts: 3 ##### Re: Fractal in 3D associated with z^3-1
« Reply #2 on: April 27, 2021, 12:18:28 PM »
I have done some 2D fractals, but it is a lot simplier to code, that's why I was interested in 3D fractals (and since what I did is not working, I was wondering whether there was any mistake or anything I did not understand in the process I tried to implement. Here is some fractal i obtained : #### youhn ##### Re: Fractal in 3D associated with z^3-1
« Reply #3 on: April 27, 2021, 12:50:15 PM »
Can you share the code from both the working 2D and the current 3D case for comparison?

#### r-lnr

• Fractal Freshman
• • Posts: 3 ##### Re: Fractal in 3D associated with z^3-1
« Reply #4 on: April 27, 2021, 02:02:07 PM »
Here are both codes for 2D and 3D as asked
Code: [Select]
from math import *import numpy as npimport matplotlib.pyplot as pltfrom mpl_toolkits.mplot3d import Axes3Dfrom matplotlib.colors import LightSourcef= lambda z: z**3-1fp= lambda z: 3*z**2fpp=lambda z: 6*zz1=1/2*1j*sqrt(3)-1/2z2=-1/2*1j*sqrt(3)-1/2z3=1nx=50ny=50xmin=-3xmax=3ymin=-3ymax=3import numpy as npx=np.linspace(xmin, xmax, nx)y=np.linspace(ymin, ymax, ny)x,y=np.meshgrid(x,y)T=x+1j*ynbitere=100for n in range (nbitere) :    T=T-(f(T)/fp(T))    eps=0.01T1=(abs(T-z1)<eps)T2=(abs(T-z2)<eps)T3=(abs(T-z3)<eps)T=T1+2*T2+3*T3import matplotlib.pyplot as pltcolo=np.array(['k','r','g','b'])x= np.asarray(x).ravel()y= np.asarray(y).ravel()T= np.asarray(T).ravel()couleur=colo[T]plt.scatter(x,y, c=couleur)plt.show()##PDV=0+1j*0h=1sup=1000def temps(eps,z) :    t=1    a=z    d=-f(a)/(fp(a))    while t<sup and abs(a-z1)>eps and abs(a-z2)>eps and abs(a-z3)>eps :        t+=1        d=d*f(a)*fpp(a)/(fp(a)**2)        a=a-(f(a)/fp(a))    dis=abs(log(abs(f(a)/fp(a))))*abs(f(a)/fp(a))/(abs(d-d*f(a)*fpp(a)/(fp(a)**2)))    return(t,dis)def doublew(u) :     return(-0.75/u**3)xp=np.linspace(xmin, xmax, nx)yp=np.linspace(ymin, ymax, ny)xp,yp=np.meshgrid(xp,yp)a=np.linspace(0,0,nx)b=np.linspace(0,0,ny)Z,Zp=np.meshgrid(a,b)U=xp+1j*ypeps2=0.01C=0.9for i in range(nx) :    j=0    print(i)    for j in range(ny) :        b=U[j][i]        w=0        t=0        c,dis=temps(eps,b)        while t<sup and abs(doublew(c)-w)>eps2 :            t+=1            if t==sup :                 print ("pb")            if doublew(c)>w :                 b=b+(C*dis*(PDV-b)/(abs(PDV-b)))                w=w+(C*dis*(h-w)/(abs(PDV-b)))            else :                  b=b-(C*dis*(PDV-b)/(abs(PDV-b)))                w=w-(C*dis*(h-w)/(abs(PDV-b)))            c,dis=temps(eps,b)        xp[j][i]=b.real        yp[j][i]=b.imag              Z[j][i]=w         fig = plt.figure()ax = fig.add_subplot(111, projection='3d')ax.plot_surface(xp, yp, Z)ax.set_xlabel('X Label')ax.set_ylabel('Y Label')ax.set_zlabel('Z Label')plt.show()
Here I have taken nx and ny quite small, because it is already taking some time and not really working on small cases. The first part of the code is quite standard (it's Newton method), the second is the one I described in the first post (if it's not clear, do not hesitate to ask).

#### 3DickUlus

•       • • Posts: 2217 ##### Re: Fractal in 3D associated with z^3-1
« Reply #5 on: April 28, 2021, 01:17:02 AM »
Have you considered "triplex maths" ? with this you can render the 3D equivalent of most 2D fractals.
Fragmentarium is not a toy, it is a very versatile tool that can be used to make toys #### youhn ##### Re: Fractal in 3D associated with z^3-1
« Reply #6 on: April 28, 2021, 06:36:19 PM »
@r-lnr
Disclaimer: I'm not expert in code, math or fractals.
Wouldn't it be easier to first try a more standard distance estimation method in 2D for a simple case?

@3DickUlus
Without any knowledge of Triplex Math, I'm pretty sure it's just a subset of geometric algebra. A great video (of which I merely understand some bits) is https://www.youtube.com/watch?v=tX4H_ctggYo. Except for the topic on the old forum, do you know any other resources for Triplex Maths?

#### claude ##### Re: Fractal in 3D associated with z^3-1
« Reply #7 on: April 28, 2021, 06:46:39 PM »
http://www.bugman123.com/Hypercomplex/index.html has examples of a few different Triplex things. AFAIK they are ad-hoc, while geometric algebra is more principled?  Don't know GA though...

#### youhn ##### Re: Fractal in 3D associated with z^3-1
« Reply #8 on: April 28, 2021, 07:21:31 PM »
GA unifies complex numbers, quaternions, etc. All in real numbers. Rotational formulas work in any dimension, and only need a plane (bivector) to do this. Much easier to understand than rotations using matrices. Though because it goes down to the very basic level, it's hard(er) to grasp if you have any training in classical maths. If Clifford didn't die young, we might all be used this stuff right now. I'll see if I can find my back-of-the-envelope notes deriving the Mandelbrot set in 2D and 3D (might also need debugging, which brings us back on-topic somewhat).

#### 3DickUlus

•       • • Posts: 2217 ##### Re: Fractal in 3D associated with z^3-1
« Reply #9 on: April 29, 2021, 01:19:08 AM »
yes, my suggestion would be http://www.bugman123.com/Hypercomplex/ too as it seemed really straight forward to make a 2D function use these triplex math calls.

### Similar Topics ###### "Time Span"

Started by cricke49 on Fractal Image Gallery

0 Replies
1022 Views August 02, 2018, 07:05:21 AM
by cricke49 ###### A new style of fractal imagery using fractal neural style transfer

Started by iRyanBell on Fractal Image Gallery

3 Replies
975 Views October 03, 2020, 10:50:39 PM
by Jimw338 ###### Neural Style Transfer with Fractal Art

Started by reallybigname on Other Artforms

1 Replies
771 Views July 20, 2019, 04:25:41 PM
by reallybigname ###### Birdie Style

Started by gannjondal on Fractal Image Gallery

1 Replies
923 Views May 08, 2018, 02:39:37 PM
by who8mypnuts ###### Buddhabrot-style Burning Ship [65536x24576]

Started by programagor on Fractal Image Gallery

12 Replies
1362 Views October 10, 2018, 02:12:39 AM
by 3DickUlus