# Continuity of real portion of cosine variant of 3d fractals

by Matt Benesi
Tags: continuity, cosine, fractals, portion, real, variant
 P: 66 By continuity I mean an unbroken fractal. With certain variants, one ends up with sharp gaps in the fractal. $$mag=({x^2+y^2+z^2})^{n/2}$$ $$yzmag=\sqrt{y^2+z^2}$$ $$\theta= n *atan2 \;\;(x + i\;\;yzmag )$$ $$\phi = n* atan2\;\; (y + iz)$$ $$new_x= \cos{(theta)}\;*\;mag$$ $$new_y= \sin{(theta)}\;*\;\cos{(phi)}\;*\;mag$$ $$new_z= \sin{(theta)}\;*\;\sin{(phi)}\;*\;mag$$ You can add in pixel components for the Mandelbrot variant, starting with a seed value; or you can start with a pixel value and add in Julia components for the Julia variant (same as with normal 2d Mandelbrots). There are various modifications that make this formula produce nicer fractals- taking the negative absolute value of the sin(theta) component in the new y and z components makes a much more interesting fractal. What I am interested in is this: When n=2 you can do the following manipulation and the fractal remains continuous (is not fragmented). if x> yzmag then new_x = -new_x If n= anything other than 2+4*V (with V=0,1,2,3....) the fractal will become fragmented. In other words, the above formula only works for n=2,6,10,14..... When n is odd (n=3,5,7,9....) you can do the following manipulation of the new x component and not have a fragmented fractal: if x>0 then new_x = -new_x These 2 manipulations work for multiple fractal formulas- I've tested them on my mag vs. xyz variety with great results, but I'd like to write a CONTINUOUS general formula to calculate the following function: var(n,yzmag) equals yzmag for n=2,6,10 equals 0 for n=3,5,7 and is between yzmag and 0 when between 1 and 3 or between 5 and 7... So that I can write a general formula like: if x > var(n,yzmag) then new_x=-new_x Now yzmag might be better written (for between 3 and 5... as 4,8,12, etc. don't do continuous fractals even for -yzmag) as: $$yzmag = |y|*y \;+\;|z|*z$$ if (yzmag>0) $yzmag=\sqrt{|yzmag|}$ else $yzmag=-\sqrt{|yzmag|}$ note that this will result in entirely differently shaped fractals (works well in some cases... not in others). Anyways, anyone with a particular grasp of this field of mathematics might know the answer- what equation do we use to determine what portion of yzmag to use? Looks like it might be cosine or sin type thing, or perhaps some relation between (theta and pi) * yzmag.
 P: 4,568 Hey Matt Benesi and welcome to the forums. When you have this kind of situation, what can be useful is to create a version of the function that is really complicated (but still continuous), then one technique that applied mathematicians, engineers, and scientists use is what is known as an integral transform. Essentially what this means is that you take some really complex function, or a signal and you want to find some kind of 'continuous' representation of it in terms of an analytic representation. It's not to say your function is not already continuous, but it may be that you want to get a form of it that is in an analytic form like an infinite series expansion that behaves like your function which you can calculate by evaluating enough terms so that the answer is right and with this method you don't have to worry about doing 'special things' like flipping signs on certain conditions which is what you are doing. This method of integral transform is used pretty much everywhere where you have a complex signal or even where you have a complex function (continuous or discontinuous) and you want some kind of continuous analytic analog that you can evaluate in an analytic manner (like you do when you calculate y for y = x^2) and although say for discontinuous functions it may not represent the function 'absolutely', it is good enough to use for the purpose it serves. Here is a link discussing the general idea: http://en.wikipedia.org/wiki/Integral_transform What this will do is basically allow you to represent your function, no matter how complicated it is in a series expansion if all of the criteria are met for the integral transform. Now it depends on what you want to do, but if you want some kind of exact analog of your function, or variable relationship you will need to get an exact form which means being able to calculate all of the coeffecients in some way. What I will do now is ask you of your mathematical background so that I can give more specific information. If you do not have much background, then a lot of what I am telling you won't make much sense, but I can still explain enough I think so that you can move towards getting a solution.
 P: 66 Thanks Chiro. I don't have an extensive mathematical background- what I do know I've learned outside of classrooms, although I did pick up a trick or two in various classes through the years. I know some basic manipulations of e, sin, and cos (series expansions of these, and various other series). Of course I'm familiar with complex numbers, trigonometry, and the various other forms of math I've used to write the various fractal formulas I've created. A little calculus, when needed. I'd prefer a quick and dirty mathematical explanation: a simple equation that I can see working, from which I can then learn the methods used to derive the equation. As I'm already familiar with the formulas, I'd like to think that the correct solution will "click", or make sense to me once I've seen it. I'd simply like to see what relationship should be used for n=4,8,12, OR better yet, I'd like to have a continuous relationship so that n could be incremented smoothly, which I think would look really nice on certain fractals. For now, we can greatly simplify it by reducing the problem to 2 dimensions. So: theta= n * atan2 (x + iy) magnitude= (x^2+y^2)^(n/2) temp_x = cos(theta)*magnitude if n==2,6,10,14... if (x< |y|) then temp_x = -temp_x else if n==3,5,7,9.... if (x< 0 ) then temp_x = -temp_x new_x = temp_x + x_pixel_value new_y = sin(theta) * magnitude + y_pixel_value Actually, we cannot see the discontinuities in 2d fractals... so... dunno. anyways, should proceed to something else for now.
P: 4,568

## Continuity of real portion of cosine variant of 3d fractals

 Quote by Matt Benesi Thanks Chiro. I don't have an extensive mathematical background- what I do know I've learned outside of classrooms, although I did pick up a trick or two in various classes through the years. I know some basic manipulations of e, sin, and cos (series expansions of these, and various other series). Of course I'm familiar with complex numbers, trigonometry, and the various other forms of math I've used to write the various fractal formulas I've created. A little calculus, when needed. I'd prefer a quick and dirty mathematical explanation: a simple equation that I can see working, from which I can then learn the methods used to derive the equation. As I'm already familiar with the formulas, I'd like to think that the correct solution will "click", or make sense to me once I've seen it. I'd simply like to see what relationship should be used for n=4,8,12, OR better yet, I'd like to have a continuous relationship so that n could be incremented smoothly, which I think would look really nice on certain fractals. For now, we can greatly simplify it by reducing our problem to 2 dimensions. So: theta= n * atan2 (x + iy) magnitude= (x^2+y^2)^(n/2) temp_x = cos(theta)*magnitude //we'll forget about the y value for now if (x< |y|) then temp_x = -temp_x
You need to use the signum function.

The signum function returns -1 for a negative number, 0 for 0 and +1 for a positive number. So in the context of your function, introduce b = signum(x - |y|).

Now for this just multiply x by b.

You may have to adjust a little but thats basically the idea.

Now if you want some kind of series formula for that then you have to use something like an integral transform which will give you a series expansion in terms of x which is why I wrote that whole spiel on integral transforms.

But take a look at the signum function:

http://en.wikipedia.org/wiki/Sign_function
 P: 66 Ohhh... I know the signum function <-- that's one of those statements meant to convey a bit of emotional undercurrent. :D Keep in mind that the signum function won't work in this particular case. When n=3,5,7, etc. (n is odd), x -|y| does not necessarily = 0, so the signum function will return an entirely different value. It has more to do with n as a multiplier of theta in cosine (n*theta). I've created a couple Julia images (Julias, because the sharp breaks are easier to see for a Julia of 1,0 instead of a regular Mandelbrot type fractal). These are 2d, although if we figure this out, we'll be able to extend it to higher dimensions (note that the current things that work for 2d work for 3d as well- we just don't have a continuous function to determine what x should be greater than). I don't know what's up with Google Picasa today- only allowing certain photos to be linked, and I can't change the permissions for certain photos for whatever reason. Anyways, here is the album link, captions describe whether I use x<0 or x<|y| to determine sign switch. You can see the sharp cutoffs when you use the incorrect version to switch sign. Album clicky clicky ( https://picasaweb.google.com/103496528720991269557/February262012DemosForMathForum?authuser=0&feat=directlink ) Note that neither type works for z^4.... However, a blanket setting of nx=-nx works (with no checks). This works for all varieties, and isn't as interesting as it results in the tricorn variety of mandelbrot fractal... The point being, you get interesting results for higher dimensional fractals, so it would be nice to have a continuous function so there can be smooth increments of n (and we can use n=4,8,12... etc). Here is a z^2 (n=2) using the proper setting in my mag vs. xyz formula type: There are interesting patterns without the sign assignment, but very interesting things pop out. In fact, the z^2 (x-mas tree- best formula) bulb modified with the sign assignment (and ||) is a LOT more interesting than the regular one.

 Related Discussions Calculus & Beyond Homework 5 Calculus & Beyond Homework 8 Calculus & Beyond Homework 3 Calculus & Beyond Homework 2 General Math 3