comment { Calculation formulas developed by Kerry Mitchell for version 3 of Ultra Fractal. Due to UF3's new features and syntax, these formulas will not work with version 2. Compilation updated 27 November 2021 Includes: Rotated Mandelbrot & Julia Rational Newton Mandelbrot & Julia (updated from v2) Caramel Popcorn Caramel Popcorn 3 Axis Embossed Mandelbrot & Julia Rose Range Lite Relativistic Addition Mandelbrot & Julia Burning Ship Mandelbrot & Julia Relaxed Newton/Halley Unit Vector Tweak Mandelbrot & Julia Partial cz Mandelbrot & Julia Alternating Functions Interpolating Functions Fourier Popcorn Breaking Newton - Real Breaking Newton - Complex Compound Mandelbrot Compound Julia Mod Mandelbrot Mod Julia Relaxed Householder's Method Extra Foam Round and Transform } rotated-mandelbrot { ; Kerry Mitchell 06oct2002 ; ; Rotates the z variable in the standard Mandelbrot ; calculation each iteration. ; ; Use the 'rotation type' parameter to rotate before or ; after raising z to the desired power, or both before and ; after. The '+before, -after' setting rotates the opposite ; way after raising z to the power. ; ; The rotation angle is the 'rotation factor' times the angle ; of the pixel or z. The 'constant' setting in 'rotation type' ; makes the rotational angle a constant 'rotation factor' ; degrees. ; init: c=#pixel z=c+@manparam float t=0.0 float trad=@rotfac*#pi/180 rot=(0,0) loop: ; ; set up the rotation angle ; if(@angletype==1) ; pixel t=@rotfac*atan2(#pixel) elseif(@angletype==2) ; z t=@rotfac*atan2(z) else ; constant t=trad endif rot=cos(t)+flip(sin(t)) ; ; iterate z, taking into account the rotation type ; if(@rottype==1) ; before z=z*rot z=z^@power+c elseif(@rottype==2) ; after z=z^@power+c if(@angletype==2) t=@rotfac*atan2(z) rot=cos(t)+flip(sin(t)) endif z=z*rot elseif(@rottype==3) ; before & after z=z*rot z=z^@power+c if(@angletype==2) t=@rotfac*atan2(z) rot=cos(t)+flip(sin(t)) endif z=z*rot elseif(@rottype==4) ; +before, -after z=z*rot z=z^@power+c if(@angletype==2) t=@rotfac*atan2(z) rot=cos(t)+flip(sin(t)) endif z=z/rot else ; none z=z^@power+c endif bailout: |z|<@bailout default: title="Rotated Mandelbrot" periodicity=0 param manparam caption="perturbation" default=(0,0) endparam param power caption="power" default=(2,0) endparam float param bailout caption="bailout" default=1000.0 endparam param rottype caption="rotation type" default=1 enum="none" "before iterating" "after iterating" \ "before & after" "+before, -after" hint="How z is rotated each iteration." endparam float param rotfac caption="rotation factor" default=1.0 enabled=@rottype!="none" hint="If 'angle type' is 'constant', then this is the \ rotation angle in degrees. Otherwise, it is the factor \ that multiples the pixel or z angle to make the rotation \ angle." endparam param angletype caption="angle type" default=2 enum="constant" "pixel" "z" enabled=@rottype!="none" hint="Use 'constant' to specify a constant angle in degrees. \ Otherwise, the rotation is based on the angle of the pixel \ or the angle of z." endparam switch: type="rotated-julia" julparam=#pixel bailout=bailout power=power rottype=rottype rotfac=rotfac angletype=angletype } rotated-julia { ; Kerry Mitchell 06oct2002 ; ; Rotates the z variable in the standard Julia set ; calculation each iteration. ; ; Use the 'rotation type' parameter to rotate before or ; after raising z to the desired power, or both before and ; after. The '+before, -after' setting rotates the opposite ; way after raising z to the power. ; ; The rotation angle is the 'rotation factor' times the angle ; of the pixel or z. The 'constant' setting in 'rotation type' ; makes the rotational angle a constant 'rotation factor' ; degrees. ; init: z=#pixel c=@julparam float t=0.0 float trad=@rotfac*#pi/180 rot=(0,0) loop: ; ; set up the rotation angle ; if(@angletype==1) ; pixel t=@rotfac*atan2(#pixel) elseif(@angletype==2) ; z t=@rotfac*atan2(z) else ; constant t=trad endif rot=cos(t)+flip(sin(t)) ; ; iterate z, taking into account the rotation type ; if(@rottype==1) ; before z=z*rot z=z^@power+c elseif(@rottype==2) ; after z=z^@power+c if(@angletype==2) t=@rotfac*atan2(z) rot=cos(t)+flip(sin(t)) endif z=z*rot elseif(@rottype==3) ; before & after z=z*rot z=z^@power+c if(@angletype==2) t=@rotfac*atan2(z) rot=cos(t)+flip(sin(t)) endif z=z*rot elseif(@rottype==4) ; +before, -after z=z*rot z=z^@power+c if(@angletype==2) t=@rotfac*atan2(z) rot=cos(t)+flip(sin(t)) endif z=z/rot else ; none z=z^@power+c endif bailout: |z|<@bailout default: title="Rotated Julia" periodicity=0 param julparam caption="Julia parameter" default=(0,0) endparam param power caption="power" default=(2,0) endparam float param bailout caption="bailout" default=1000.0 endparam param rottype caption="rotation type" default=1 enum="none" "before iterating" "after iterating" \ "before & after" "+before, -after" hint="How z is rotated each iteration." endparam float param rotfac caption="rotation factor" default=1.0 enabled=@rottype!="none" hint="If 'angle type' is 'constant', then this is the \ rotation angle in degrees. Otherwise, it is the factor \ that multiples the pixel or z angle to make the rotation \ angle." endparam param angletype caption="angle type" default=2 enum="constant" "pixel" "z" enabled=@rottype!="none" hint="Use 'constant' to specify a constant angle in degrees. \ Otherwise, the rotation is based on the angle of the pixel \ or the angle of z." endparam switch: type="rotated-mandelbrot" bailout=bailout power=power rottype=rottype rotfac=rotfac angletype=angletype } comment { ; narrative copyright Kerry Mitchell 28apr2001 Updated 03jan2003 Mandelbrot-Newton Formulas Mandelbrot and Newton are two of the more popular fractal types, and have been studied for quite a while. Each has its own unique style, due to the nature of the underlying formulas. Mandelbrot sets Mandelbrot fractals come from iterating z = f(z), where f is a function of the variable z and a parameter c. The initial value of z is the critical point of f: the value z0 such that the derivative of f at z0 is 0, or f'(z0) = 0. Typically, c comes from the pixel value. The image shows which c values are such that f(z) never goes to infinity. Thus, the "bailout" condition is generally some variant of stopping the iteration when z becomes large. For polynomials, this means that the fractal structure is located around the origin of the plane (around the point (0,0)), because as c gets large, z gets large. Julia sets can be thought of as variants of the Mandelbrot set for a given formula. The major difference is in the initialization: z is initialized to the pixel value and c is a user-input constant. The Mandelbrot set acts as a catalog of the Julia sets: the structure of the Mandelbrot set around a given point c is similar to the structure of the Julia set for that c. Consequently, Julia sets typically do not exhibit the diversity of structure of the Mandelbrot set. In particular, Julia sets do not contain "midgets," small copies of the Mandelbrot set. Newton fractals Newton fractals are the result of iterating z = z - g(z)/g'(z), where g is a function of the variable z and a parameter c, and g'(z) is the first derivative of g(z) with respect to z. Newton's method is a technique for finding roots to an equation, specifically, finding those z values such that g(z) = 0. Consequently, the initial z value is typically taken as the pixel (like a Julia set), and the "bailout" condition is when two consecutive z values are close enough, indicating convergence to a root. Most Newton images have a characteristic structure of strings of loops. This lace-like form extends to infinity, since the iteration results in z settling down to a final value for almost any initial guess. Newton fractals are generally created by taking the initial z value from the pixel and having c be constant; an example is solving z^4 - 1 = 0. This is essentially a Julia set formulation, where c takes the role of 1. Thus, the structure of the fractal does not show a great deal of variation, and Newton fractals typically do not contain midgets. Mandelbrot-Newton formula What is missing is a Mandelbrot implementation of Newton's method. This image (presumably) would have a great diversity of structure, as it would catalog the infinity of Julia-Newton images available from the same formula. If done correctly, a Mandelbrot-Newton image would also extend to infinity, instead of being constrained to a relatively small region around the origin. The problem is in determining the critical point of the formula, so that the appropriate initial z can be found. To do this, compare the Mandelbrot and Newton formulas: Mandelbrot: z = f(z) Newton: z = z - g(z)/g'(z), thus f(z) = z - g(z)/g'(z). The Mandelbrot initial z is z0 such that f'(z0) = 0: f = z - g/g', f' = 1 - (g' g' - g g'')/(g'g'), or f' = 1 - 1 + (g g'') / (g' g'), resulting in f' = (g g'') / (g' g'). So f'(z) will be 0 whenever g(z) = 0 or g''(z) = 0. The first condition is the solution that the formula is trying to find, so using that for the initial z will not be productive. Thus, the critical point comes from having the second derivative of g be 0: g''(z0) = 0. (Strictly speaking, there are critical points where f'(z) fails to exist, which would occur when g'(z) = 0. However, this would cause the iteration formula to fail by dividing by zero, so it is not a valid beginning point.) Finding z such that g''(z) = 0 is not a trivial task for a general function g. However, this can be simplified by constructing g in a special way: g(z) = h(z) + az^2 + bz + c, where h(z) is any general function of z, and a, b, and c are constants. Differentiating, g'(z) = h'(z) + 2az + b, and g''(z) = h''(z) + 2a. The advantage of this is that any z can be the critical point, through a judicious choice of the constant a. In practice, the user inputs the initial point z0. Then, a is determined by forcing g''(z0) to be 0: g''(z0) = 0 = h''(z0) + 2a, or, solving for a: a = -1/2 h''(z0). Once the function h(z) is chosen, it is reasonably straightforward to determine h''(z0), and thus a. The user inputs b, and the bz term is just to add more flexibility. The constant term c is supplied by the pixel value, just as in typical Mandelbrot formulas. To recap, a Mandelbrot version of Newton's method can be created by starting with any function h(z) whose second derivative is non-zero. The user specifies the critical point and initial z value z0. Then, a is determined, a = -0.5 h''(z0). The constant b is another user input, and c comes from the pixel value. The formulas are then: Newton: g(z) = h(z) + az^2 + bz + c, g'(z) = h'(z) + 2az + b Mandelbrot: f(z) = z - g(z)/g'(z) The bailout condition is when the next z value is close enough to the previous z, indicating that g(z) = close enough to 0, or that z is a root of g(z). Rational implementation The initial implementation of this idea was with a rational h(z). Rational functions are ratios of polynomial functions. Polynomials themselves are rational functions, as a polynomial p(z) can be written as p(z)/1, and 1 is a (constant) polynomial function. The function h(z) is composed of 2 pieces, p(z) and q(z), both of which are polynomials. To balance between simplicity and flexibility, p(z) = z^m + b, and q(z) = z^n - b, where b is the constant from above (this version does not use the linear bz term). Strictly speaking, m and n should both be non-negative integers (e.g., 0, 1, 2, 17, etc.), but they are allowed to be real numbers (e.g., 1.234, -7.89) for flexibility. Arithmetic combinations of p and q yields h(z); h can be any of the following: p, q, p+q, p-q, q-p, p*q, p/q, or q/p. Using the formula The formula has 7 parameters: "critical point", "bailout", "m", "n", "b", "h(z) type", and "z type": "critical point": This is the initial z value (complex). Whatever value is entered will be the critical point for the function f(z). Smaller values work better; larger values may require magnifications much, much less than 1 (extreme zooming out) to see any detail. "bailout": Use a large (real) value. Since this formula is looking for z to converge to a final value instead of z to get very large, the condition that is tested is 1/|znew - zold|. As znew gets very close to zold, the reciprocal of their difference goes to infinity. "m": The z exponent in the p function: p(z) = z^m + b. Can be any real value (not complex). "n": The z exponent in the q function: q(z) = z^n - b. Can be any real value (not complex). "b": The (complex) constant in the p and q functions. The nature of the fractal may or may not be sensitive to b, depending on the critical point and the h(z) type. In particular, b has no effect when the h(z) type is set to "p+q", as the b values s in the 2 functions cancel out. "h(z) type": How p(z) and q(z) are combined into h(z). Choose from: p, q, p+q, p-q, q-p, p*q, p/q, and q/p. "z type": This formula offers the opportunity to generate an "embossed" image, based on the number of iterations until bailout. If this option is not exercised, then the "z type" parameter determines what value of z is sent to the coloring routine. The choices are "iterate" (the z value that converges to a root of g(z)); "1/change in z", the value checked for bailout; and "derivative", the derivative of g with respect to z. If the embossed image is chosen, the "z type" parameter is hidden. For any set m, n, b, and h(z) type, the entered "critical point" value should indeed be a critical point for f(z). Consequently, the rendered Mandelbrot set should serve as a catalog for Julia sets from the same formula. To keep the same formula, all 7 parameters (plus the embossing parameters) are passed with the "switch" function to the Julia version of the formula. The c constant, which took on the pixel value in the Mandelbrot version, is an input ("Julia parameter") in the Julia version (or passed from the pixel value during the "switch"). Note that the "critical point" is the initial z value only for the Mandelbrot case. It is used in the Julia case to determine the a constant, but the initial z comes from the pixel value. } rational-newton-mandelbrot { ; Kerry Mitchell 28apr2001 ; ; Mandelbrot and Newton set in one ; iterates z = f(z), beginning at zc = critical point of f(z) ; f(z) = Newton algorithm = z - g(z)/g'(z) ; g(z) = h(z) + a*z^2 + c ; h(z) = rational combination of 2 polynomial functions p(z) & q(z) ; p(z) = z^m + b ; q(z) = z^n - b ; a = -h"(zc)/2, so that g"(zc) = 0 and zc is a critical point of f(z) ; b = user input ; c = pixel ; ; Updated 02jan2003: ; added optional embossing capability ; added 'ztype' parameter ; updated syntax to version 3 ; init: ; ; embossing initializations ; float theta=@lightangle*#pi/180.0 float size=@sizefac*0.0065/#magn dr=size*(cos(theta)+flip(sin(theta))) c1=#pixel-dr c2=#pixel+dr int iter=0 int iter1=0 int iter2=0 if(@emboss==false) ; no embossing iter2=1 endif int iter=0 ; ; rational newton initializations ; z=@zc z1=@zc z2=@zc g=(0,0) gp=(0,0) h=(0,0) hp=(0,0) hpp=(0,0) dz=(0,0) temp=(0,0) ; ; first polynomial, p(z) = z^m + b ; temp=z^(@m-1) p=z*temp+@b pp=@m*temp ppp=(@m-1)*pp/z ; ; second polynomial, q(z) = z^n - b ; temp=z^(@n-1) q=z*temp-@b qp=@n*temp qpp=(@n-1)*qp/z ; ; combine p & q to find a ; if(@htype==1) ; q hpp=qpp elseif(@htype==2) ; p+q hpp=ppp+qpp elseif(@htype==3) ; p-q hpp=ppp-qpp elseif(@htype==4) ; q-p hpp=qpp-ppp elseif(@htype==5) ; p*q hpp=p*qpp+2*pp*qp+ppp*q elseif(@htype==6) ; p/q temp=sqr(q) hpp=temp*(q*ppp-p*qpp)-2*q*qp*(q*pp-p*qp) hpp=hpp/sqr(temp) elseif(@htype==7) ; q/p temp=sqr(p) hpp=temp*(p*qpp-q*ppp)-2*p*pp*(p*qp-q*pp) hpp=hpp/sqr(temp) else ; p hpp=ppp endif a=-0.5*hpp loop: iter=iter+1 ; ; first test point ; if(iter1==0) ; ; first polynomial, p(z) = z^m + b ; temp=z1^(@m-1) p=z1*temp+@b pp=@m*temp ; ; second polynomial, q(z) = z^n - b ; temp=z1^(@n-1) q=z1*temp-@b qp=@n*temp ; ; combine p & q to make h(z) ; if(@htype==1) ; q h=q hp=qp elseif(@htype==2) ; p+q h=p+q hp=pp+qp elseif(@htype==3) ; p-q h=p-q hp=pp-qp elseif(@htype==4) ; q-p h=q-p hp=qp-pp elseif(@htype==5) ; p*q h=p*q hp=p*qp+pp*q elseif(@htype==6) ; p/q h=p/q hp=(q*pp-p*qp)/sqr(q) elseif(@htype==7) ; q/p h=q/p hp=(p*qp-q*pp)/sqr(p) else ; p h=p hp=pp endif ; ; add quadratic to make g(z) ; g=h+a*sqr(z1)+c1 gp=hp+2*a*z1 ; ; Newton iteration; check 1/(change in z) for bailout ; dz=g/gp z1=z1-dz temp=1/dz if(|temp|>@bailout) iter1=iter endif endif ; ; second test point ; if(iter2==0) ; ; first polynomial, p(z) = z^m + b ; temp=z2^(@m-1) p=z2*temp+@b pp=@m*temp ; ; second polynomial, q(z) = z^n - b ; temp=z2^(@n-1) q=z2*temp-@b qp=@n*temp ; ; combine p & q to make h(z) ; if(@htype==1) ; q h=q hp=qp elseif(@htype==2) ; p+q h=p+q hp=pp+qp elseif(@htype==3) ; p-q h=p-q hp=pp-qp elseif(@htype==4) ; q-p h=q-p hp=qp-pp elseif(@htype==5) ; p*q h=p*q hp=p*qp+pp*q elseif(@htype==6) ; p/q h=p/q hp=(q*pp-p*qp)/sqr(q) elseif(@htype==7) ; q/p h=q/p hp=(p*qp-q*pp)/sqr(p) else ; p h=p hp=pp endif ; ; add quadratic to make g(z) ; g=h+a*sqr(z2)+c2 gp=hp+2*a*z2 ; ; Newton iteration; check 1/(change in z) for bailout ; dz=g/gp z2=z2-dz temp=1/dz if(|temp|>@bailout) iter2=iter endif endif if(@emboss==false) ; no embossing--set z to: if(@ztype==1) ; 1/dz z=temp elseif(@ztype==2) ; derivative z=gp else ; iterate z=z1 endif else ; embossing--z = iter1 & iter2 z=iter1+flip(iter2) endif bailout: (iter1==0)||(iter2==0) default: title="Rational Newton Mandelbrot" method=multipass maxiter=100 periodicity=0 center=(0,0) magn=0.01 ; ; rational newton mandelbrot stuff ; heading caption="Rational Newton parameters" endheading param zc caption="critical point" default=(1,0) hint="Keep to a fairly small value." endparam param bailout caption="bailout" default=1000.0 hint="Set to a large value." endparam param m caption="m" default=8.0 hint="Exponent in p(z) function; p(z) = z^m + b." endparam param n caption="n" default=4.0 hint="Exponent in q(z) function; q(z) = z^n - b." endparam param b caption="b" default=(-1,0) hint="Constant in p(z) and q(z) functions. Doesn't do anything when \ 'h(z) type' is set to 'p+q'." endparam param htype caption="h(z) type" default=2 enum="p" "q" "p+q" "p-q" "q-p" "p*q" "p/q" "q/p" hint="How the p(z) and q(z) functions are combined to make h(z)." endparam param ztype caption="z type" default=0 enum="iterate" "1/change in z" "derivative" hint="Determines what value to send to coloring routine, \ if the image is not embossed." visible=(@emboss==false) endparam ; ; embossing stuff ; heading caption="Embossing parameters" endheading bool param emboss caption="embossed image" default=false endparam float param sizefac caption="contour size" default=1.0 hint="Specifies the relative size of the contour bands. Larger values \ give thicker bands." visible=(@emboss==true) endparam float param lightangle caption="light angle" default=0.0 hint="Angle of apparent light source, in degrees." visible=(@emboss==true) endparam switch: type="rational-newton-julia" zc=zc julparam=#pixel bailout=bailout m=m n=n b=b htype=htype ztype=ztype emboss=emboss sizefac=sizefac lightangle=lightangle } rational-newton-julia { ; Kerry Mitchell 28apr2001 ; ; Julia and Newton set in one ; iterates z = f(z), beginning at zc = critical point of f(z) ; f(z) = Newton algorithm = z - g(z)/g'(z) ; g(z) = h(z) + a*z^2 + c ; h(z) = rational combination of 2 polynomial functions p(z) & q(z) ; p(z) = z^m + b ; q(z) = z^n - b ; a = -h"(zc)/2, so that g"(zc) = 0 and zc is a critical point of f(z) ; b = user input ; c = pixel ; ; Updated 02jan2003: ; added optional embossing capability ; added 'ztype' parameter ; updated syntax to version 3 ; init: ; ; embossing initializations ; float theta=@lightangle*#pi/180.0 float size=@sizefac*0.0065/#magn dr=size*(cos(theta)+flip(sin(theta))) z1=#pixel-dr z2=#pixel+dr int iter=0 int iter1=0 int iter2=0 if(@emboss==false) ; no embossing iter2=1 endif int iter=0 ; ; rational newton initializations ; z=@zc g=(0,0) gp=(0,0) h=(0,0) hp=(0,0) hpp=(0,0) dz=(0,0) temp=(0,0) ; ; first polynomial, p(z) = z^m + b ; temp=z^(@m-1) p=z*temp+@b pp=@m*temp ppp=(@m-1)*pp/z ; ; second polynomial, q(z) = z^n - b ; temp=z^(@n-1) q=z*temp-@b qp=@n*temp qpp=(@n-1)*qp/z ; ; combine p & q to find a ; if(@htype==1) ; q hpp=qpp elseif(@htype==2) ; p+q hpp=ppp+qpp elseif(@htype==3) ; p-q hpp=ppp-qpp elseif(@htype==4) ; q-p hpp=qpp-ppp elseif(@htype==5) ; p*q hpp=p*qpp+2*pp*qp+ppp*q elseif(@htype==6) ; p/q temp=sqr(q) hpp=temp*(q*ppp-p*qpp)-2*q*qp*(q*pp-p*qp) hpp=hpp/sqr(temp) elseif(@htype==7) ; q/p temp=sqr(p) hpp=temp*(p*qpp-q*ppp)-2*p*pp*(p*qp-q*pp) hpp=hpp/sqr(temp) else ; p hpp=ppp endif a=-0.5*hpp c1=@julparam c2=@julparam loop: iter=iter+1 ; ; first test point ; if(iter1==0) ; ; first polynomial, p(z) = z^m + b ; temp=z1^(@m-1) p=z1*temp+@b pp=@m*temp ; ; second polynomial, q(z) = z^n - b ; temp=z1^(@n-1) q=z1*temp-@b qp=@n*temp ; ; combine p & q to make h(z) ; if(@htype==1) ; q h=q hp=qp elseif(@htype==2) ; p+q h=p+q hp=pp+qp elseif(@htype==3) ; p-q h=p-q hp=pp-qp elseif(@htype==4) ; q-p h=q-p hp=qp-pp elseif(@htype==5) ; p*q h=p*q hp=p*qp+pp*q elseif(@htype==6) ; p/q h=p/q hp=(q*pp-p*qp)/sqr(q) elseif(@htype==7) ; q/p h=q/p hp=(p*qp-q*pp)/sqr(p) else ; p h=p hp=pp endif ; ; add quadratic to make g(z) ; g=h+a*sqr(z1)+c1 gp=hp+2*a*z1 ; ; Newton iteration; check 1/(change in z) for bailout ; dz=g/gp z1=z1-dz temp=1/dz if(|temp|>@bailout) iter1=iter endif endif ; ; second test point ; if(iter2==0) ; ; first polynomial, p(z) = z^m + b ; temp=z2^(@m-1) p=z2*temp+@b pp=@m*temp ; ; second polynomial, q(z) = z^n - b ; temp=z2^(@n-1) q=z2*temp-@b qp=@n*temp ; ; combine p & q to make h(z) ; if(@htype==1) ; q h=q hp=qp elseif(@htype==2) ; p+q h=p+q hp=pp+qp elseif(@htype==3) ; p-q h=p-q hp=pp-qp elseif(@htype==4) ; q-p h=q-p hp=qp-pp elseif(@htype==5) ; p*q h=p*q hp=p*qp+pp*q elseif(@htype==6) ; p/q h=p/q hp=(q*pp-p*qp)/sqr(q) elseif(@htype==7) ; q/p h=q/p hp=(p*qp-q*pp)/sqr(p) else ; p h=p hp=pp endif ; ; add quadratic to make g(z) ; g=h+a*sqr(z2)+c2 gp=hp+2*a*z2 ; ; Newton iteration; check 1/(change in z) for bailout ; dz=g/gp z2=z2-dz temp=1/dz if(|temp|>@bailout) iter2=iter endif endif if(@emboss==false) ; no embossing--set z to: if(@ztype==1) ; 1/dz z=temp elseif(@ztype==2) ; derivative z=gp else ; iterate z=z1 endif else ; embossing--z = iter1 & iter2 z=iter1+flip(iter2) endif bailout: (iter1==0)||(iter2==0) default: title="Rational Newton Julia" method=multipass maxiter=100 periodicity=0 center=(0,0) magn=1 ; ; rational newton julia stuff ; heading caption="Rational Newton parameters" endheading param julparam caption="Julia parameter" default=(0,0) endparam param zc caption="critical point" default=(1,0) hint="Keep to a fairly small value." endparam param bailout caption="bailout" default=1000.0 hint="Set to a large value." endparam param m caption="m" default=8.0 hint="Exponent in p(z) function; p(z) = z^m + b." endparam param n caption="n" default=4.0 hint="Exponent in q(z) function; q(z) = z^n - b." endparam param b caption="b" default=(-1,0) hint="Constant in p(z) and q(z) functions. Doesn't do anything when \ 'h(z) type' is set to 'p+q'." endparam param htype caption="h(z) type" default=2 enum="p" "q" "p+q" "p-q" "q-p" "p*q" "p/q" "q/p" hint="How the p(z) and q(z) functions are combined to make h(z)." endparam param ztype caption="z type" default=0 enum="iterate" "1/change in z" "derivative" hint="Determines what value to send to coloring routine, \ if the image is not embossed." visible=(@emboss==false) endparam ; ; embossing stuff ; heading caption="Embossing parameters" endheading bool param emboss caption="embossed image" default=false endparam float param sizefac caption="contour size" default=1.0 hint="Specifies the relative size of the contour bands. Larger values \ give thicker bands." visible=(@emboss==true) endparam float param lightangle caption="light angle" default=0.0 hint="Angle of apparent light source, in degrees." visible=(@emboss==true) endparam switch: type="rational-newton-mandelbrot" zc=zc bailout=bailout m=m n=n b=b htype=htype ztype=ztype emboss=emboss sizefac=sizefac lightangle=lightangle } caramel-popcorn { ; Kerry Mitchell 09Aug2003 ; ; This is a complex-valued implementation and generalization ; of Cliff Pickover's "popcorn" algorithm. His method iterates ; 2 real variables like this: ; ; xnew = xold - h * sin(a*y + tan(b*y)) ; ynew = yold - h * sin(a*x + tan(b*x)) ; ; where a = 1. The current method generalizes the above in ; several ways: ; - The variables x and y are complex. ; - The parameters a, b, and h are all complex. ; - The h coefficient has been changed to +1 in both equations. ; - The outer function (sin) and the inner function (tan) ; are user-specified. ; - Instead of using y in the x equation or x in the y ; equation, the user can choose to use a function of x, ; a function of y, or a function of z (x+i*y) for each. ; ; In addition, several bailout methods have been included: ; - if x gets large ; - if y gets large ; - if z gets large ; - if either x or y get large ; - if both x and y get large ; - if the argument to the x outer function gets large ; - if the argument to the y outer function gets large ; - if either arguments get large ; - if both arguments get large ; ; The latter 4 methods were added because, in the standard ; implementation using the tan() function as the inner function, ; large values of tan() can give visual noise in the image. ; Using these bailout methods can reduce or eliminate those ; features. ; ; To prevent the user from being overwhelmed with all this, ; there is a "controls" parameter. Set it to "less" (default) ; to see a greatly limited set of choices, or set it to "more" ; to have access to all the parameters. ; ; Update history: ; First published 09 August 2003 ; init: complex temp=(0,0) complex temp2=(0,0) complex x=real(#pixel) complex y=imag(#pixel) complex xnew=(0,0) complex ynew=(0,0) complex z=#pixel float r=0.0 float rx=0.0 float ry=0.0 loop: ; ; x equation ; if(@control=="more") ; ; choose what variable to use ; if(@vartypex==1) ; f(y) temp=@varfnx(y) elseif(@vartypex==2) ; f(z) temp=@varfnx(z) else ; f(x) temp=@varfnx(x) endif ; ; compute the inner function and its magnitude for the ; "argument" bailout types ; temp2=@innerfnx(@bx*temp) rx=|temp2| xnew=x+@hx*@outerfnx(@ax*temp+temp2) else temp2=@innerfn(@b*y) xnew=x+@h*@outerfn(y+temp2) endif ; ; y equation ; if(@control=="more") ; ; choose what variable to use ; if(@vartypey==1) ; f(y) temp=@varfny(y) elseif(@vartypey==2) ; f(z) temp=@varfny(z) else ; f(x) temp=@varfny(x) endif ; ; compute the inner function and its magnitude for the ; "argument" bailout types ; temp2=@innerfny(@by*temp) ry=|temp2| ynew=y+@hy*@outerfny(@ay*temp+temp2) else temp2=@innerfn(@b*x) ynew=y+@h*@outerfn(x+temp2) endif ; ; set z ; x=xnew y=ynew z=x+flip(y) ; ; check for bailout ; if(@control=="more") if(@bailtype==1) ; x r=|x| elseif(@bailtype==2) ; y r=|y| elseif(@bailtype==3) ; x or y r=|x| if(|y|>r) r=|y| endif elseif(@bailtype==4) ; x and y r=|x| if(|y|r) r=ry endif elseif(@bailtype==8) ; both r=rx if(ryr) r=|x2| endif if(|x3|>r) r=|x3| endif elseif(@bailtype==5) ; all r=|x1| if(|x2|r) r=r2 endif if(r3>r) r=r3 endif elseif(@bailtype==10) ; all r=r1 if(r2#maxiter)) do_last=#maxiter else do_last=@dolast endif ; ; create array of Fibonacci numbers ; gi=0 while(gi<#maxiter) gi=gi+1 fib[gi]=false endwhile fib1=0 fib2=1 gi=1 while(gi<#maxiter) fib[gi]=true fib1=fib2 fib2=gi gi=fib1+fib2 endwhile ; ; create array of triangular numbers ; gi=0 while(gi<#maxiter) gi=gi+1 tri[gi]=false endwhile gi=0 gj=1 while(gi<#maxiter) tri[gi]=true gi=gi+gj gj=gj+1 endwhile ; ; set do_this flag if that iteration is to be used ; gi=@do_first-1 while(gi<(do_last-1)) gi=gi+1 if(@modtype=="do all") ; do each iteration do_this[gi]=true elseif(@modtype=="do every n") ; do every nth gj=(gi-@do_first+#maxiter*@modbase)%@modbase if(gj==0) do_this[gi]=true endif elseif(@modtype=="skip every n") ; skip every nth gj=(gi-@do_first+#maxiter*@modbase)%@modbase if(gj>0) do_this[gi]=true endif elseif(@modtype=="do primes") ; do if iteration # is prime gj=1 gfac=2 while(gj<(gi-1)) gj=gj+1 if((gi%gj)==0) gfac=gfac+1 endif endwhile if(gfac==2) do_this[gi]=true endif elseif(@modtype=="skip primes") ; do if iteration # is not prime if(gi==1) do_this[gi]=true endif gj=1 gfac=2 while(gj<(gi-1)) gj=gj+1 if((gi%gj)==0) gfac=gfac+1 endif endwhile if(gfac>2) do_this[gi]=true endif elseif(@modtype=="do Fibonacci") ; do if iteration is a Fibonacci # if(fib[gi]==true) do_this[gi]=true endif elseif(@modtype=="skip Fibonacci") ; do if iteration is not a Fibonacci # if(fib[gi]==false) do_this[gi]=true endif elseif(@modtype=="do triangular") ; do if iteration is a triangular # if(tri[gi]==true) do_this[gi]=true endif elseif(@modtype=="skip triangular") ; do if iteration is not a triangular # if(tri[gi]==false) do_this[gi]=true endif elseif(@modtype=="blocks") ; blocks of trap some, then skip some gj=((gi-@do_first)%@block_size)+1 if(gj<=@block_trap) do_this[gi]=true endif endif endwhile ; ; print do_this ; if(@print_do_this==true) gi=0 while(gi<#maxiter) gi=gi+1 if(do_this[gi]==true) print(gi) endif endwhile endif init: bool keepgoing1=true bool keepgoing2=true complex c1=(0,0) complex c2=(0,0) complex dr=(0,0) complex z=(0,0) complex z1=@manparam complex z2=@manparam float part1=0 float part2=0 float r11=0 float r12=0 float rfaze=@rphase/180*#pi float rho=0 float rmax=0 float rmaxfac=@scale*(1+0.5*@rangewidth) float rmin=0 float rminfac=@scale*(1-0.5*@rangewidth) float rn1=0 float rn2=0 float rotangle=-@rotd/180*#pi float rw=0 float rz=0 float size=0 float t11=0 float t12=0 float theta=0 float tn1=0 float tn2=0 float tz=0 int iter=0 int iter11=0 int iter12=0 int itern1=0 int itern2=0 int rangeiter1=0 int rangeiter2=0 ; ; set up embossing ; theta=@lightangle*#pi/180 size=@sizefac*0.0065/#magn dr=size*(cos(theta)+flip(sin(theta))) c1=#pixel-dr c2=#pixel+dr loop: iter=iter+1 ; ; iterate first point ; if(keepgoing1==true) z1=z1^@power+c1 if(|z1|>@bailout) keepgoing1=false endif ; ; check iterate against rose curve ; if(do_this[iter]==true) tz=atan2(z1)+rotangle rz=@ac*cos(@bc*tz)+@as*sin(@bs*tz) if(@vary_width==true) rho=(1-cos(@rfreq*tz+rfaze))/2 rw=rho*(@maxwidth-@minwidth)+@minwidth rminfac=@scale*(1-0.5*rw) rmaxfac=@scale*(1+0.5*rw) endif rmin=rz*rminfac rmax=rz*rmaxfac rz=cabs(z1-@curvecenter) if((rz>=rmin)&&(rz<=rmax)) rangeiter1=rangeiter1+1 rn1=rz tn1=tz itern1=iter if(rangeiter1==1) r11=rn1 t11=tn1 iter11=iter endif endif endif endif ; ; iterate second point ; if(keepgoing2==true) z2=z2^@power+c2 if(|z2|>@bailout) keepgoing2=false endif ; ; check iterate against rose curve ; if(do_this[iter]==true) tz=atan2(z2)+rotangle rz=@ac*cos(@bc*tz)+@as*sin(@bs*tz) rmin=rz*rminfac rmax=rz*rmaxfac rz=cabs(z2-@curvecenter) if((rz>=rmin)&&(rz<=rmax)) rangeiter2=rangeiter2+1 rn2=rz tn2=tz itern2=iter if(rangeiter2==1) r12=rn2 t12=tn2 iter12=iter endif endif endif endif ; ; assign parts of z ; if(@parttype==0) part1=rangeiter1 part2=rangeiter2 elseif(@parttype==1) part1=iter11 part2=iter12 elseif(@parttype==2) part1=itern1 part2=itern2 elseif(@parttype==3) part1=trunc(r11*@sections) part2=trunc(r12*@sections) elseif(@parttype==4) part1=trunc(rn1*@sections) part2=trunc(rn2*@sections) elseif(@parttype==5) part1=trunc(t11*@sections) part2=trunc(t12*@sections) elseif(@parttype==6) part1=trunc(tn1*@sections) part2=trunc(tn2*@sections) endif z=part1+flip(part2) bailout: (keepgoing1==true)||(keepgoing2==true) default: title="Embossed Mandelbrot - Rose Range Lite" method=multipass periodicity=0 ; ; Mandelbrot parameters ; heading caption="Mandelbrot parameters" endheading complex param manparam caption="initial z" default=(0,0) endparam complex param power caption="power" default=(2,0) endparam float param bailout caption="bailout" default=1000 endparam ; ; embossing parameters ; heading caption="Embossing parameters" endheading param parttype caption="emboss type" default=0 enum="in range" "first iteration" "last iteration" "first magnitude" \ "last magnitude" "first angle" "last angle" endparam float param sections caption="# sections" default=2 visible=(@parttype>2) endparam float param lightangle caption="light angle" default=0 hint="Angle of apparant light source, in degrees" endparam float param sizefac caption="contour size" default=1 hint="relative size of contours bands" endparam ; ; rose range lite parameters ; heading caption="Rose Range Lite parameters" endheading float param scale caption="range scale" default=1 endparam bool param vary_width caption="vary width" default=false endparam float param rangewidth caption="range width" default=0.1 visible=(@vary_width==false) endparam float param minwidth caption="min range width" default=0.1 visible=(@vary_width==true) endparam float param maxwidth caption="max range width" default=0.4 visible=(@vary_width==true) endparam float param rfreq caption="range frequency" default=1 visible=(@vary_width==true) endparam float param rphase caption="range phase, deg" default=0 visible=(@vary_width==true) endparam float param ac caption="cos amplitude" default=1 endparam float param bc caption="cos frequency" default=3 endparam float param as caption="sin amplitude" default=0 endparam float param bs caption="sin frequency" default=0 endparam complex param curvecenter caption="curve center" default=(0,0) endparam float param rotd caption="rotation angle" default=0 hint="degrees" endparam ; ; selected iterations paramaters ; heading caption="Selected Iterations parameters" endheading param modtype caption="mod type" default=0 enum="do all" "do every n" "skip every n" "do primes" "skip primes"\ "do Fibonacci" "skip Fibonacci" "do triangular" "skip triangular" \ "blocks" endparam int param modbase caption="n" default=2 min=2 hint="The 'n' for type 'every n'; at least 2." visible=((@modtype=="do every n")||(@modtype=="skip every n")) endparam int param block_size caption="block size" default=4 min=3 visible=(@modtype=="blocks") endparam int param block_trap caption="block trap" default=2 min=1 visible=(@modtype=="blocks") endparam int param do_first caption="first iteration" default=1 min=1 hint="Start with this iteration." endparam int param dolast caption="last iteration" default=0 min=0 hint="End on this iteration; use 0 for maximum iterations." endparam bool param print_do_this caption="print iterations" default=false hint="Print those iterations that will be calculated" endparam switch: type="embossed-julia-rrl" julparam=#pixel ac=ac as=as bailout=bailout bc=bc block_size=block_size block_trap=block_trap bs=bs curvecenter=curvecenter do_first=do_first dolast=dolast julparam=julparam lightangle=lightangle maxwidth=maxwidth minwidth=minwidth modbase=modbase modtype=modtype parttype=parttype power=power print_do_this=print_do_this rangewidth=rangewidth rfreq=rfreq rotd=rotd rphase=rphase scale=scale sections=sections sizefac=sizefac vary_width=vary_width } embossed-julia-rrl { ; Kerry Mitchell 10March2007 ; ; This combines the embossed Julia set with the geometry of the Rose Range ; Lite coloring. The image can be embossed along the edges of the rose curves ; or along internal sections. The parameters are very similar to those in the ; embossed Julia formula and the Rose Range Lite coloring. ; global: bool do_this[round(#maxiter+1)] bool fib[round(#maxiter+1)] bool tri[round(#maxiter+1)] int do_last=0 int fib1=0 int fib2=0 int gfac=0 int gi=0 int gj=0 ; ; set up selected iterations ; ; clear do_this array ; gi=-1 while(gi<#maxiter) gi=gi+1 do_this[gi]=false endwhile ; ; set up counter for final iteration ; if((@dolast==0)||(@dolast>#maxiter)) do_last=#maxiter else do_last=@dolast endif ; ; create array of Fibonacci numbers ; gi=0 while(gi<#maxiter) gi=gi+1 fib[gi]=false endwhile fib1=0 fib2=1 gi=1 while(gi<#maxiter) fib[gi]=true fib1=fib2 fib2=gi gi=fib1+fib2 endwhile ; ; create array of triangular numbers ; gi=0 while(gi<#maxiter) gi=gi+1 tri[gi]=false endwhile gi=0 gj=1 while(gi<#maxiter) tri[gi]=true gi=gi+gj gj=gj+1 endwhile ; ; set do_this flag if that iteration is to be used ; gi=@do_first-1 while(gi<(do_last-1)) gi=gi+1 if(@modtype=="do all") ; do each iteration do_this[gi]=true elseif(@modtype=="do every n") ; do every nth gj=(gi-@do_first+#maxiter*@modbase)%@modbase if(gj==0) do_this[gi]=true endif elseif(@modtype=="skip every n") ; skip every nth gj=(gi-@do_first+#maxiter*@modbase)%@modbase if(gj>0) do_this[gi]=true endif elseif(@modtype=="do primes") ; do if iteration # is prime gj=1 gfac=2 while(gj<(gi-1)) gj=gj+1 if((gi%gj)==0) gfac=gfac+1 endif endwhile if(gfac==2) do_this[gi]=true endif elseif(@modtype=="skip primes") ; do if iteration # is not prime if(gi==1) do_this[gi]=true endif gj=1 gfac=2 while(gj<(gi-1)) gj=gj+1 if((gi%gj)==0) gfac=gfac+1 endif endwhile if(gfac>2) do_this[gi]=true endif elseif(@modtype=="do Fibonacci") ; do if iteration is a Fibonacci # if(fib[gi]==true) do_this[gi]=true endif elseif(@modtype=="skip Fibonacci") ; do if iteration is not a Fibonacci # if(fib[gi]==false) do_this[gi]=true endif elseif(@modtype=="do triangular") ; do if iteration is a triangular # if(tri[gi]==true) do_this[gi]=true endif elseif(@modtype=="skip triangular") ; do if iteration is not a triangular # if(tri[gi]==false) do_this[gi]=true endif elseif(@modtype=="blocks") ; blocks of trap some, then skip some gj=((gi-@do_first)%@block_size)+1 if(gj<=@block_trap) do_this[gi]=true endif endif endwhile ; ; print do_this ; if(@print_do_this==true) gi=0 while(gi<#maxiter) gi=gi+1 if(do_this[gi]==true) print(gi) endif endwhile endif init: bool keepgoing1=true bool keepgoing2=true complex c1=@julparam complex c2=@julparam complex dr=(0,0) complex z=(0,0) complex z1=(0,0) complex z2=(0,0) float part1=0 float part2=0 float r11=0 float r12=0 float rfaze=@rphase/180*#pi float rho=0 float rmax=0 float rmaxfac=@scale*(1+0.5*@rangewidth) float rmin=0 float rminfac=@scale*(1-0.5*@rangewidth) float rn1=0 float rn2=0 float rotangle=-@rotd/180*#pi float rw=0 float rz=0 float size=0 float t11=0 float t12=0 float theta=0 float tn1=0 float tn2=0 float tz=0 int iter=0 int iter11=0 int iter12=0 int itern1=0 int itern2=0 int rangeiter1=0 int rangeiter2=0 ; ; set up embossing ; theta=@lightangle*#pi/180 size=@sizefac*0.0065/#magn dr=size*(cos(theta)+flip(sin(theta))) z1=#pixel-dr z2=#pixel+dr loop: iter=iter+1 ; ; iterate first point ; if(keepgoing1==true) z1=z1^@power+c1 if(|z1|>@bailout) keepgoing1=false endif ; ; check iterate against rose curve ; if(do_this[iter]==true) tz=atan2(z1)+rotangle rz=@ac*cos(@bc*tz)+@as*sin(@bs*tz) if(@vary_width==true) rho=(1-cos(@rfreq*tz+rfaze))/2 rw=rho*(@maxwidth-@minwidth)+@minwidth rminfac=@scale*(1-0.5*rw) rmaxfac=@scale*(1+0.5*rw) endif rmin=rz*rminfac rmax=rz*rmaxfac rz=cabs(z1-@curvecenter) if((rz>=rmin)&&(rz<=rmax)) rangeiter1=rangeiter1+1 rn1=rz tn1=tz itern1=iter if(rangeiter1==1) r11=rn1 t11=tn1 iter11=iter endif endif endif endif ; ; iterate second point ; if(keepgoing2==true) z2=z2^@power+c2 if(|z2|>@bailout) keepgoing2=false endif ; ; check iterate against rose curve ; if(do_this[iter]==true) tz=atan2(z2)+rotangle rz=@ac*cos(@bc*tz)+@as*sin(@bs*tz) rmin=rz*rminfac rmax=rz*rmaxfac rz=cabs(z2-@curvecenter) if((rz>=rmin)&&(rz<=rmax)) rangeiter2=rangeiter2+1 rn2=rz tn2=tz itern2=iter if(rangeiter2==1) r12=rn2 t12=tn2 iter12=iter endif endif endif endif ; ; assign parts of z ; if(@parttype==0) part1=rangeiter1 part2=rangeiter2 elseif(@parttype==1) part1=iter11 part2=iter12 elseif(@parttype==2) part1=itern1 part2=itern2 elseif(@parttype==3) part1=trunc(r11*@sections) part2=trunc(r12*@sections) elseif(@parttype==4) part1=trunc(rn1*@sections) part2=trunc(rn2*@sections) elseif(@parttype==5) part1=trunc(t11*@sections) part2=trunc(t12*@sections) elseif(@parttype==6) part1=trunc(tn1*@sections) part2=trunc(tn2*@sections) endif z=part1+flip(part2) bailout: (keepgoing1==true)||(keepgoing2==true) default: title="Embossed Julia - Rose Range Lite" method=multipass periodicity=0 ; ; Julia parameters ; heading caption="Julia parameters" endheading complex param julparam caption="Julia parameter" default=(0,1) endparam complex param power caption="power" default=(2,0) endparam float param bailout caption="bailout" default=1000 endparam ; ; embossing parameters ; heading caption="Embossing parameters" endheading param parttype caption="emboss type" default=0 enum="in range" "first iteration" "last iteration" "first magnitude" \ "last magnitude" "first angle" "last angle" endparam float param sections caption="# sections" default=2 visible=(@parttype>2) endparam float param lightangle caption="light angle" default=0 hint="Angle of apparant light source, in degrees" endparam float param sizefac caption="contour size" default=1 hint="relative size of contours bands" endparam ; ; rose range lite parameters ; heading caption="Rose Range Lite parameters" endheading float param scale caption="range scale" default=1 endparam bool param vary_width caption="vary width" default=false endparam float param rangewidth caption="range width" default=0.1 visible=(@vary_width==false) endparam float param minwidth caption="min range width" default=0.1 visible=(@vary_width==true) endparam float param maxwidth caption="max range width" default=0.4 visible=(@vary_width==true) endparam float param rfreq caption="range frequency" default=1 visible=(@vary_width==true) endparam float param rphase caption="range phase, deg" default=0 visible=(@vary_width==true) endparam float param ac caption="cos amplitude" default=1 endparam float param bc caption="cos frequency" default=3 endparam float param as caption="sin amplitude" default=0 endparam float param bs caption="sin frequency" default=0 endparam complex param curvecenter caption="curve center" default=(0,0) endparam float param rotd caption="rotation angle" default=0 hint="degrees" endparam ; ; selected iterations paramaters ; heading caption="Selected Iterations parameters" endheading param modtype caption="mod type" default=0 enum="do all" "do every n" "skip every n" "do primes" "skip primes"\ "do Fibonacci" "skip Fibonacci" "do triangular" "skip triangular" \ "blocks" endparam int param modbase caption="n" default=2 min=2 hint="The 'n' for type 'every n'; at least 2." visible=((@modtype=="do every n")||(@modtype=="skip every n")) endparam int param block_size caption="block size" default=4 min=3 visible=(@modtype=="blocks") endparam int param block_trap caption="block trap" default=2 min=1 visible=(@modtype=="blocks") endparam int param do_first caption="first iteration" default=1 min=1 hint="Start with this iteration." endparam int param dolast caption="last iteration" default=0 min=0 hint="End on this iteration; use 0 for maximum iterations." endparam bool param print_do_this caption="print iterations" default=false hint="Print those iterations that will be calculated" endparam switch: type="embossed-mandelbrot-rrl" ac=ac as=as bailout=bailout bc=bc block_size=block_size block_trap=block_trap bs=bs curvecenter=curvecenter do_first=do_first dolast=dolast julparam=julparam lightangle=lightangle maxwidth=maxwidth minwidth=minwidth modbase=modbase modtype=modtype parttype=parttype power=power print_do_this=print_do_this rangewidth=rangewidth rfreq=rfreq rotd=rotd rphase=rphase scale=scale sections=sections sizefac=sizefac vary_width=vary_width } comment { Relativistic Addition These formulas are based on the addition of velocities according to special relativity. If you took physics, you probably learned the Galilean method of adding velocities. Say you're riding in a bus at 60 mph and you roll a bowling ball forward at 20 mph relative to you. Relative to an observer outside of the bus, the ball has its own velocity plus that of the bus, so would be moving at 80 mph. This is fine for most situations, but falls apart when things move very quickly. If that same bus were moving along at a speedy 600,000,000 mph (about 90% of the speed of light) and you managed to roll the ball at 200,000,000 mph relative to you, then the Galilean method would have the ball moving at 800,000,000 mph r elative to an observer outside of the bus, or about 20% faster than the speed of light. According to Einstein's theory of relativity, nothing can move faster than light. To accommodate this, velocities don't add regularly, but through what is known as a Lorentzian transformation. Using such a transformation here, the bowling ball would be moving at 94% of the speed of light, relative to the outside observer. Under relativistic addition, if two motions are added and both are slower than the speed of light, then the sum will always be slower as well. If one motion is at the speed of the light, then the sum will be, as well. This can be applied to the standard Mandelbrot/Julia formula z = z^n + c by considering each of the terms on the right side of the equation to be a velocity and adding them relativistically. Then, if they are both smaller in magnitude than the "speed of light" parameter, the result will be as well. This results in some very interesting warping of the fractal for small light speeds. As the speed parameter increases, the warping decreases. The other major aspect of this is the choice of observer. In the case of two independent motions, the observer can be moving with either particle or independent of both. The sum of the two velocities will depend on the frame of reference of the observer. In these formulas, there are choices for that frame of reference. There is also a simplification of the relativistic equation that is used in the case of collinear motion (both motions in the same direction). If you choose that method, then the assumed motion can be in the direction of c, of z^n, or in some independent direction. } relativistic-addition-julia { ; Kerry Mitchell 03aug2007 ; ; Replace the standard addition with relativistic addition ; both addends are treated like velocities ; use the full-blown equation found in wikipedia ; ; http://en.wikipedia.org/wiki/Velocity-addition_formula ; init: complex c=@julparam complex v1=(0,0) complex v2=(0,0) complex w=(0,0) complex z=#pixel float fac1=0 float fac2=0 float fac3=0 float recip_speed2=1/sqr(@speed) loop: w=z^@power if(@vtype=="c frame") v1=c v2=w fac1=1+(real(v1)*real(v2)+imag(v1)*imag(v2))*recip_speed2 fac2=recip_speed2*(1+sqrt(1-|v1|*recip_speed2)) fac3=real(v1)*imag(v2)-real(v2)*imag(v1) z=(v1+v2)/fac1+fac2*(imag(v1)*fac3-flip(real(v1)*fac3))/fac1 elseif(@vtype=="z frame") v2=c v1=w fac1=1+(real(v1)*real(v2)+imag(v1)*imag(v2))*recip_speed2 fac2=recip_speed2*(1+sqrt(1-|v1|*recip_speed2)) fac3=real(v1)*imag(v2)-real(v2)*imag(v1) z=(v1+v2)/fac1+fac2*(imag(v1)*fac3-flip(real(v1)*fac3))/fac1 elseif(@vtype=="collinear c") if(cabs(c)==0) z=w else v1par=c v1perp=0 v2par=(real(w)*real(c)+imag(w)*imag(c))/|c|*c v2perp=w-v2par z=(v1par+v2par)/(1+(real(v1par)*real(v2par)+imag(v1par)*imag(v2par))*\ recip_speed2)+v1perp+v2perp endif elseif(@vtype=="collinear z") if(cabs(w)==0) z=c else v1par=w v1perp=0 v2par=(real(c)*real(w)+imag(c)*imag(w))/|w|*w v2perp=c-v2par z=(v1par+v2par)/(1+(real(v1par)*real(v2par)+imag(v1par)*imag(v2par))*\ recip_speed2)+v1perp+v2perp endif elseif(@vtype=="collinear observer") if(cabs(@observer)==0) z=w+c else v1par=(real(w)*real(@observer)+imag(w)*imag(@observer))/|@observer|*@observer v1perp=w-v1par v2par=(real(c)*real(@observer)+imag(c)*imag(@observer))/|@observer|*@observer v2perp=c-v2par z=(v1par+v2par)/(1+(real(v1par)*real(v2par)+imag(v1par)*imag(v2par))*\ recip_speed2)+v1perp+v2perp endif endif bailout: |z|<@bailout default: title="Relativistic Addition Julia" periodicity=0 complex param julparam caption="Julia parameter" default=(0,1) endparam complex param power caption="power" default=2 endparam float param speed caption="light speed" default=3 endparam float param bailout caption="bailout" default=10 endparam param vtype caption="reference frame" default=0 enum="c frame" "z frame" "collinear c" "collinear z" "collinear observer" endparam complex param observer caption="observer's frame" default=(1,1) visible=(@vtype=="collinear observer") endparam switch: type="relativistic-addition-mandelbrot" power=power speed=speed bailout=bailout vtype=vtype observer=observer } relativistic-addition-mandelbrot { ; Kerry Mitchell 03aug2007 ; ; Replace the standard addition with relativistic addition ; both addends are treated like velocities ; use the full-blown equation found in wikipedia ; ; http://en.wikipedia.org/wiki/Velocity-addition_formula ; init: complex c=#pixel complex v1=(0,0) complex v2=(0,0) complex w=(0,0) complex z=@manparam float fac1=0 float fac2=0 float fac3=0 float recip_speed2=1/sqr(@speed) loop: w=z^@power if(@vtype=="c frame") v1=c v2=w fac1=1+(real(v1)*real(v2)+imag(v1)*imag(v2))*recip_speed2 fac2=recip_speed2*(1+sqrt(1-|v1|*recip_speed2)) fac3=real(v1)*imag(v2)-real(v2)*imag(v1) z=(v1+v2)/fac1+fac2*(imag(v1)*fac3-flip(real(v1)*fac3))/fac1 elseif(@vtype=="z frame") v2=c v1=w fac1=1+(real(v1)*real(v2)+imag(v1)*imag(v2))*recip_speed2 fac2=recip_speed2*(1+sqrt(1-|v1|*recip_speed2)) fac3=real(v1)*imag(v2)-real(v2)*imag(v1) z=(v1+v2)/fac1+fac2*(imag(v1)*fac3-flip(real(v1)*fac3))/fac1 elseif(@vtype=="collinear c") if(cabs(c)==0) z=w else v1par=c v1perp=0 v2par=(real(w)*real(c)+imag(w)*imag(c))/|c|*c v2perp=w-v2par z=(v1par+v2par)/(1+(real(v1par)*real(v2par)+imag(v1par)*imag(v2par))*\ recip_speed2)+v1perp+v2perp endif elseif(@vtype=="collinear z") if(cabs(w)==0) z=c else v1par=w v1perp=0 v2par=(real(c)*real(w)+imag(c)*imag(w))/|w|*w v2perp=c-v2par z=(v1par+v2par)/(1+(real(v1par)*real(v2par)+imag(v1par)*imag(v2par))*\ recip_speed2)+v1perp+v2perp endif elseif(@vtype=="collinear observer") if(cabs(@observer)==0) z=w+c else v1par=(real(w)*real(@observer)+imag(w)*imag(@observer))/|@observer|*@observer v1perp=w-v1par v2par=(real(c)*real(@observer)+imag(c)*imag(@observer))/|@observer|*@observer v2perp=c-v2par z=(v1par+v2par)/(1+(real(v1par)*real(v2par)+imag(v1par)*imag(v2par))*\ recip_speed2)+v1perp+v2perp endif endif bailout: |z|<@bailout default: title="Relativistic Addition Mandelbrot" periodicity=0 complex param manparam caption="initial z" default=0 endparam complex param power caption="power" default=2 endparam float param speed caption="light speed" default=3 endparam float param bailout caption="bailout" default=10 endparam param vtype caption="reference frame" default=0 enum="c frame" "z frame" "collinear c" "collinear z" "collinear observer" endparam complex param observer caption="observer's frame" default=(1,1) visible=(@vtype=="collinear observer") endparam switch: type="relativistic-addition-julia" julparam=#pixel power=power speed=speed bailout=bailout vtype=vtype observer=observer } burning-ship-mandelbrot { ; Kerry Mitchell 17jun2008 ; ; Based on the algorithm by Michael Michelitsch and Otto Rossler ; and on the UF implementation written by Pasi Piitulainen. ; ; Generalized to allow for functions, powers, and weights ; for both the x- and y-parts of z. The default parameters give the ; standard 'burning ship' fractal. ; init: complex c=#pixel complex z=@initial_z float zx=0 float zy=0 loop: zx=abs(real(@xfunction(real(z))))^@xpower zy=abs(real(@yfunction(imag(z))))^@ypower z=(@xweight*zx+@yweight*flip(zy))^@zpower+c bailout: |z|<=@bailout default: title="Burning Ship Mandelbrot" ; ; general parameters ; heading caption="General" endheading complex param initial_z caption="initial z" default=(0,0) endparam float param bailout caption="bailout" default=1000 endparam complex param zpower caption="power" default=2 endparam ; ; x parameters ; heading caption="X" endheading float param xpower caption="power" default=1 endparam func xfunction caption="function" default=ident() endfunc complex param xweight caption="weight" default=1 endparam ; ; y parameters ; heading caption="Y" endheading float param ypower caption="power" default=1 endparam func yfunction caption="function" default=ident() endfunc complex param yweight caption="weight" default=1 endparam switch: type="burning-ship-julia" julparam=#pixel bailout=bailout zpower=zpower xpower=xpower xfunction=xfunction xweight=xweight ypower=ypower yfunction=yfunction yweight=yweight } burning-ship-julia { ; Kerry Mitchell 17jun2008 ; ; Based on the algorithm by Michael Michelitsch and Otto Rossler ; and on the UF implementation written by Pasi Piitulainen. ; ; Generalized to allow for functions, powers, and weights ; for both the x- and y-parts of z. The default parameters give the ; standard 'burning ship' fractal. ; init: complex c=@julparam complex z=#pixel float zx=0 float zy=0 loop: zx=abs(real(@xfunction(real(z))))^@xpower zy=abs(real(@yfunction(imag(z))))^@ypower z=(@xweight*zx+@yweight*flip(zy))^@zpower+c bailout: |z|<=@bailout default: title="Burning Ship Julia" ; ; general parameters ; heading caption="General" endheading complex param julparam caption="Julia parameter" default=(0,0) endparam float param bailout caption="bailout" default=1000 endparam complex param zpower caption="power" default=2 endparam ; ; x parameters ; heading caption="X" endheading float param xpower caption="power" default=1 endparam func xfunction caption="function" default=ident() endfunc complex param xweight caption="weight" default=1 endparam ; ; y parameters ; heading caption="Y" endheading float param ypower caption="power" default=1 endparam func yfunction caption="function" default=ident() endfunc complex param yweight caption="weight" default=1 endparam switch: type="burning-ship-mandelbrot" bailout=bailout zpower=zpower xpower=xpower xfunction=xfunction xweight=xweight ypower=ypower yfunction=yfunction yweight=yweight } relaxed-newton-halley { ; Kerry Mitchell 22dec08 ; ; Newton's method, generalized to include Halley's method and two relaxation ; factors. "Solves" z^n = c and exp(z*c) = log(z)/c ; global: $define debug complex relaxfac1=(0,0) complex relaxfac2=@relaxrect2 complex weighthalley=(0,0) complex weightnewton=(0,0) ; ; set up relaxation coefficient 1 ; if(@relaxcoord=="rectangular") relaxfac1=@relaxrect elseif(@relaxcoord=="polar, degrees") gt=@relaxdegree*#pi/180 relaxfac1=@relaxcenter+@relaxradius*(cos(gt)+flip(sin(gt))) elseif(@relaxcoord=="polar, radians") gt=@relaxradian relaxfac1=@relaxcenter+@relaxradius*(cos(gt)+flip(sin(gt))) elseif(@relaxcoord=="polar, turns") if(@pifac==0) gt=@relaxm/@relaxn*2*#pi else gt=@relaxm/@relaxn*2*@pifac endif relaxfac1=@relaxcenter+@relaxradius*(cos(gt)+flip(sin(gt))) endif if(@printrelax) print("Relaxation 1: ",relaxfac1) print("Relaxation 2: ",relaxfac2) endif ; ; weights for weighted solution ; weightnewton=@weightn/(@weighth+@weightn) weighthalley=1-weightnewton init: complex c=(0,0) complex dz=(0,0) complex dzh=(0,0) complex dzn=(0,0) complex f=(0,0) complex fdoubleprime=(0,0) complex fprime=(0,0) complex powerm1=@power-1 complex relaxation1=(0,0) complex relaxation2=(0,0) complex znewton=(0,0) int iterhalley=0 int iternewton=0 ; ; initialize #pixel, c, z ; if(@pixeltype=="initial z") znewton=#pixel c=@root relaxation1=relaxfac1 relaxation2=relaxfac2 elseif(@pixeltype=="c") znewton=@initialz c=#pixel relaxation1=relaxfac1 relaxation2=relaxfac2 elseif(@pixeltype=="relaxation 1") znewton=@initialz c=@root relaxation1=#pixel relaxation2=relaxfac2 elseif(@pixeltype=="relaxation 2") znewton=@initialz c=@root relaxation1=relaxfac1 relaxation2=#pixel elseif(@pixeltype=="relaxation 1 & 2") znewton=@initialz c=@root relaxation1=@relaxfn1(#pixel) relaxation2=@relaxfn2(#pixel) endif ; ; toggles for switched solution ; if(@solntype=="switch-Newton") iternewton=1 elseif(@solntype=="switch-Halley") iterhalley=1 endif loop: ; ; toggle switched solution ; iternewton=1-iternewton iterhalley=1-iterhalley ; ; compute function and derivatives ; if(@eqntype=="roots of c") ; ; optimizations for low-order power functions ; if(@power==(2,0)) fdoubleprime=2 fprime=2*znewton f=sqr(znewton)-c elseif(@power==(3,0)) fdoubleprime=6*znewton fprime=sqr(znewton) f=znewton*fprime-c fprime=3*fprime elseif(@power==(4,0)) fdoubleprime=sqr(znewton) fprime=4*znewton*fdoubleprime f=sqr(fdoubleprime)-c fdoubleprime=12*fdoubleprime else fprime=znewton^powerm1 f=znewton*fprime-c fdoubleprime=fprime/znewton*@power*powerm1 fprime=@power*fprime endif elseif(@eqntype=="exp(cz) = log(z)/c") fprime=exp(c*znewton) fdoubleprime=sqr(c)*fprime+1/sqr(znewton)/c f=fprime-log(znewton)/c fprime=c*fprime-1/(c*znewton) endif ; ; generate next iterate ; if(@solntype=="Newton") dz=-relaxation1*(f/fprime)^relaxation2 elseif(@solntype=="Halley") dz=2*relaxation1*f*fprime dz=dz/(relaxation2*f*fdoubleprime-2*sqr(fprime)) elseif(@solntype=="weighted") dzn=-relaxation1*f/fprime dzh=2*relaxation1*f*fprime dzh=dzh/(relaxation2*f*fdoubleprime-2*sqr(fprime)) dz=weightnewton*dzn+weighthalley*dzh elseif(@solntype=="switch-Newton") dzn=-relaxation1*f/fprime dzh=2*relaxation1*f*fprime dzh=dzh/(relaxation2*f*fdoubleprime-2*sqr(fprime)) dz=iternewton*dzn+iterhalley*dzh elseif(@solntype=="switch-Halley") dzn=-relaxation1*f/fprime dzh=2*relaxation1*f*fprime dzh=dzh/(relaxation2*f*fdoubleprime-2*sqr(fprime)) dz=iternewton*dzn+iterhalley*dzh endif znewton=znewton+dz ; ; update z variable ; if(@ztype=="iterate") z=znewton elseif(@ztype=="change") z=dz elseif(@ztype=="function") z=f elseif(@ztype=="1st derivative") z=fprime elseif(@ztype=="2nd derivative") z=fdoubleprime endif bailout: |dz|>@bailin default: title="Relaxed Newton/Halley" periodicity=0 ; ; general ; heading caption="General" endheading float param bailin caption="bailin" default=1e-6 min=0 hint="Make small" endparam param pixeltype caption="pixel type" default=0 enum="initial z" "c" "relaxation 1" "relaxation 2" \ "relaxation 1 & 2" endparam complex param initialz caption="initial z" default=(2,3) visible=(@pixeltype!="initial z") endparam complex param root caption="c" default=(1,0) visible=(@pixeltype!="c") endparam param ztype caption="z type" default=0 enum="iterate" "change" "function" "1st derivative"\ "2nd derivative" endparam ; ; solution method ; heading caption="Solution" endheading param eqntype caption="equation to solve" default=0 enum="roots of c" "exp(cz) = log(z)/c" endparam complex param power caption="exponent" default=(4,0) visible=(@eqntype=="roots of c") endparam param solntype caption="solution type" default=0 enum="Newton" "Halley" "weighted" "switch-Newton" "switch-Halley" endparam complex param weightn caption="Newton weight" default=(1,0) visible=(@solntype=="weighted") endparam complex param weighth caption="Halley weight" default=(0,1) visible=(@solntype=="weighted") endparam ; ; relaxation parameters ; heading caption="Relaxation" endheading param relaxcoord caption="#1 coord. type" default=0 enum="rectangular" "polar, degrees" "polar, radians"\ "polar, turns" visible=((@pixeltype!="relaxation 1")&&\ (@pixeltype!="relaxation 1 & 2")) endparam ; ; relaxation 1: rectangular ; complex param relaxrect caption="relaxation 1" default=(1,0) visible=(((@pixeltype!="relaxation 1")&&\ (@pixeltype!="relaxation 1 & 2"))&&(@relaxcoord=="rectangular")) endparam ; ; relaxation 1: polar ; complex param relaxcenter caption="center" default=(1,0) visible=(((@pixeltype!="relaxation 1")&&\ (@pixeltype!="relaxation 1 & 2"))&&\ (@relaxcoord!="rectangular")) endparam float param relaxradius caption="radius" default=1 visible=(((@pixeltype!="relaxation 1")&&\ (@pixeltype!="relaxation 1 & 2"))&&\ (@relaxcoord!="rectangular")) endparam float param relaxdegree caption="angle, degrees" default=60 visible=(((@pixeltype!="relaxation 1")&&\ (@pixeltype!="relaxation 1 & 2"))&&\ (@relaxcoord=="polar, degrees")) endparam float param relaxradian caption="angle, radians" default=1 visible=(((@pixeltype!="relaxation 1")&&\ (@pixeltype!="relaxation 1 & 2"))&&\ (@relaxcoord=="polar, radians")) endparam float param relaxm caption="m of m/n turns" default=1 visible=(((@pixeltype!="relaxation 1")&&\ (@pixeltype!="relaxation 1 & 2"))&&\ (@relaxcoord=="polar, turns")) endparam float param relaxn caption="n of m/n turns" default=3 visible=(((@pixeltype!="relaxation 1")&&\ (@pixeltype!="relaxation 1 & 2"))&&\ (@relaxcoord=="polar, turns")) endparam float param pifac caption="pi factor" default=0 hint="Use 0 for machine pi" visible=(((@pixeltype!="relaxation 1")&&\ (@pixeltype!="relaxation 1 & 2"))&&\ (@relaxcoord=="polar, turns")) endparam ; ; relaxation 2: rectangular only ; complex param relaxrect2 caption="relaxation 2" default=(1,0) visible=((@pixeltype!="relaxation 2")&&\ (@pixeltype!="relaxation 1 & 2")) endparam ; ; relaxation 1 & 2: modifying functions ; func relaxfn1 caption="relaxation fn 1" default=ident() visible=(@pixeltype=="relaxation 1 & 2") endfunc func relaxfn2 caption="relaxation fn 2" default=ident() visible=(@pixeltype=="relaxation 1 & 2") endfunc ; ; print relaxations ; bool param printrelax caption="print relaxation" default=false visible=(@pixeltype!="relaxation 1 & 2") endparam } unit-vector-tweak-mandelbrot { ; Kerry Mitchell 30dec2011 ; ; Add a tweak of the unit vector for z at each iteation. ; Either add before the z^power+c step, after, or both. ; ; Based on Asdam's Mandelbrot variation, posted to Fractal Forums 12/30/2011 ; http://www.fractalforums.com/new-theories-and-research/ ; is-there-anything-novel-left-to-do-in-m-like-escape-time-fractals-in-2d/ ; msg38948/#newinit: ; complex c=#pixel complex unit_vector=(0,0) complex z=@initial_z loop: if((@tweak_type=="before")||(@tweak_type=="both")) if(cabs(z)==0) unit_vector=1 else unit_vector=z/cabs(z) endif z=z+@fac_pre*@func_pre(unit_vector) endif z=z^@power+c if((@tweak_type=="after")||(@tweak_type=="both")) if(cabs(z)==0) unit_vector=1 else unit_vector=z/cabs(z) endif z=z+@fac_post*@func_post(unit_vector) endif bailout: |z|<@bailout default: title="Unit Vector Tweak Mandelbrot" complex param initial_z caption="initial z" default=(0,0) endparam complex param power caption="power" default=2 endparam float param bailout caption="bailout" default=1000 endparam param tweak_type caption="tweak type" default=1 enum="before" "after" "both" endparam complex param fac_pre caption="before factor" default=(-0.7,0.1) visible=((@tweak_type=="before")||(@tweak_type=="both")) endparam func func_pre caption="before function" default=cos() visible=((@tweak_type=="before")||(@tweak_type=="both")) endfunc complex param fac_post caption="after factor" default=0.26 visible=((@tweak_type=="after")||(@tweak_type=="both")) endparam func func_post caption="after function" default=ident() visible=((@tweak_type=="after")||(@tweak_type=="both")) endfunc switch: type="unit-vector-tweak-julia" julparam=#pixel power=power bailout=bailout tweak_type=tweak_type fac_pre=fac_pre func_pre=func_pre fac_post=fac_post func_post=func_post } unit-vector-tweak-julia { ; Kerry Mitchell 30dec2011 ; ; Add a tweak of the unit vector for z at each iteation. ; Either add before the z^power+c step, after, or both. ; ; Based on Asdam's Mandelbrot variation, posted to Fractal Forums 12/30/2011 ; http://www.fractalforums.com/new-theories-and-research/ ; is-there-anything-novel-left-to-do-in-m-like-escape-time-fractals-in-2d/ ; msg38948/#newinit: ; complex c=@julparam complex unit_vector=(0,0) complex z=#pixel loop: if((@tweak_type=="before")||(@tweak_type=="both")) if(cabs(z)==0) unit_vector=1 else unit_vector=z/cabs(z) endif z=z+@fac_pre*@func_pre(unit_vector) endif z=z^@power+c if((@tweak_type=="after")||(@tweak_type=="both")) if(cabs(z)==0) unit_vector=1 else unit_vector=z/cabs(z) endif z=z+@fac_post*@func_post(unit_vector) endif bailout: |z|<@bailout default: title="Unit Vector Tweak Julia" complex param julparam caption="Julia seed" default=(0.1,1) endparam complex param power caption="power" default=2 endparam float param bailout caption="bailout" default=1000 endparam param tweak_type caption="tweak type" default=1 enum="before" "after" "both" endparam complex param fac_pre caption="before factor" default=(-0.7,0.1) visible=((@tweak_type=="before")||(@tweak_type=="both")) endparam func func_pre caption="before function" default=cos() visible=((@tweak_type=="before")||(@tweak_type=="both")) endfunc complex param fac_post caption="after factor" default=0.26 visible=((@tweak_type=="after")||(@tweak_type=="both")) endparam func func_post caption="after function" default=ident() visible=((@tweak_type=="after")||(@tweak_type=="both")) endfunc switch: type="unit-vector-tweak-mandelbrot" power=power bailout=bailout tweak_type=tweak_type fac_pre=fac_pre func_pre=func_pre fac_post=fac_post func_post=func_post } partial-cz-mandelbrot { ; Kerry Mitchell 29apr2012 ; ; Tweaks z before and/or after iteration, as well as modifying ; how c is added in z^n + c. ; init: complex c=#pixel complex partz=(0,0) complex z=(0,0) ; ; initialize z ; if(@manparam==(0,0)) z=c else z=@manparam endif loop: ; ; determine part of z ; if(@parttype=="real") partz=real(z) elseif(@parttype=="imag") partz=imag(z) elseif(@parttype=="z") partz=z elseif(@parttype=="magnitude") partz=cabs(z) elseif(@parttype=="real/mag") partz=real(z)/cabs(z) elseif(@parttype=="imag/mag") partz=imag(z)/cabs(z) elseif(@parttype=="z/mag") partz=z/cabs(z) elseif(@parttype=="angle") partz=atan2(z) elseif(@parttype=="real/imag") partz=real(z)/imag(z) endif ; ; apply modifying function ; partz=@partscale*@partfunc(partz) ; ; apply partz to z^n ; if(@ztype=="add before") z=z+partz z=z^@power elseif(@ztype=="add after") z=z^@power z=z+partz elseif(@ztype=="add both") z=z+partz z=z^@power z=z+partz elseif(@ztype=="add & subtract") z=z+partz z=z^@power z=z-partz elseif(@ztype=="multiply before") z=z*partz z=z^@power elseif(@ztype=="multiply after") z=z^@power z=z*partz elseif(@ztype=="multiply both") z=z*partz z=z^@power z=z*partz elseif(@ztype=="multiply & divide") z=z*partz z=z^@power z=z/partz else ; none z=z^@power endif ; ; add jacked-up c ; if(@ctype=="add") z=z+c+partz elseif(@ctype=="subtract") z=z+c-partz elseif(@ctype=="multiply") z=z+c*partz elseif(@ctype=="divide") z=z+c/partz elseif(@ctype=="power") z=z+c^partz elseif(@ctype=="root") z=z+c^(1/partz) else ; none z=z+c endif bailout: |z|<@bailout default: title="Partial cz Mandelbrot" heading text="Tweaks z before and/or after iteration, as well as modifying \ how c is added in z^n + c." endheading complex param manparam caption="initial z" default=(0,0) endparam complex param power caption="power" default=2 endparam float param bailout caption="bailout" default=1000 endparam param parttype caption="z part type" enum="z" "real" "imag" "magnitude" "angle"\ "real/mag" "imag/mag" "z/mag" "real/imag" default=5 endparam param ztype caption="z tweak type" enum="none" "add before" "add after" "add both" "add & subtract"\ "multiply before" "multiply after" "multiply both" "multiply & divide" default=1 endparam param ctype caption="c tweak type" enum="none" "add" "subtract" "multiply" "divide" "power" "root" default=2 endparam complex param partscale caption="amount" default=0.1 endparam func partfunc caption="modifying function" default=ident() endfunc switch: type="partial-cz-julia" julparam=pixel power=power bailout=bailout parttype=parttype ztype=ztype ctype=ctype partscale=partscale partfunc=partfunc } partial-cz-julia { ; Kerry Mitchell 29apr2012 ; ; Tweaks z before and/or after iteration, as well as modifying ; how c is added in z^n + c. ; init: complex c=@julparam complex partz=(0,0) complex z=#pixel loop: ; ; determine part of z ; if(@parttype=="real") partz=real(z) elseif(@parttype=="imag") partz=imag(z) elseif(@parttype=="z") partz=z elseif(@parttype=="magnitude") partz=cabs(z) elseif(@parttype=="real/mag") partz=real(z)/cabs(z) elseif(@parttype=="imag/mag") partz=imag(z)/cabs(z) elseif(@parttype=="z/mag") partz=z/cabs(z) elseif(@parttype=="angle") partz=atan2(z) elseif(@parttype=="real/imag") partz=real(z)/imag(z) endif ; ; apply modifying function ; partz=@partscale*@partfunc(partz) ; ; apply partz to z^n ; if(@ztype=="add before") z=z+partz z=z^@power elseif(@ztype=="add after") z=z^@power z=z+partz elseif(@ztype=="add both") z=z+partz z=z^@power z=z+partz elseif(@ztype=="add & subtract") z=z+partz z=z^@power z=z-partz elseif(@ztype=="multiply before") z=z*partz z=z^@power elseif(@ztype=="multiply after") z=z^@power z=z*partz elseif(@ztype=="multiply both") z=z*partz z=z^@power z=z*partz elseif(@ztype=="multiply & divide") z=z*partz z=z^@power z=z/partz else ; none z=z^@power endif ; ; add jacked-up c ; if(@ctype=="add") z=z+c+partz elseif(@ctype=="subtract") z=z+c-partz elseif(@ctype=="multiply") z=z+c*partz elseif(@ctype=="divide") z=z+c/partz elseif(@ctype=="power") z=z+c^partz elseif(@ctype=="root") z=z+c^(1/partz) else ; none z=z+c endif bailout: |z|<@bailout default: title="Partial cz Julia" heading text="Tweaks z before and/or after iteration, as well as modifying \ how c is added in z^n + c." endheading complex param julparam caption="Julia parameter" default=(0,1) endparam complex param power caption="power" default=2 endparam float param bailout caption="bailout" default=1000 endparam param parttype caption="z part type" enum="z" "real" "imag" "magnitude" "angle"\ "real/mag" "imag/mag" "z/mag" "real/imag" default=5 endparam param ztype caption="z tweak type" enum="none" "add before" "add after" "add both" "add & subtract"\ "multiply before" "multiply after" "multiply both" "multiply & divide" default=1 endparam param ctype caption="c tweak type" enum="none" "add" "subtract" "multiply" "divide" "power" "root" default=2 endparam complex param partscale caption="amount" default=0.1 endparam func partfunc caption="modifying function" default=ident() endfunc switch: type="partial-cz-mandelbrot" power=power bailout=bailout parttype=parttype ztype=ztype ctype=ctype partscale=partscale partfunc=partfunc } alternating-functions { ; Kerry Mitchell 02Jul2013 init: complex dz=(0,0) complex z=(0,0) complex xnew=(0,0) complex xold=(0,0) complex ynew=(0,0) complex yold=(0,0) complex znew=(0,0) complex zold=(0,0) float r=0 float sincos=0 int funtype=0 int iter=0 int picker=0 int seed=@initial_seed ; if(@initz_type=="pixel") zold=#pixel else zold=@initial_z endif iter=-1 loop: iter=iter+1 ; ; choose function ; ; 1 function ; if(@nfunction=="1") if(@fn1=="Mandelbrot 1") funtype=1 elseif(@fn1=="Julia 1") funtype=2 elseif(@fn1=="Newton M 1") funtype=3 elseif(@fn1=="Newton J 1") funtype=4 elseif(@fn1=="Popcorn C 1") funtype=5 elseif(@fn1=="Popcorn R 1") funtype=6 elseif(@fn1=="Mandelbrot 2") funtype=7 elseif(@fn1=="Julia 2") funtype=8 elseif(@fn1=="Newton M 2") funtype=9 elseif(@fn1=="Newton J 2") funtype=10 elseif(@fn1=="Popcorn C 2") funtype=11 elseif(@fn1=="Popcorn R 2") funtype=12 endif ; ; 2 functions ; elseif(@nfunction=="2") if(@oscillator_type=="ramp") picker=iter%2 elseif(@oscillator_type=="sine") sincos=(1+sin(iter-0.125))/2 picker=trunc(sincos*2) elseif(@oscillator_type=="cosine") sincos=(1+cos(iter+0.125))/2 picker=trunc(sincos*2) elseif(@oscillator_type=="random msb") seed=random(seed) sincos=abs(seed/#randomrange) picker=trunc(sincos*2) elseif(@oscillator_type=="random lsb") seed=random(seed) picker=abs(seed)%2 endif picker=picker+1 if(picker==1) if(@fn1=="Mandelbrot 1") funtype=1 elseif(@fn1=="Julia 1") funtype=2 elseif(@fn1=="Newton M 1") funtype=3 elseif(@fn1=="Newton J 1") funtype=4 elseif(@fn1=="Popcorn C 1") funtype=5 elseif(@fn1=="Popcorn R 1") funtype=6 elseif(@fn1=="Mandelbrot 2") funtype=7 elseif(@fn1=="Julia 2") funtype=8 elseif(@fn1=="Newton M 2") funtype=9 elseif(@fn1=="Newton J 2") funtype=10 elseif(@fn1=="Popcorn C 2") funtype=11 elseif(@fn1=="Popcorn R 2") funtype=12 endif else if(@fn2=="Mandelbrot 1") funtype=1 elseif(@fn2=="Julia 1") funtype=2 elseif(@fn2=="Newton M 1") funtype=3 elseif(@fn2=="Newton J 1") funtype=4 elseif(@fn2=="Popcorn C 1") funtype=5 elseif(@fn2=="Popcorn R 1") funtype=6 elseif(@fn2=="Mandelbrot 2") funtype=7 elseif(@fn2=="Julia 2") funtype=8 elseif(@fn2=="Newton M 2") funtype=9 elseif(@fn2=="Newton J 2") funtype=10 elseif(@fn2=="Popcorn C 2") funtype=11 elseif(@fn2=="Popcorn R 2") funtype=12 endif endif ; ; 3 functions ; elseif(@nfunction=="3") if(@oscillator_type=="ramp") picker=iter%3 elseif(@oscillator_type=="sine") sincos=(1+sin(iter-0.125))/2 picker=trunc(sincos*3) elseif(@oscillator_type=="cosine") sincos=(1+cos(iter+0.125))/2 picker=trunc(sincos*3) elseif(@oscillator_type=="random msb") seed=random(seed) sincos=abs(seed/#randomrange) picker=trunc(sincos*3) elseif(@oscillator_type=="random lsb") seed=random(seed) picker=abs(seed)%3 endif picker=picker+1 if(picker==1) if(@fn1=="Mandelbrot 1") funtype=1 elseif(@fn1=="Julia 1") funtype=2 elseif(@fn1=="Newton M 1") funtype=3 elseif(@fn1=="Newton J 1") funtype=4 elseif(@fn1=="Popcorn C 1") funtype=5 elseif(@fn1=="Popcorn R 1") funtype=6 elseif(@fn1=="Mandelbrot 2") funtype=7 elseif(@fn1=="Julia 2") funtype=8 elseif(@fn1=="Newton M 2") funtype=9 elseif(@fn1=="Newton J 2") funtype=10 elseif(@fn1=="Popcorn C 2") funtype=11 elseif(@fn1=="Popcorn R 2") funtype=12 endif elseif(picker==2) if(@fn2=="Mandelbrot 1") funtype=1 elseif(@fn2=="Julia 1") funtype=2 elseif(@fn2=="Newton M 1") funtype=3 elseif(@fn2=="Newton J 1") funtype=4 elseif(@fn2=="Popcorn C 1") funtype=5 elseif(@fn2=="Popcorn R 1") funtype=6 elseif(@fn2=="Mandelbrot 2") funtype=7 elseif(@fn2=="Julia 2") funtype=8 elseif(@fn2=="Newton M 2") funtype=9 elseif(@fn2=="Newton J 2") funtype=10 elseif(@fn2=="Popcorn C 2") funtype=11 elseif(@fn2=="Popcorn R 2") funtype=12 endif else if(@fn3=="Mandelbrot 1") funtype=1 elseif(@fn3=="Julia 1") funtype=2 elseif(@fn3=="Newton M 1") funtype=3 elseif(@fn3=="Newton J 1") funtype=4 elseif(@fn3=="Popcorn C 1") funtype=5 elseif(@fn3=="Popcorn R 1") funtype=6 elseif(@fn3=="Mandelbrot 2") funtype=7 elseif(@fn3=="Julia 2") funtype=8 elseif(@fn3=="Newton M 2") funtype=9 elseif(@fn3=="Newton J 2") funtype=10 elseif(@fn3=="Popcorn C 2") funtype=11 elseif(@fn3=="Popcorn R 2") funtype=12 endif endif ; ; 4 functions ; elseif(@nfunction=="4") if(@oscillator_type=="ramp") picker=iter%4 elseif(@oscillator_type=="sine") sincos=(1+sin(iter-0.125))/2 picker=trunc(sincos*4) elseif(@oscillator_type=="cosine") sincos=(1+cos(iter+0.125))/2 picker=trunc(sincos*4) elseif(@oscillator_type=="random msb") seed=random(seed) sincos=abs(seed/#randomrange) picker=trunc(sincos*4) elseif(@oscillator_type=="random lsb") seed=random(seed) picker=abs(seed)%4 endif picker=picker+1 if(picker==1) if(@fn1=="Mandelbrot 1") funtype=1 elseif(@fn1=="Julia 1") funtype=2 elseif(@fn1=="Newton M 1") funtype=3 elseif(@fn1=="Newton J 1") funtype=4 elseif(@fn1=="Popcorn C 1") funtype=5 elseif(@fn1=="Popcorn R 1") funtype=6 elseif(@fn1=="Mandelbrot 2") funtype=7 elseif(@fn1=="Julia 2") funtype=8 elseif(@fn1=="Newton M 2") funtype=9 elseif(@fn1=="Newton J 2") funtype=10 elseif(@fn1=="Popcorn C 2") funtype=11 elseif(@fn1=="Popcorn R 2") funtype=12 endif elseif(picker==2) if(@fn2=="Mandelbrot 1") funtype=1 elseif(@fn2=="Julia 1") funtype=2 elseif(@fn2=="Newton M 1") funtype=3 elseif(@fn2=="Newton J 1") funtype=4 elseif(@fn2=="Popcorn C 1") funtype=5 elseif(@fn2=="Popcorn R 1") funtype=6 elseif(@fn2=="Mandelbrot 2") funtype=7 elseif(@fn2=="Julia 2") funtype=8 elseif(@fn2=="Newton M 2") funtype=9 elseif(@fn2=="Newton J 2") funtype=10 elseif(@fn2=="Popcorn C 2") funtype=11 elseif(@fn2=="Popcorn R 2") funtype=12 endif elseif(picker==3) if(@fn3=="Mandelbrot 1") funtype=1 elseif(@fn3=="Julia 1") funtype=2 elseif(@fn3=="Newton M 1") funtype=3 elseif(@fn3=="Newton J 1") funtype=4 elseif(@fn3=="Popcorn C 1") funtype=5 elseif(@fn3=="Popcorn R 1") funtype=6 elseif(@fn3=="Mandelbrot 2") funtype=7 elseif(@fn3=="Julia 2") funtype=8 elseif(@fn3=="Newton M 2") funtype=9 elseif(@fn3=="Newton J 2") funtype=10 elseif(@fn3=="Popcorn C 2") funtype=11 elseif(@fn3=="Popcorn R 2") funtype=12 endif else if(@fn4=="Mandelbrot 1") funtype=1 elseif(@fn4=="Julia 1") funtype=2 elseif(@fn4=="Newton M 1") funtype=3 elseif(@fn4=="Newton J 1") funtype=4 elseif(@fn4=="Popcorn C 1") funtype=5 elseif(@fn4=="Popcorn R 1") funtype=6 elseif(@fn4=="Mandelbrot 2") funtype=7 elseif(@fn4=="Julia 2") funtype=8 elseif(@fn4=="Newton M 2") funtype=9 elseif(@fn4=="Newton J 2") funtype=10 elseif(@fn4=="Popcorn C 2") funtype=11 elseif(@fn4=="Popcorn R 2") funtype=12 endif endif ; ; 5 functions ; elseif(@nfunction=="5") if(@oscillator_type=="ramp") picker=iter%5 elseif(@oscillator_type=="sine") sincos=(1+sin(iter-0.125))/2 picker=trunc(sincos*5) elseif(@oscillator_type=="cosine") sincos=(1+cos(iter+0.125))/2 picker=trunc(sincos*5) elseif(@oscillator_type=="random msb") seed=random(seed) sincos=abs(seed/#randomrange) picker=trunc(sincos*5) elseif(@oscillator_type=="random lsb") seed=random(seed) picker=abs(seed)%5 endif picker=picker+1 if(picker==1) if(@fn1=="Mandelbrot 1") funtype=1 elseif(@fn1=="Julia 1") funtype=2 elseif(@fn1=="Newton M 1") funtype=3 elseif(@fn1=="Newton J 1") funtype=4 elseif(@fn1=="Popcorn C 1") funtype=5 elseif(@fn1=="Popcorn R 1") funtype=6 elseif(@fn1=="Mandelbrot 2") funtype=7 elseif(@fn1=="Julia 2") funtype=8 elseif(@fn1=="Newton M 2") funtype=9 elseif(@fn1=="Newton J 2") funtype=10 elseif(@fn1=="Popcorn C 2") funtype=11 elseif(@fn1=="Popcorn R 2") funtype=12 endif elseif(picker==2) if(@fn2=="Mandelbrot 1") funtype=1 elseif(@fn2=="Julia 1") funtype=2 elseif(@fn2=="Newton M 1") funtype=3 elseif(@fn2=="Newton J 1") funtype=4 elseif(@fn2=="Popcorn C 1") funtype=5 elseif(@fn2=="Popcorn R 1") funtype=6 elseif(@fn2=="Mandelbrot 2") funtype=7 elseif(@fn2=="Julia 2") funtype=8 elseif(@fn2=="Newton M 2") funtype=9 elseif(@fn2=="Newton J 2") funtype=10 elseif(@fn2=="Popcorn C 2") funtype=11 elseif(@fn2=="Popcorn R 2") funtype=12 endif elseif(picker==3) if(@fn3=="Mandelbrot 1") funtype=1 elseif(@fn3=="Julia 1") funtype=2 elseif(@fn3=="Newton M 1") funtype=3 elseif(@fn3=="Newton J 1") funtype=4 elseif(@fn3=="Popcorn C 1") funtype=5 elseif(@fn3=="Popcorn R 1") funtype=6 elseif(@fn3=="Mandelbrot 2") funtype=7 elseif(@fn3=="Julia 2") funtype=8 elseif(@fn3=="Newton M 2") funtype=9 elseif(@fn3=="Newton J 2") funtype=10 elseif(@fn3=="Popcorn C 2") funtype=11 elseif(@fn3=="Popcorn R 2") funtype=12 endif elseif(picker==4) if(@fn4=="Mandelbrot 1") funtype=1 elseif(@fn4=="Julia 1") funtype=2 elseif(@fn4=="Newton M 1") funtype=3 elseif(@fn4=="Newton J 1") funtype=4 elseif(@fn4=="Popcorn C 1") funtype=5 elseif(@fn4=="Popcorn R 1") funtype=6 elseif(@fn4=="Mandelbrot 2") funtype=7 elseif(@fn4=="Julia 2") funtype=8 elseif(@fn4=="Newton M 2") funtype=9 elseif(@fn4=="Newton J 2") funtype=10 elseif(@fn4=="Popcorn C 2") funtype=11 elseif(@fn4=="Popcorn R 2") funtype=12 endif else if(@fn5=="Mandelbrot 1") funtype=1 elseif(@fn5=="Julia 1") funtype=2 elseif(@fn5=="Newton M 1") funtype=3 elseif(@fn5=="Newton J 1") funtype=4 elseif(@fn5=="Popcorn C 1") funtype=5 elseif(@fn5=="Popcorn R 1") funtype=6 elseif(@fn5=="Mandelbrot 2") funtype=7 elseif(@fn5=="Julia 2") funtype=8 elseif(@fn5=="Newton M 2") funtype=9 elseif(@fn5=="Newton J 2") funtype=10 elseif(@fn5=="Popcorn C 2") funtype=11 elseif(@fn5=="Popcorn R 2") funtype=12 endif endif ; ; 6 functions ; elseif(@nfunction=="6") if(@oscillator_type=="ramp") picker=iter%6 elseif(@oscillator_type=="sine") sincos=(1+sin(iter-0.125))/2 picker=trunc(sincos*6) elseif(@oscillator_type=="cosine") sincos=(1+cos(iter+0.125))/2 picker=trunc(sincos*6) elseif(@oscillator_type=="random msb") seed=random(seed) sincos=abs(seed/#randomrange) picker=trunc(sincos*6) elseif(@oscillator_type=="random lsb") seed=random(seed) picker=abs(seed)%6 endif picker=picker+1 if(picker==1) if(@fn1=="Mandelbrot 1") funtype=1 elseif(@fn1=="Julia 1") funtype=2 elseif(@fn1=="Newton M 1") funtype=3 elseif(@fn1=="Newton J 1") funtype=4 elseif(@fn1=="Popcorn C 1") funtype=5 elseif(@fn1=="Popcorn R 1") funtype=6 elseif(@fn1=="Mandelbrot 2") funtype=7 elseif(@fn1=="Julia 2") funtype=8 elseif(@fn1=="Newton M 2") funtype=9 elseif(@fn1=="Newton J 2") funtype=10 elseif(@fn1=="Popcorn C 2") funtype=11 elseif(@fn1=="Popcorn R 2") funtype=12 endif elseif(picker==2) if(@fn2=="Mandelbrot 1") funtype=1 elseif(@fn2=="Julia 1") funtype=2 elseif(@fn2=="Newton M 1") funtype=3 elseif(@fn2=="Newton J 1") funtype=4 elseif(@fn2=="Popcorn C 1") funtype=5 elseif(@fn2=="Popcorn R 1") funtype=6 elseif(@fn2=="Mandelbrot 2") funtype=7 elseif(@fn2=="Julia 2") funtype=8 elseif(@fn2=="Newton M 2") funtype=9 elseif(@fn2=="Newton J 2") funtype=10 elseif(@fn2=="Popcorn C 2") funtype=11 elseif(@fn2=="Popcorn R 2") funtype=12 endif elseif(picker==3) if(@fn3=="Mandelbrot 1") funtype=1 elseif(@fn3=="Julia 1") funtype=2 elseif(@fn3=="Newton M 1") funtype=3 elseif(@fn3=="Newton J 1") funtype=4 elseif(@fn3=="Popcorn C 1") funtype=5 elseif(@fn3=="Popcorn R 1") funtype=6 elseif(@fn3=="Mandelbrot 2") funtype=7 elseif(@fn3=="Julia 2") funtype=8 elseif(@fn3=="Newton M 2") funtype=9 elseif(@fn3=="Newton J 2") funtype=10 elseif(@fn3=="Popcorn C 2") funtype=11 elseif(@fn3=="Popcorn R 2") funtype=12 endif elseif(picker==4) if(@fn4=="Mandelbrot 1") funtype=1 elseif(@fn4=="Julia 1") funtype=2 elseif(@fn4=="Newton M 1") funtype=3 elseif(@fn4=="Newton J 1") funtype=4 elseif(@fn4=="Popcorn C 1") funtype=5 elseif(@fn4=="Popcorn R 1") funtype=6 elseif(@fn4=="Mandelbrot 2") funtype=7 elseif(@fn4=="Julia 2") funtype=8 elseif(@fn4=="Newton M 2") funtype=9 elseif(@fn4=="Newton J 2") funtype=10 elseif(@fn4=="Popcorn C 2") funtype=11 elseif(@fn4=="Popcorn R 2") funtype=12 endif elseif(picker==5) if(@fn5=="Mandelbrot 1") funtype=1 elseif(@fn5=="Julia 1") funtype=2 elseif(@fn5=="Newton M 1") funtype=3 elseif(@fn5=="Newton J 1") funtype=4 elseif(@fn5=="Popcorn C 1") funtype=5 elseif(@fn5=="Popcorn R 1") funtype=6 elseif(@fn5=="Mandelbrot 2") funtype=7 elseif(@fn5=="Julia 2") funtype=8 elseif(@fn5=="Newton M 2") funtype=9 elseif(@fn5=="Newton J 2") funtype=10 elseif(@fn5=="Popcorn C 2") funtype=11 elseif(@fn5=="Popcorn R 2") funtype=12 endif else if(@fn6=="Mandelbrot 1") funtype=1 elseif(@fn6=="Julia 1") funtype=2 elseif(@fn6=="Newton M 1") funtype=3 elseif(@fn6=="Newton J 1") funtype=4 elseif(@fn6=="Popcorn C 1") funtype=5 elseif(@fn6=="Popcorn R 1") funtype=6 elseif(@fn6=="Mandelbrot 2") funtype=7 elseif(@fn6=="Julia 2") funtype=8 elseif(@fn6=="Newton M 2") funtype=9 elseif(@fn6=="Newton J 2") funtype=10 elseif(@fn6=="Popcorn C 2") funtype=11 elseif(@fn6=="Popcorn R 2") funtype=12 endif endif endif ; ; iterate ; if(funtype==1) ; Mandelbrot 1 znew=(1-@m1weight)*zold+@m1weight*(zold^@m1power+#pixel) r=|znew| elseif(funtype==2) ; Julia 1 znew=(1-@j1weight)*zold+@j1weight*(zold^@j1power+@j1param) r=|znew| elseif(funtype==3) ; Newton M 1, roots of pixel dz=(zold^@nm1power-#pixel)/(@nm1power*zold^(@nm1power-1)) znew=zold-@nm1weight*dz r=1/|dz| elseif(funtype==4) ; Newton J 1, roots of specific value dz=(zold^@nj1power-@nj1param)/(@nj1power*zold^(@nj1power-1)) znew=zold-@nj1weight*dz r=1/|dz| elseif(funtype==5) ; Popcorn C 1, popcorn with complex variables xold=real(zold) yold=imag(zold) xnew=xold-@pc1h*@pc1out(yold+@pc1in(@pc1c*yold)) ynew=yold-@pc1h*@pc1out(xold+@pc1in(@pc1c*xold)) znew=xnew+flip(ynew) r=|znew| elseif(funtype==6) ; Popcorn R 1, popcorn with real variables xold=real(zold) yold=imag(zold) xnew=xold-@pr1h*real(@pr1out(yold+real(@pr1in(@pr1c*yold)))) ynew=yold-@pr1h*real(@pr1out(xold+real(@pr1in(@pr1c*xold)))) znew=xnew+flip(ynew) r=|znew| elseif(funtype==7) ; Mandelbrot 2 znew=(1-@m2weight)*zold+@m2weight*(zold^@m2power+#pixel) r=|znew| elseif(funtype==8) ; Julia 2 znew=(1-@j2weight)*zold+@j2weight*(zold^@j2power+@j2param) r=|znew| elseif(funtype==9) ; Newton M 2, roots of pixel dz=(zold^@nm2power-#pixel)/(@nm2power*zold^(@nm2power-1)) znew=zold-@nm2weight*dz r=1/|dz| elseif(funtype==10) ; Newton J 2, roots of specific value dz=(zold^@nj2power-@nj2param)/(@nj2power*zold^(@nj2power-1)) znew=zold-@nj2weight*dz r=1/|dz| elseif(funtype==11) ; Popcorn C 2, popcorn with complex variables xold=real(zold) yold=imag(zold) xnew=xold-@pc2h*@pc2out(yold+@pc2in(@pc2c*yold)) ynew=yold-@pc2h*@pc2out(xold+@pc2in(@pc2c*xold)) znew=xnew+flip(ynew) r=|znew| elseif(funtype==12) ; Popcorn R 2, popcorn with real variables xold=real(zold) yold=imag(zold) xnew=xold-@pr2h*real(@pr2out(yold+real(@pr2in(@pr2c*yold)))) ynew=yold-@pr2h*real(@pr2out(xold+real(@pr2in(@pr2c*xold)))) znew=xnew+flip(ynew) r=|znew| endif ; ; establish z ; if(@ztype=="iterate") z=znew elseif(@ztype=="difference") z=znew-zold elseif(@ztype=="ratio") z=znew/zold elseif(@ztype=="weird") if(@nfunction=="1") z=zold^znew elseif(@nfunction=="2") z=(-zold)^znew elseif(@nfunction=="3") z=(-zold)^(-znew) elseif(@nfunction=="4") z=zold^(-znew) elseif(@nfunction=="5") z=(zold+znew)^(zold-znew) elseif(@nfunction=="6") z=(znew-zold)^(zold+znew) endif endif zold=znew bailout: r<@bailout default: title="Alternating Functions" heading text="Allows you to alternate between several functions every iteration." endheading ; ; general parameters ; heading caption="General parameters" endheading param initz_type caption="initial z type" default=1 enum="manual" "pixel" endparam complex param initial_z caption="initial z" default=(0,0) visible=(@initz_type=="manual") endparam float param bailout caption="bailout" default=1000 endparam param ztype caption="z type" default=0 enum="iterate" "difference" "ratio" "weird" endparam ; ; alternating function defintions ; heading caption="Alternating functions" endheading param nfunction caption="# of functions" default=1 enum="1" "2" "3" "4" "5" "6" endparam param fn1 caption="function 1" default=4 enum=" " "Mandelbrot 1" "Julia 1" "Newton M 1" "Newton J 1" "Popcorn C 1" "Popcorn R 1"\ "Mandelbrot 2" "Julia 2" "Newton M 2" "Newton J 2" "Popcorn C 2" "Popcorn R 2" endparam param fn2 caption="function 2" default=1 enum=" " "Mandelbrot 1" "Julia 1" "Newton M 1" "Newton J 1" "Popcorn C 1" "Popcorn R 1"\ "Mandelbrot 2" "Julia 2" "Newton M 2" "Newton J 2" "Popcorn C 2" "Popcorn R 2" visible=(@nfunction>0) endparam param fn3 caption="function 3" default=0 enum=" " "Mandelbrot 1" "Julia 1" "Newton M 1" "Newton J 1" "Popcorn C 1" "Popcorn R 1"\ "Mandelbrot 2" "Julia 2" "Newton M 2" "Newton J 2" "Popcorn C 2" "Popcorn R 2" visible=(@nfunction>1) endparam param fn4 caption="function 4" default=0 enum=" " "Mandelbrot 1" "Julia 1" "Newton M 1" "Newton J 1" "Popcorn C 1" "Popcorn R 1"\ "Mandelbrot 2" "Julia 2" "Newton M 2" "Newton J 2" "Popcorn C 2" "Popcorn R 2" visible=(@nfunction>2) endparam param fn5 caption="function 5" default=0 enum=" " "Mandelbrot 1" "Julia 1" "Newton M 1" "Newton J 1" "Popcorn C 1" "Popcorn R 1"\ "Mandelbrot 2" "Julia 2" "Newton M 2" "Newton J 2" "Popcorn C 2" "Popcorn R 2" visible=(@nfunction>3) endparam param fn6 caption="function 6" default=0 enum=" " "Mandelbrot 1" "Julia 1" "Newton M 1" "Newton J 1" "Popcorn C 1" "Popcorn R 1"\ "Mandelbrot 2" "Julia 2" "Newton M 2" "Newton J 2" "Popcorn C 2" "Popcorn R 2" visible=(@nfunction>4) endparam ; complex param m1power caption="Mandelbrot 1 power" default=(2,0) visible=((@fn1=="Mandelbrot 1")||(@fn2=="Mandelbrot 1")||(@fn3=="Mandelbrot 1")||\ (@fn4=="Mandelbrot 1")||(@fn5=="Mandelbrot 1")||(@fn6=="Mandelbrot 1")) endparam complex param m1weight caption="Mandelbrot 1 weight" default=1 visible=((@fn1=="Mandelbrot 1")||(@fn2=="Mandelbrot 1")||(@fn3=="Mandelbrot 1")||\ (@fn4=="Mandelbrot 1")||(@fn5=="Mandelbrot 1")||(@fn6=="Mandelbrot 1")) endparam complex param j1power caption="Julia 1 power" default=(2,0) visible=((@fn1=="Julia 1")||(@fn2=="Julia 1")||(@fn3=="Julia 1")||\ (@fn4=="Julia 1")||(@fn5=="Julia 1")||(@fn6=="Julia 1")) endparam complex param j1param caption="Julia 1 parameter" default=(0,1) visible=((@fn1=="Julia 1")||(@fn2=="Julia 1")||(@fn3=="Julia 1")||\ (@fn4=="Julia 1")||(@fn5=="Julia 1")||(@fn6=="Julia 1")) endparam complex param j1weight caption="Julia 1 weight" default=1 visible=((@fn1=="Julia 1")||(@fn2=="Julia 1")||(@fn3=="Julia 1")||\ (@fn4=="Julia 1")||(@fn5=="Julia 1")||(@fn6=="Julia 1")) endparam complex param nm1power caption="Newton M 1 power" default=(3,0) visible=((@fn1=="Newton M 1")||(@fn2=="Newton M 1")||(@fn3=="Newton M 1")||\ (@fn4=="Newton M 1")||(@fn5=="Newton M 1")||(@fn6=="Newton M 1")) endparam complex param nm1weight caption="Newton M 1 nova fac" default=1 visible=((@fn1=="Newton M 1")||(@fn2=="Newton M 1")||(@fn3=="Newton M 1")||\ (@fn4=="Newton M 1")||(@fn5=="Newton M 1")||(@fn6=="Newton M 1")) endparam complex param nj1power caption="Newton J 1 power" default=(4,0) visible=((@fn1=="Newton J 1")||(@fn2=="Newton J 1")||(@fn3=="Newton J 1")||\ (@fn4=="Newton J 1")||(@fn5=="Newton J 1")||(@fn6=="Newton J 1")) endparam complex param nj1param caption="Newton J 1 parameter" default=(1,0) visible=((@fn1=="Newton J 1")||(@fn2=="Newton J 1")||(@fn3=="Newton J 1")||\ (@fn4=="Newton J 1")||(@fn5=="Newton J 1")||(@fn6=="Newton J 1")) endparam complex param nj1weight caption="Newton J 1 nova fac" default=1 visible=((@fn1=="Newton J 1")||(@fn2=="Newton J 1")||(@fn3=="Newton J 1")||\ (@fn4=="Newton J 1")||(@fn5=="Newton J 1")||(@fn6=="Newton J 1")) endparam complex param pc1h caption="complex step size 1" default=(0.1,0) visible=((@fn1=="Popcorn C 1")||(@fn2=="Popcorn C 1")||(@fn3=="Popcorn C 1")||\ (@fn4=="Popcorn C 1")||(@fn5=="Popcorn C 1")||(@fn6=="Popcorn C 1")) endparam complex param pc1c caption="complex frequency 1" default=(3,0) visible=((@fn1=="Popcorn C 1")||(@fn2=="Popcorn C 1")||(@fn3=="Popcorn C 1")||\ (@fn4=="Popcorn C 1")||(@fn5=="Popcorn C 1")||(@fn6=="Popcorn C 1")) endparam func pc1out caption="complex outer function 1" default=sin() visible=((@fn1=="Popcorn C 1")||(@fn2=="Popcorn C 1")||(@fn3=="Popcorn C 1")||\ (@fn4=="Popcorn C 1")||(@fn5=="Popcorn C 1")||(@fn6=="Popcorn C 1")) endfunc func pc1in caption="complex inner function 1" default=tan() visible=((@fn1=="Popcorn C 1")||(@fn2=="Popcorn C 1")||(@fn3=="Popcorn C 1")||\ (@fn4=="Popcorn C 1")||(@fn5=="Popcorn C 1")||(@fn6=="Popcorn C 1")) endfunc float param pr1h caption="real step size 1" default=0.1 visible=((@fn1=="Popcorn R 1")||(@fn2=="Popcorn R 1")||(@fn3=="Popcorn R 1")||\ (@fn4=="Popcorn R 1")||(@fn5=="Popcorn R 1")||(@fn6=="Popcorn R 1")) endparam float param pr1c caption="real frequency 1" default=3 visible=((@fn1=="Popcorn R 1")||(@fn2=="Popcorn R 1")||(@fn3=="Popcorn R 1")||\ (@fn4=="Popcorn R 1")||(@fn5=="Popcorn R 1")||(@fn6=="Popcorn R 1")) endparam func pr1out caption="real outer function 1" default=sin() visible=((@fn1=="Popcorn R 1")||(@fn2=="Popcorn R 1")||(@fn3=="Popcorn R 1")||\ (@fn4=="Popcorn R 1")||(@fn5=="Popcorn R 1")||(@fn6=="Popcorn R 1")) endfunc func pr1in caption="real inner function 1" default=tan() visible=((@fn1=="Popcorn R 1")||(@fn2=="Popcorn R 1")||(@fn3=="Popcorn R 1")||\ (@fn4=="Popcorn R 1")||(@fn5=="Popcorn R 1")||(@fn6=="Popcorn R 1")) endfunc complex param m2power caption="Mandelbrot 2 power" default=(2,0) visible=((@fn1=="Mandelbrot 2")||(@fn2=="Mandelbrot 2")||(@fn3=="Mandelbrot 2")||\ (@fn4=="Mandelbrot 2")||(@fn5=="Mandelbrot 2")||(@fn6=="Mandelbrot 2")) endparam complex param m2weight caption="Mandelbrot 2 weight" default=1 visible=((@fn1=="Mandelbrot 2")||(@fn2=="Mandelbrot 2")||(@fn3=="Mandelbrot 2")||\ (@fn4=="Mandelbrot 2")||(@fn5=="Mandelbrot 2")||(@fn6=="Mandelbrot 2")) endparam complex param j2power caption="Julia 2 power" default=(2,0) visible=((@fn1=="Julia 2")||(@fn2=="Julia 2")||(@fn3=="Julia 2")||\ (@fn4=="Julia 2")||(@fn5=="Julia 2")||(@fn6=="Julia 2")) endparam complex param j2param caption="Julia 2 parameter" default=(0,1) visible=((@fn1=="Julia 2")||(@fn2=="Julia 2")||(@fn3=="Julia 2")||\ (@fn4=="Julia 2")||(@fn5=="Julia 2")||(@fn6=="Julia 2")) endparam complex param j2weight caption="Julia 2 weight" default=1 visible=((@fn1=="Julia 2")||(@fn2=="Julia 2")||(@fn3=="Julia 2")||\ (@fn4=="Julia 2")||(@fn5=="Julia 2")||(@fn6=="Julia 2")) endparam complex param nm2power caption="Newton M 2 power" default=(3,0) visible=((@fn1=="Newton M 2")||(@fn2=="Newton M 2")||(@fn3=="Newton M 2")||\ (@fn4=="Newton M 2")||(@fn5=="Newton M 2")||(@fn6=="Newton M 2")) endparam complex param nm2weight caption="Newton M 2 nova fac" default=1 visible=((@fn1=="Newton M 2")||(@fn2=="Newton M 2")||(@fn3=="Newton M 2")||\ (@fn4=="Newton M 2")||(@fn5=="Newton M 2")||(@fn6=="Newton M 2")) endparam complex param nj2power caption="Newton J 2 power" default=(4,0) visible=((@fn1=="Newton J 2")||(@fn2=="Newton J 2")||(@fn3=="Newton J 2")||\ (@fn4=="Newton J 2")||(@fn5=="Newton J 2")||(@fn6=="Newton J 2")) endparam complex param nj2param caption="Newton J 2 parameter" default=(1,0) visible=((@fn1=="Newton J 2")||(@fn2=="Newton J 2")||(@fn3=="Newton J 2")||\ (@fn4=="Newton J 2")||(@fn5=="Newton J 2")||(@fn6=="Newton J 2")) endparam complex param nj2weight caption="Newton J 2 nova fac" default=(1,0) visible=((@fn1=="Newton J 2")||(@fn2=="Newton J 2")||(@fn3=="Newton J 2")||\ (@fn4=="Newton J 2")||(@fn5=="Newton J 2")||(@fn6=="Newton J 2")) endparam complex param pc2h caption="complex step size 2" default=(0.1,0) visible=((@fn1=="Popcorn C 2")||(@fn2=="Popcorn C 2")||(@fn3=="Popcorn C 2")||\ (@fn4=="Popcorn C 2")||(@fn5=="Popcorn C 2")||(@fn6=="Popcorn C 2")) endparam complex param pc2c caption="complex frequency 2" default=(3,0) visible=((@fn1=="Popcorn C 2")||(@fn2=="Popcorn C 2")||(@fn3=="Popcorn C 2")||\ (@fn4=="Popcorn C 2")||(@fn5=="Popcorn C 2")||(@fn6=="Popcorn C 2")) endparam func pc2out caption="complex outer function 2" default=sin() visible=((@fn1=="Popcorn C 2")||(@fn2=="Popcorn C 2")||(@fn3=="Popcorn C 2")||\ (@fn4=="Popcorn C 2")||(@fn5=="Popcorn C 2")||(@fn6=="Popcorn C 2")) endfunc func pc2in caption="complex inner function 2" default=tan() visible=((@fn1=="Popcorn C 2")||(@fn2=="Popcorn C 2")||(@fn3=="Popcorn C 2")||\ (@fn4=="Popcorn C 2")||(@fn5=="Popcorn C 2")||(@fn6=="Popcorn C 2")) endfunc float param pr2h caption="real step size 2" default=0.1 visible=((@fn1=="Popcorn R 2")||(@fn2=="Popcorn R 2")||(@fn3=="Popcorn R 2")||\ (@fn4=="Popcorn R 2")||(@fn5=="Popcorn R 2")||(@fn6=="Popcorn R 2")) endparam float param pr2c caption="real frequency 2" default=3 visible=((@fn1=="Popcorn R 2")||(@fn2=="Popcorn R 2")||(@fn3=="Popcorn R 2")||\ (@fn4=="Popcorn R 2")||(@fn5=="Popcorn R 2")||(@fn6=="Popcorn R 2")) endparam func pr2out caption="real outer function 2" default=sin() visible=((@fn1=="Popcorn R 2")||(@fn2=="Popcorn R 2")||(@fn3=="Popcorn R 2")||\ (@fn4=="Popcorn R 2")||(@fn5=="Popcorn R 2")||(@fn6=="Popcorn R 2")) endfunc func pr2in caption="real inner function 2" default=tan() visible=((@fn1=="Popcorn R 2")||(@fn2=="Popcorn R 2")||(@fn3=="Popcorn R 2")||\ (@fn4=="Popcorn R 2")||(@fn5=="Popcorn R 2")||(@fn6=="Popcorn R 2")) endfunc ; ; oscillator/ramp ; heading caption="Oscillator" endheading param oscillator_type caption="type" default=0 enum="ramp" "sine" "cosine" "random msb" "random lsb" endparam int param initial_seed caption="random seed" default=2357 visible=((@oscillator_type=="random msb")||(@oscillator_type=="random lsb")) endparam } interpolating-functions { ; Kerry Mitchell 06 July 2014 ; ; based on my Alternating Functions formula ; allows you to interpolate between up to 6 functions for each iteration ; supports multiple interpolation methods ; init: complex a0=(0,0) complex a1=(0,0) complex a2=(0,0) complex a3=(0,0) complex b1=(0,0) complex b2=(0,0) complex b3=(0,0) complex dz=(0,0) complex xnew=(0,0) complex xold=(0,0) complex ynew=(0,0) complex yold=(0,0) complex z=(0,0) complex z1=(0,0) complex z2=(0,0) complex z3=(0,0) complex z4=(0,0) complex z5=(0,0) complex z6=(0,0) float t=0 float weight1=0 float weight2=0 int fun1type=0 int fun2type=0 int fun3type=0 int fun4type=0 int fun5type=0 int fun6type=0 int iter=0 ; ; initialize z ; iter=0 if(@initz_type=="pixel") z=#pixel else z=@initial_z endif loop: iter=iter+1 ; ; choose functions to interpolate between ; ; 1 function ; if(@nfunction=="1") if(@fn1=="Mandelbrot 1") fun1type=1 elseif(@fn1=="Julia 1") fun1type=2 elseif(@fn1=="Newton M 1") fun1type=3 elseif(@fn1=="Newton J 1") fun1type=4 elseif(@fn1=="Popcorn C 1") fun1type=5 elseif(@fn1=="Popcorn R 1") fun1type=6 elseif(@fn1=="Mandelbrot 2") fun1type=7 elseif(@fn1=="Julia 2") fun1type=8 elseif(@fn1=="Newton M 2") fun1type=9 elseif(@fn1=="Newton J 2") fun1type=10 elseif(@fn1=="Popcorn C 2") fun1type=11 elseif(@fn1=="Popcorn R 2") fun1type=12 endif ; ; 2 functions ; elseif(@nfunction=="2") if(@fn1=="Mandelbrot 1") fun1type=1 elseif(@fn1=="Julia 1") fun1type=2 elseif(@fn1=="Newton M 1") fun1type=3 elseif(@fn1=="Newton J 1") fun1type=4 elseif(@fn1=="Popcorn C 1") fun1type=5 elseif(@fn1=="Popcorn R 1") fun1type=6 elseif(@fn1=="Mandelbrot 2") fun1type=7 elseif(@fn1=="Julia 2") fun1type=8 elseif(@fn1=="Newton M 2") fun1type=9 elseif(@fn1=="Newton J 2") fun1type=10 elseif(@fn1=="Popcorn C 2") fun1type=11 elseif(@fn1=="Popcorn R 2") fun1type=12 endif if(@fn2=="Mandelbrot 1") fun2type=1 elseif(@fn2=="Julia 1") fun2type=2 elseif(@fn2=="Newton M 1") fun2type=3 elseif(@fn2=="Newton J 1") fun2type=4 elseif(@fn2=="Popcorn C 1") fun2type=5 elseif(@fn2=="Popcorn R 1") fun2type=6 elseif(@fn2=="Mandelbrot 2") fun2type=7 elseif(@fn2=="Julia 2") fun2type=8 elseif(@fn2=="Newton M 2") fun2type=9 elseif(@fn2=="Newton J 2") fun2type=10 elseif(@fn2=="Popcorn C 2") fun2type=11 elseif(@fn2=="Popcorn R 2") fun2type=12 endif ; ; 3 functions ; elseif(@nfunction=="3") if(@fn1=="Mandelbrot 1") fun1type=1 elseif(@fn1=="Julia 1") fun1type=2 elseif(@fn1=="Newton M 1") fun1type=3 elseif(@fn1=="Newton J 1") fun1type=4 elseif(@fn1=="Popcorn C 1") fun1type=5 elseif(@fn1=="Popcorn R 1") fun1type=6 elseif(@fn1=="Mandelbrot 2") fun1type=7 elseif(@fn1=="Julia 2") fun1type=8 elseif(@fn1=="Newton M 2") fun1type=9 elseif(@fn1=="Newton J 2") fun1type=10 elseif(@fn1=="Popcorn C 2") fun1type=11 elseif(@fn1=="Popcorn R 2") fun1type=12 endif if(@fn2=="Mandelbrot 1") fun2type=1 elseif(@fn2=="Julia 1") fun2type=2 elseif(@fn2=="Newton M 1") fun2type=3 elseif(@fn2=="Newton J 1") fun2type=4 elseif(@fn2=="Popcorn C 1") fun2type=5 elseif(@fn2=="Popcorn R 1") fun2type=6 elseif(@fn2=="Mandelbrot 2") fun2type=7 elseif(@fn2=="Julia 2") fun2type=8 elseif(@fn2=="Newton M 2") fun2type=9 elseif(@fn2=="Newton J 2") fun2type=10 elseif(@fn2=="Popcorn C 2") fun2type=11 elseif(@fn2=="Popcorn R 2") fun2type=12 endif if(@fn3=="Mandelbrot 1") fun3type=1 elseif(@fn3=="Julia 1") fun3type=2 elseif(@fn3=="Newton M 1") fun3type=3 elseif(@fn3=="Newton J 1") fun3type=4 elseif(@fn3=="Popcorn C 1") fun3type=5 elseif(@fn3=="Popcorn R 1") fun3type=6 elseif(@fn3=="Mandelbrot 2") fun3type=7 elseif(@fn3=="Julia 2") fun3type=8 elseif(@fn3=="Newton M 2") fun3type=9 elseif(@fn3=="Newton J 2") fun3type=10 elseif(@fn3=="Popcorn C 2") fun3type=11 elseif(@fn3=="Popcorn R 2") fun3type=12 endif ; ; 4 functions ; elseif(@nfunction=="4") if(@fn1=="Mandelbrot 1") fun1type=1 elseif(@fn1=="Julia 1") fun1type=2 elseif(@fn1=="Newton M 1") fun1type=3 elseif(@fn1=="Newton J 1") fun1type=4 elseif(@fn1=="Popcorn C 1") fun1type=5 elseif(@fn1=="Popcorn R 1") fun1type=6 elseif(@fn1=="Mandelbrot 2") fun1type=7 elseif(@fn1=="Julia 2") fun1type=8 elseif(@fn1=="Newton M 2") fun1type=9 elseif(@fn1=="Newton J 2") fun1type=10 elseif(@fn1=="Popcorn C 2") fun1type=11 elseif(@fn1=="Popcorn R 2") fun1type=12 endif if(@fn2=="Mandelbrot 1") fun2type=1 elseif(@fn2=="Julia 1") fun2type=2 elseif(@fn2=="Newton M 1") fun2type=3 elseif(@fn2=="Newton J 1") fun2type=4 elseif(@fn2=="Popcorn C 1") fun2type=5 elseif(@fn2=="Popcorn R 1") fun2type=6 elseif(@fn2=="Mandelbrot 2") fun2type=7 elseif(@fn2=="Julia 2") fun2type=8 elseif(@fn2=="Newton M 2") fun2type=9 elseif(@fn2=="Newton J 2") fun2type=10 elseif(@fn2=="Popcorn C 2") fun2type=11 elseif(@fn2=="Popcorn R 2") fun2type=12 endif if(@fn3=="Mandelbrot 1") fun3type=1 elseif(@fn3=="Julia 1") fun3type=2 elseif(@fn3=="Newton M 1") fun3type=3 elseif(@fn3=="Newton J 1") fun3type=4 elseif(@fn3=="Popcorn C 1") fun3type=5 elseif(@fn3=="Popcorn R 1") fun3type=6 elseif(@fn3=="Mandelbrot 2") fun3type=7 elseif(@fn3=="Julia 2") fun3type=8 elseif(@fn3=="Newton M 2") fun3type=9 elseif(@fn3=="Newton J 2") fun3type=10 elseif(@fn3=="Popcorn C 2") fun3type=11 elseif(@fn3=="Popcorn R 2") fun3type=12 endif if(@fn4=="Mandelbrot 1") fun4type=1 elseif(@fn4=="Julia 1") fun4type=2 elseif(@fn4=="Newton M 1") fun4type=3 elseif(@fn4=="Newton J 1") fun4type=4 elseif(@fn4=="Popcorn C 1") fun4type=5 elseif(@fn4=="Popcorn R 1") fun4type=6 elseif(@fn4=="Mandelbrot 2") fun4type=7 elseif(@fn4=="Julia 2") fun4type=8 elseif(@fn4=="Newton M 2") fun4type=9 elseif(@fn4=="Newton J 2") fun4type=10 elseif(@fn4=="Popcorn C 2") fun4type=11 elseif(@fn4=="Popcorn R 2") fun4type=12 endif ; ; 5 functions ; elseif(@nfunction=="5") if(@fn1=="Mandelbrot 1") fun1type=1 elseif(@fn1=="Julia 1") fun1type=2 elseif(@fn1=="Newton M 1") fun1type=3 elseif(@fn1=="Newton J 1") fun1type=4 elseif(@fn1=="Popcorn C 1") fun1type=5 elseif(@fn1=="Popcorn R 1") fun1type=6 elseif(@fn1=="Mandelbrot 2") fun1type=7 elseif(@fn1=="Julia 2") fun1type=8 elseif(@fn1=="Newton M 2") fun1type=9 elseif(@fn1=="Newton J 2") fun1type=10 elseif(@fn1=="Popcorn C 2") fun1type=11 elseif(@fn1=="Popcorn R 2") fun1type=12 endif if(@fn2=="Mandelbrot 1") fun2type=1 elseif(@fn2=="Julia 1") fun2type=2 elseif(@fn2=="Newton M 1") fun2type=3 elseif(@fn2=="Newton J 1") fun2type=4 elseif(@fn2=="Popcorn C 1") fun2type=5 elseif(@fn2=="Popcorn R 1") fun2type=6 elseif(@fn2=="Mandelbrot 2") fun2type=7 elseif(@fn2=="Julia 2") fun2type=8 elseif(@fn2=="Newton M 2") fun2type=9 elseif(@fn2=="Newton J 2") fun2type=10 elseif(@fn2=="Popcorn C 2") fun2type=11 elseif(@fn2=="Popcorn R 2") fun2type=12 endif if(@fn3=="Mandelbrot 1") fun3type=1 elseif(@fn3=="Julia 1") fun3type=2 elseif(@fn3=="Newton M 1") fun3type=3 elseif(@fn3=="Newton J 1") fun3type=4 elseif(@fn3=="Popcorn C 1") fun3type=5 elseif(@fn3=="Popcorn R 1") fun3type=6 elseif(@fn3=="Mandelbrot 2") fun3type=7 elseif(@fn3=="Julia 2") fun3type=8 elseif(@fn3=="Newton M 2") fun3type=9 elseif(@fn3=="Newton J 2") fun3type=10 elseif(@fn3=="Popcorn C 2") fun3type=11 elseif(@fn3=="Popcorn R 2") fun3type=12 endif if(@fn4=="Mandelbrot 1") fun4type=1 elseif(@fn4=="Julia 1") fun4type=2 elseif(@fn4=="Newton M 1") fun4type=3 elseif(@fn4=="Newton J 1") fun4type=4 elseif(@fn4=="Popcorn C 1") fun4type=5 elseif(@fn4=="Popcorn R 1") fun4type=6 elseif(@fn4=="Mandelbrot 2") fun4type=7 elseif(@fn4=="Julia 2") fun4type=8 elseif(@fn4=="Newton M 2") fun4type=9 elseif(@fn4=="Newton J 2") fun4type=10 elseif(@fn4=="Popcorn C 2") fun4type=11 elseif(@fn4=="Popcorn R 2") fun4type=12 endif if(@fn5=="Mandelbrot 1") fun5type=1 elseif(@fn5=="Julia 1") fun5type=2 elseif(@fn5=="Newton M 1") fun5type=3 elseif(@fn5=="Newton J 1") fun5type=4 elseif(@fn5=="Popcorn C 1") fun5type=5 elseif(@fn5=="Popcorn R 1") fun5type=6 elseif(@fn5=="Mandelbrot 2") fun5type=7 elseif(@fn5=="Julia 2") fun5type=8 elseif(@fn5=="Newton M 2") fun5type=9 elseif(@fn5=="Newton J 2") fun5type=10 elseif(@fn5=="Popcorn C 2") fun5type=11 elseif(@fn5=="Popcorn R 2") fun5type=12 endif ; ; 6 functions ; elseif(@nfunction=="6") if(@fn1=="Mandelbrot 1") fun1type=1 elseif(@fn1=="Julia 1") fun1type=2 elseif(@fn1=="Newton M 1") fun1type=3 elseif(@fn1=="Newton J 1") fun1type=4 elseif(@fn1=="Popcorn C 1") fun1type=5 elseif(@fn1=="Popcorn R 1") fun1type=6 elseif(@fn1=="Mandelbrot 2") fun1type=7 elseif(@fn1=="Julia 2") fun1type=8 elseif(@fn1=="Newton M 2") fun1type=9 elseif(@fn1=="Newton J 2") fun1type=10 elseif(@fn1=="Popcorn C 2") fun1type=11 elseif(@fn1=="Popcorn R 2") fun1type=12 endif if(@fn2=="Mandelbrot 1") fun2type=1 elseif(@fn2=="Julia 1") fun2type=2 elseif(@fn2=="Newton M 1") fun2type=3 elseif(@fn2=="Newton J 1") fun2type=4 elseif(@fn2=="Popcorn C 1") fun2type=5 elseif(@fn2=="Popcorn R 1") fun2type=6 elseif(@fn2=="Mandelbrot 2") fun2type=7 elseif(@fn2=="Julia 2") fun2type=8 elseif(@fn2=="Newton M 2") fun2type=9 elseif(@fn2=="Newton J 2") fun2type=10 elseif(@fn2=="Popcorn C 2") fun2type=11 elseif(@fn2=="Popcorn R 2") fun2type=12 endif if(@fn3=="Mandelbrot 1") fun3type=1 elseif(@fn3=="Julia 1") fun3type=2 elseif(@fn3=="Newton M 1") fun3type=3 elseif(@fn3=="Newton J 1") fun3type=4 elseif(@fn3=="Popcorn C 1") fun3type=5 elseif(@fn3=="Popcorn R 1") fun3type=6 elseif(@fn3=="Mandelbrot 2") fun3type=7 elseif(@fn3=="Julia 2") fun3type=8 elseif(@fn3=="Newton M 2") fun3type=9 elseif(@fn3=="Newton J 2") fun3type=10 elseif(@fn3=="Popcorn C 2") fun3type=11 elseif(@fn3=="Popcorn R 2") fun3type=12 endif if(@fn4=="Mandelbrot 1") fun4type=1 elseif(@fn4=="Julia 1") fun4type=2 elseif(@fn4=="Newton M 1") fun4type=3 elseif(@fn4=="Newton J 1") fun4type=4 elseif(@fn4=="Popcorn C 1") fun4type=5 elseif(@fn4=="Popcorn R 1") fun4type=6 elseif(@fn4=="Mandelbrot 2") fun4type=7 elseif(@fn4=="Julia 2") fun4type=8 elseif(@fn4=="Newton M 2") fun4type=9 elseif(@fn4=="Newton J 2") fun4type=10 elseif(@fn4=="Popcorn C 2") fun4type=11 elseif(@fn4=="Popcorn R 2") fun4type=12 endif if(@fn5=="Mandelbrot 1") fun5type=1 elseif(@fn5=="Julia 1") fun5type=2 elseif(@fn5=="Newton M 1") fun5type=3 elseif(@fn5=="Newton J 1") fun5type=4 elseif(@fn5=="Popcorn C 1") fun5type=5 elseif(@fn5=="Popcorn R 1") fun5type=6 elseif(@fn5=="Mandelbrot 2") fun5type=7 elseif(@fn5=="Julia 2") fun5type=8 elseif(@fn5=="Newton M 2") fun5type=9 elseif(@fn5=="Newton J 2") fun5type=10 elseif(@fn5=="Popcorn C 2") fun5type=11 elseif(@fn5=="Popcorn R 2") fun5type=12 endif if(@fn6=="Mandelbrot 1") fun6type=1 elseif(@fn6=="Julia 1") fun6type=2 elseif(@fn6=="Newton M 1") fun6type=3 elseif(@fn6=="Newton J 1") fun6type=4 elseif(@fn6=="Popcorn C 1") fun6type=5 elseif(@fn6=="Popcorn R 1") fun6type=6 elseif(@fn6=="Mandelbrot 2") fun6type=7 elseif(@fn6=="Julia 2") fun6type=8 elseif(@fn6=="Newton M 2") fun6type=9 elseif(@fn6=="Newton J 2") fun6type=10 elseif(@fn6=="Popcorn C 2") fun6type=11 elseif(@fn6=="Popcorn R 2") fun6type=12 endif endif ; ; iterate each interpolating function ; if(fun1type==1) ; Mandelbrot 1 z1=z^@m1power+#pixel elseif(fun1type==2) ; Julia 1 z1=z^@j1power+@j1param elseif(fun1type==3) ; Newton M 1, roots of pixel dz=(z^@nm1power-#pixel)/(@nm1power*z^(@nm1power-1)) z1=z-@nm1weight*dz elseif(fun1type==4) ; Newton J 1, roots of specific value dz=(z^@nj1power-@nj1param)/(@nj1power*z^(@nj1power-1)) z1=z-@nj1weight*dz elseif(fun1type==5) ; Popcorn C 1, popcorn with complex variables xold=real(z) yold=imag(z) xnew=xold-@pc1h*@pc1out(yold+@pc1in(@pc1c*yold)) ynew=yold-@pc1h*@pc1out(xold+@pc1in(@pc1c*xold)) z1=xnew+flip(ynew) elseif(fun1type==6) ; Popcorn R 1, popcorn with real variables xold=real(z) yold=imag(z) xnew=xold-@pr1h*real(@pr1out(yold+real(@pr1in(@pr1c*yold)))) ynew=yold-@pr1h*real(@pr1out(xold+real(@pr1in(@pr1c*xold)))) z1=xnew+flip(ynew) elseif(fun1type==7) ; Mandelbrot 2 z1=z^@m2power+#pixel elseif(fun1type==8) ; Julia 2 z1=z^@j2power+@j2param elseif(fun1type==9) ; Newton M 2, roots of pixel dz=(z^@nm2power-#pixel)/(@nm2power*z^(@nm2power-1)) z1=z-@nm2weight*dz elseif(fun1type==10) ; Newton J 2, roots of specific value dz=(z^@nj2power-@nj2param)/(@nj2power*z^(@nj2power-1)) z1=z-@nj2weight*dz elseif(fun1type==11) ; Popcorn C 2, popcorn with complex variables xold=real(z) yold=imag(z) xnew=xold-@pc2h*@pc2out(yold+@pc2in(@pc2c*yold)) ynew=yold-@pc2h*@pc2out(xold+@pc2in(@pc2c*xold)) z1=xnew+flip(ynew) elseif(fun1type==12) ; Popcorn R 2, popcorn with real variables xold=real(z) yold=imag(z) xnew=xold-@pr2h*real(@pr2out(yold+real(@pr2in(@pr2c*yold)))) ynew=yold-@pr2h*real(@pr2out(xold+real(@pr2in(@pr2c*xold)))) z1=xnew+flip(ynew) endif ; if(fun2type==1) ; Mandelbrot 1 z2=z^@m1power+#pixel elseif(fun2type==2) ; Julia 1 z2=z^@j1power+@j1param elseif(fun2type==3) ; Newton M 1, roots of pixel dz=(z^@nm1power-#pixel)/(@nm1power*z^(@nm1power-1)) z2=z-@nm1weight*dz elseif(fun2type==4) ; Newton J 1, roots of specific value dz=(z^@nj1power-@nj1param)/(@nj1power*z^(@nj1power-1)) z2=z-@nj1weight*dz elseif(fun2type==5) ; Popcorn C 1, popcorn with complex variables xold=real(z) yold=imag(z) xnew=xold-@pc1h*@pc1out(yold+@pc1in(@pc1c*yold)) ynew=yold-@pc1h*@pc1out(xold+@pc1in(@pc1c*xold)) z2=xnew+flip(ynew) elseif(fun2type==6) ; Popcorn R 1, popcorn with real variables xold=real(z) yold=imag(z) xnew=xold-@pr1h*real(@pr1out(yold+real(@pr1in(@pr1c*yold)))) ynew=yold-@pr1h*real(@pr1out(xold+real(@pr1in(@pr1c*xold)))) z2=xnew+flip(ynew) elseif(fun2type==7) ; Mandelbrot 2 z2=z^@m2power+#pixel elseif(fun2type==8) ; Julia 2 z2=z^@j2power+@j2param elseif(fun2type==9) ; Newton M 2, roots of pixel dz=(z^@nm2power-#pixel)/(@nm2power*z^(@nm2power-1)) z2=z-@nm2weight*dz elseif(fun2type==10) ; Newton J 2, roots of specific value dz=(z^@nj2power-@nj2param)/(@nj2power*z^(@nj2power-1)) z2=z-@nj2weight*dz elseif(fun2type==11) ; Popcorn C 2, popcorn with complex variables xold=real(z) yold=imag(z) xnew=xold-@pc2h*@pc2out(yold+@pc2in(@pc2c*yold)) ynew=yold-@pc2h*@pc2out(xold+@pc2in(@pc2c*xold)) z2=xnew+flip(ynew) elseif(fun2type==12) ; Popcorn R 2, popcorn with real variables xold=real(z) yold=imag(z) xnew=xold-@pr2h*real(@pr2out(yold+real(@pr2in(@pr2c*yold)))) ynew=yold-@pr2h*real(@pr2out(xold+real(@pr2in(@pr2c*xold)))) z2=xnew+flip(ynew) endif ; if(fun3type==1) ; Mandelbrot 1 z3=z^@m1power+#pixel elseif(fun3type==2) ; Julia 1 z3=z^@j1power+@j1param elseif(fun3type==3) ; Newton M 1, roots of pixel dz=(z^@nm1power-#pixel)/(@nm1power*z^(@nm1power-1)) z3=z-@nm1weight*dz elseif(fun3type==4) ; Newton J 1, roots of specific value dz=(z^@nj1power-@nj1param)/(@nj1power*z^(@nj1power-1)) z3=z-@nj1weight*dz elseif(fun3type==5) ; Popcorn C 1, popcorn with complex variables xold=real(z) yold=imag(z) xnew=xold-@pc1h*@pc1out(yold+@pc1in(@pc1c*yold)) ynew=yold-@pc1h*@pc1out(xold+@pc1in(@pc1c*xold)) z3=xnew+flip(ynew) elseif(fun3type==6) ; Popcorn R 1, popcorn with real variables xold=real(z) yold=imag(z) xnew=xold-@pr1h*real(@pr1out(yold+real(@pr1in(@pr1c*yold)))) ynew=yold-@pr1h*real(@pr1out(xold+real(@pr1in(@pr1c*xold)))) z3=xnew+flip(ynew) elseif(fun3type==7) ; Mandelbrot 2 z3=z^@m2power+#pixel elseif(fun3type==8) ; Julia 2 z3=z^@j2power+@j2param elseif(fun3type==9) ; Newton M 2, roots of pixel dz=(z^@nm2power-#pixel)/(@nm2power*z^(@nm2power-1)) z3=z-@nm2weight*dz elseif(fun3type==10) ; Newton J 2, roots of specific value dz=(z^@nj2power-@nj2param)/(@nj2power*z^(@nj2power-1)) z3=z-@nj2weight*dz elseif(fun3type==11) ; Popcorn C 2, popcorn with complex variables xold=real(z) yold=imag(z) xnew=xold-@pc2h*@pc2out(yold+@pc2in(@pc2c*yold)) ynew=yold-@pc2h*@pc2out(xold+@pc2in(@pc2c*xold)) z3=xnew+flip(ynew) elseif(fun3type==12) ; Popcorn R 2, popcorn with real variables xold=real(z) yold=imag(z) xnew=xold-@pr2h*real(@pr2out(yold+real(@pr2in(@pr2c*yold)))) ynew=yold-@pr2h*real(@pr2out(xold+real(@pr2in(@pr2c*xold)))) z3=xnew+flip(ynew) endif ; if(fun4type==1) ; Mandelbrot 1 z4=z^@m1power+#pixel elseif(fun4type==2) ; Julia 1 z4=z^@j1power+@j1param elseif(fun4type==3) ; Newton M 1, roots of pixel dz=(z^@nm1power-#pixel)/(@nm1power*z^(@nm1power-1)) z4=z-@nm1weight*dz elseif(fun4type==4) ; Newton J 1, roots of specific value dz=(z^@nj1power-@nj1param)/(@nj1power*z^(@nj1power-1)) z4=z-@nj1weight*dz elseif(fun4type==5) ; Popcorn C 1, popcorn with complex variables xold=real(z) yold=imag(z) xnew=xold-@pc1h*@pc1out(yold+@pc1in(@pc1c*yold)) ynew=yold-@pc1h*@pc1out(xold+@pc1in(@pc1c*xold)) z4=xnew+flip(ynew) elseif(fun4type==6) ; Popcorn R 1, popcorn with real variables xold=real(z) yold=imag(z) xnew=xold-@pr1h*real(@pr1out(yold+real(@pr1in(@pr1c*yold)))) ynew=yold-@pr1h*real(@pr1out(xold+real(@pr1in(@pr1c*xold)))) z4=xnew+flip(ynew) elseif(fun4type==7) ; Mandelbrot 2 z4=z^@m2power+#pixel elseif(fun4type==8) ; Julia 2 z4=z^@j2power+@j2param elseif(fun4type==9) ; Newton M 2, roots of pixel dz=(z^@nm2power-#pixel)/(@nm2power*z^(@nm2power-1)) z4=z-@nm2weight*dz elseif(fun4type==10) ; Newton J 2, roots of specific value dz=(z^@nj2power-@nj2param)/(@nj2power*z^(@nj2power-1)) z4=z-@nj2weight*dz elseif(fun4type==11) ; Popcorn C 2, popcorn with complex variables xold=real(z) yold=imag(z) xnew=xold-@pc2h*@pc2out(yold+@pc2in(@pc2c*yold)) ynew=yold-@pc2h*@pc2out(xold+@pc2in(@pc2c*xold)) z4=xnew+flip(ynew) elseif(fun4type==12) ; Popcorn R 2, popcorn with real variables xold=real(z) yold=imag(z) xnew=xold-@pr2h*real(@pr2out(yold+real(@pr2in(@pr2c*yold)))) ynew=yold-@pr2h*real(@pr2out(xold+real(@pr2in(@pr2c*xold)))) z4=xnew+flip(ynew) endif ; if(fun5type==1) ; Mandelbrot 1 z5=z^@m1power+#pixel elseif(fun5type==2) ; Julia 1 z5=z^@j1power+@j1param elseif(fun5type==3) ; Newton M 1, roots of pixel dz=(z^@nm1power-#pixel)/(@nm1power*z^(@nm1power-1)) z5=z-@nm1weight*dz elseif(fun5type==4) ; Newton J 1, roots of specific value dz=(z^@nj1power-@nj1param)/(@nj1power*z^(@nj1power-1)) z5=z-@nj1weight*dz elseif(fun5type==5) ; Popcorn C 1, popcorn with complex variables xold=real(z) yold=imag(z) xnew=xold-@pc1h*@pc1out(yold+@pc1in(@pc1c*yold)) ynew=yold-@pc1h*@pc1out(xold+@pc1in(@pc1c*xold)) z5=xnew+flip(ynew) elseif(fun5type==6) ; Popcorn R 1, popcorn with real variables xold=real(z) yold=imag(z) xnew=xold-@pr1h*real(@pr1out(yold+real(@pr1in(@pr1c*yold)))) ynew=yold-@pr1h*real(@pr1out(xold+real(@pr1in(@pr1c*xold)))) z5=xnew+flip(ynew) elseif(fun5type==7) ; Mandelbrot 2 z5=z^@m2power+#pixel elseif(fun5type==8) ; Julia 2 z5=z^@j2power+@j2param elseif(fun5type==9) ; Newton M 2, roots of pixel dz=(z^@nm2power-#pixel)/(@nm2power*z^(@nm2power-1)) z5=z-@nm2weight*dz elseif(fun5type==10) ; Newton J 2, roots of specific value dz=(z^@nj2power-@nj2param)/(@nj2power*z^(@nj2power-1)) z5=z-@nj2weight*dz elseif(fun5type==11) ; Popcorn C 2, popcorn with complex variables xold=real(z) yold=imag(z) xnew=xold-@pc2h*@pc2out(yold+@pc2in(@pc2c*yold)) ynew=yold-@pc2h*@pc2out(xold+@pc2in(@pc2c*xold)) z5=xnew+flip(ynew) elseif(fun5type==12) ; Popcorn R 2, popcorn with real variables xold=real(z) yold=imag(z) xnew=xold-@pr2h*real(@pr2out(yold+real(@pr2in(@pr2c*yold)))) ynew=yold-@pr2h*real(@pr2out(xold+real(@pr2in(@pr2c*xold)))) z5=xnew+flip(ynew) endif ; if(fun6type==1) ; Mandelbrot 1 z6=z^@m1power+#pixel elseif(fun6type==2) ; Julia 1 z6=z^@j1power+@j1param elseif(fun6type==3) ; Newton M 1, roots of pixel dz=(z^@nm1power-#pixel)/(@nm1power*z^(@nm1power-1)) z6=z-@nm1weight*dz elseif(fun6type==4) ; Newton J 1, roots of specific value dz=(z^@nj1power-@nj1param)/(@nj1power*z^(@nj1power-1)) z6=z-@nj1weight*dz elseif(fun6type==5) ; Popcorn C 1, popcorn with complex variables xold=real(z) yold=imag(z) xnew=xold-@pc1h*@pc1out(yold+@pc1in(@pc1c*yold)) ynew=yold-@pc1h*@pc1out(xold+@pc1in(@pc1c*xold)) z6=xnew+flip(ynew) elseif(fun6type==6) ; Popcorn R 1, popcorn with real variables xold=real(z) yold=imag(z) xnew=xold-@pr1h*real(@pr1out(yold+real(@pr1in(@pr1c*yold)))) ynew=yold-@pr1h*real(@pr1out(xold+real(@pr1in(@pr1c*xold)))) z6=xnew+flip(ynew) elseif(fun6type==7) ; Mandelbrot 2 z6=z^@m2power+#pixel elseif(fun6type==8) ; Julia 2 z6=z^@j2power+@j2param elseif(fun6type==9) ; Newton M 2, roots of pixel dz=(z^@nm2power-#pixel)/(@nm2power*z^(@nm2power-1)) z6=z-@nm2weight*dz elseif(fun6type==10) ; Newton J 2, roots of specific value dz=(z^@nj2power-@nj2param)/(@nj2power*z^(@nj2power-1)) z6=z-@nj2weight*dz elseif(fun6type==11) ; Popcorn C 2, popcorn with complex variables xold=real(z) yold=imag(z) xnew=xold-@pc2h*@pc2out(yold+@pc2in(@pc2c*yold)) ynew=yold-@pc2h*@pc2out(xold+@pc2in(@pc2c*xold)) z6=xnew+flip(ynew) elseif(fun6type==12) ; Popcorn R 2, popcorn with real variables xold=real(z) yold=imag(z) xnew=xold-@pr2h*real(@pr2out(yold+real(@pr2in(@pr2c*yold)))) ynew=yold-@pr2h*real(@pr2out(xold+real(@pr2in(@pr2c*xold)))) z6=xnew+flip(ynew) endif ; ; interpolate ; ; 1 function--no interpolation ; if(@nfunction=="1") z=z1 ; ; 2 functions ; elseif(@nfunction=="2") if(@slider2_type=="constant") weight2=@slider2-1 weight1=1-weight2 elseif(@slider2_type=="cos(iter)") weight2=(1-cos(@freq2*iter))/2 weight1=1-weight2 elseif(@slider2_type=="sin(iter)") weight2=(1+sin(@freq2*iter))/2 weight1=1-weight2 elseif(@slider2_type=="tanh(iter)") weight2=tanh(@freq2*iter) weight1=1-weight2 elseif(@slider2_type=="cos(real)") weight2=(1-cos(@freq2*real(z)))/2 weight1=1-weight2 elseif(@slider2_type=="sin(imag)") weight2=(1+sin(@freq2*imag(z)))/2 weight1=1-weight2 elseif(@slider2_type=="tanh(mag)") weight2=tanh(@freq2*cabs(z)) weight1=1-weight2 elseif(@slider2_type=="angle") weight2=(atan2(z)/#pi+1)/2 weight2=(weight2*@freq2)%1 weight1=1-weight2 endif z=weight1*z1+weight2*z2 ; ; 3 functions ; elseif(@nfunction=="3") if(@slider3_type=="constant") t=(@slider3-1)/2 elseif(@slider3_type=="cos(iter)") t=(1-cos(@freq3*iter))/2 elseif(@slider3_type=="sin(iter)") t=(1+sin(@freq3*iter))/2 elseif(@slider3_type=="tanh(iter)") t=tanh(@freq3*iter) elseif(@slider3_type=="cos(real)") t=(1-cos(@freq3*real(z)))/2 elseif(@slider3_type=="sin(imag)") t=(1+sin(@freq3*imag(z)))/2 elseif(@slider3_type=="tanh(mag)") t=tanh(@freq3*cabs(z)) elseif(@slider3_type=="angle") t=(atan2(z)/#pi+1)/2 t=(t*@freq3)%1 endif if(@interp3_type=="Lagrange") t=t*2+1 z=z1*(t-2)*(t-3)/((1-2)*(1-3))\ +z2*(t-1)*(t-3)/((2-1)*(2-3))\ +z3*(t-1)*(t-2)/((3-1)*(3-2)) elseif(@interp3_type=="Bezier") z=sqr(1-t)*z1+2*(1-t)*t*z2+sqr(t)*z3 elseif(@interp3_type=="Fourier") a0=2/3*(z1+z2+z3) a1=2/3*(z1-z2/2-z3/2) b1=sqrt(3)/3*(z2-z3) t=t*4*#pi/3 z=a0/2+a1*cos(t)+b1*sin(t) endif ; ; 4 functions ; elseif(@nfunction=="4") if(@slider4_type=="constant") t=(@slider4-1)/3 elseif(@slider4_type=="cos(iter)") t=(1-cos(@freq4*iter))/2 elseif(@slider4_type=="sin(iter)") t=(1+sin(@freq4*iter))/2 elseif(@slider4_type=="tanh(iter)") t=tanh(@freq4*iter) elseif(@slider4_type=="cos(real)") t=(1-cos(@freq4*real(z)))/2 elseif(@slider4_type=="sin(imag)") t=(1+sin(@freq4*imag(z)))/2 elseif(@slider4_type=="tanh(mag)") t=tanh(@freq4*cabs(z)) elseif(@slider4_type=="angle") t=(atan2(z)/#pi+1)/2 t=(t*@freq4)%1 endif if(@interp4_type=="Lagrange") t=t*3+1 z=z1*(t-2)*(t-3)*(t-4)/((1-2)*(1-3)*(1-4))\ +z2*(t-1)*(t-3)*(t-4)/((2-1)*(2-3)*(2-4))\ +z3*(t-1)*(t-2)*(t-4)/((3-1)*(3-2)*(3-4))\ +z4*(t-1)*(t-2)*(t-3)/((4-1)*(4-2)*(4-3)) elseif(@interp4_type=="Bezier") z=(1-t)^3*z1+3*sqr(1-t)*t*z2+3*(1-t)*sqr(t)*z3+t^3*z4 elseif(@interp4_type=="Fourier") a0=(z1+z2+z3+z4)/2 a1=(z1-z3)/2 a2=(z1-z2+z3-z4)/2 b1=(z2-z4)/2 b2=0 t=t*1.5*#pi z=a0/2+a1*cos(t)+a2/2*cos(2*t)+b1*sin(t)+b2*sin(2*t) endif ; ; 5 functions ; elseif(@nfunction=="5") if(@slider5_type=="constant") t=(@slider5-1)/4 elseif(@slider5_type=="cos(iter)") t=(1-cos(@freq5*iter))/2 elseif(@slider5_type=="sin(iter)") t=(1+sin(@freq5*iter))/2 elseif(@slider5_type=="tanh(iter)") t=tanh(@freq5*iter) elseif(@slider5_type=="cos(real)") t=(1-cos(@freq5*real(z)))/2 elseif(@slider5_type=="sin(imag)") t=(1+sin(@freq5*imag(z)))/2 elseif(@slider5_type=="tanh(mag)") t=tanh(@freq5*cabs(z)) elseif(@slider5_type=="angle") t=(atan2(z)/#pi+1)/2 t=(t*@freq5)%1 endif if(@interp5_type=="Lagrange") t=t*4+1 z=z1*(t-2)*(t-3)*(t-4)*(t-5)/((1-2)*(1-3)*(1-4)*(1-5))\ +z2*(t-1)*(t-3)*(t-4)*(t-5)/((2-1)*(2-3)*(2-4)*(2-5))\ +z3*(t-1)*(t-2)*(t-4)*(t-5)/((3-1)*(3-2)*(3-4)*(3-5))\ +z4*(t-1)*(t-2)*(t-3)*(t-5)/((4-1)*(4-2)*(4-3)*(4-5))\ +z5*(t-1)*(t-2)*(t-3)*(t-4)/((5-1)*(5-2)*(5-3)*(5-4)) elseif(@interp5_type=="Bezier") z=(1-t)^4*z1+4*(1-t)^3*t*z2+6*sqr(1-t)*sqr(t)*z3+4*(1-t)*t^3*z4\ +t^4*z5 elseif(@interp5_type=="Fourier") a0=0.4*(z1+z2+z3+z4+z5) a1=0.4*(z1+z2*cos(0.4*#pi)+z3*cos(0.8*#pi)+z4*cos(1.2*#pi)+z5*cos(1.6*#pi)) a2=0.4*(z1+z2*cos(0.8*#pi)+z3*cos(1.6*#pi)+z4*cos(2.4*#pi)+z5*cos(3.2*#pi)) b1=0.4*(z2*sin(0.4*#pi)+z3*sin(0.8*#pi)+z4*sin(1.2*#pi)+z5*sin(1.6*#pi)) b2=0.4*(z2*sin(0.8*#pi)+z3*sin(1.6*#pi)+z4*sin(2.4*#pi)+z5*sin(3.2*#pi)) t=t*1.6*#pi z=a0/2+a1*cos(t)+a2*cos(2*t)+b1*sin(t)+b2*sin(2*t) endif ; ; 6 functions ; elseif(@nfunction=="6") if(@slider6_type=="constant") t=(@slider6-1)/5 elseif(@slider6_type=="cos(iter)") t=(1-cos(@freq6*iter))/2 elseif(@slider6_type=="sin(iter)") t=(1+sin(@freq6*iter))/2 elseif(@slider6_type=="tanh(iter)") t=tanh(@freq6*iter) elseif(@slider6_type=="cos(real)") t=(1-cos(@freq6*real(z)))/2 elseif(@slider6_type=="sin(imag)") t=(1+sin(@freq6*imag(z)))/2 elseif(@slider6_type=="tanh(mag)") t=tanh(@freq6*cabs(z)) elseif(@slider6_type=="angle") t=(atan2(z)/#pi+1)/2 t=(t*@freq6)%1 endif if(@interp6_type=="Lagrange") t=t*5+1 z=z1*(t-2)*(t-3)*(t-4)*(t-5)*(t-6)/((1-2)*(1-3)*(1-4)*(1-5)*(1-6))\ +z2*(t-1)*(t-3)*(t-4)*(t-5)*(t-6)/((2-1)*(2-3)*(2-4)*(2-5)*(2-6))\ +z3*(t-1)*(t-2)*(t-4)*(t-5)*(t-6)/((3-1)*(3-2)*(3-4)*(3-5)*(3-6))\ +z4*(t-1)*(t-2)*(t-3)*(t-5)*(t-6)/((4-1)*(4-2)*(4-3)*(4-5)*(4-6))\ +z5*(t-1)*(t-2)*(t-3)*(t-4)*(t-6)/((5-1)*(5-2)*(5-3)*(5-4)*(5-6))\ +z6*(t-1)*(t-2)*(t-3)*(t-4)*(t-5)/((6-1)*(6-2)*(6-3)*(6-4)*(6-5)) elseif(@interp6_type=="Bezier") z=(1-t)^5*z1+5*(1-t)^4*t*z2+10*(1-t)^3*sqr(t)*z3+10*sqr(1-t)*t^3*z4\ +5*(1-t)*t^4*z5+t^5*z6 elseif(@interp6_type=="Fourier") a0=(z1+z2+z3+z4+z5+z6)/3 a1=(z1+z2/2-z3/2-z4-z5/2+z6/2)/3 a2=(z1-z2/2-z3/2+z4-z5/2-z6/2)/3 a3=(z1-z2+z3-z4+z5-z6)/3 b1=sqrt(3)/6*(z2+z3-z5-z6) b2=sqrt(3)/6*(z2-z3+z5-z6) b3=0 t=t*5*#pi/3 z=a0/2+a1*cos(t)+a2*cos(2*t)+a3/2*cos(3*t)+b1*sin(t)+b2*sin(2*t)+b3*sin(3*t) endif endif bailout: |z|<@bailout default: title="Interpolating Functions" heading text="Allows you to interpolate between several functions every iteration." endheading ; ; general parameters ; heading caption="General parameters" endheading param initz_type caption="initial z type" default=1 enum="manual" "pixel" endparam complex param initial_z caption="initial z" default=(0,0) visible=(@initz_type=="manual") endparam float param bailout caption="bailout" default=1000 endparam ; ; interpolating function defintions ; heading caption="Interpolating functions" endheading param nfunction caption="# of functions" default=1 enum="1" "2" "3" "4" "5" "6" endparam param fn1 caption="function 1" default=1 enum=" " "Mandelbrot 1" "Julia 1" "Newton M 1" "Newton J 1" "Popcorn C 1" "Popcorn R 1"\ "Mandelbrot 2" "Julia 2" "Newton M 2" "Newton J 2" "Popcorn C 2" "Popcorn R 2" endparam param fn2 caption="function 2" default=7 enum=" " "Mandelbrot 1" "Julia 1" "Newton M 1" "Newton J 1" "Popcorn C 1" "Popcorn R 1"\ "Mandelbrot 2" "Julia 2" "Newton M 2" "Newton J 2" "Popcorn C 2" "Popcorn R 2" visible=(@nfunction>0) endparam param fn3 caption="function 3" default=0 enum=" " "Mandelbrot 1" "Julia 1" "Newton M 1" "Newton J 1" "Popcorn C 1" "Popcorn R 1"\ "Mandelbrot 2" "Julia 2" "Newton M 2" "Newton J 2" "Popcorn C 2" "Popcorn R 2" visible=(@nfunction>1) endparam param fn4 caption="function 4" default=0 enum=" " "Mandelbrot 1" "Julia 1" "Newton M 1" "Newton J 1" "Popcorn C 1" "Popcorn R 1"\ "Mandelbrot 2" "Julia 2" "Newton M 2" "Newton J 2" "Popcorn C 2" "Popcorn R 2" visible=(@nfunction>2) endparam param fn5 caption="function 5" default=0 enum=" " "Mandelbrot 1" "Julia 1" "Newton M 1" "Newton J 1" "Popcorn C 1" "Popcorn R 1"\ "Mandelbrot 2" "Julia 2" "Newton M 2" "Newton J 2" "Popcorn C 2" "Popcorn R 2" visible=(@nfunction>3) endparam param fn6 caption="function 6" default=0 enum=" " "Mandelbrot 1" "Julia 1" "Newton M 1" "Newton J 1" "Popcorn C 1" "Popcorn R 1"\ "Mandelbrot 2" "Julia 2" "Newton M 2" "Newton J 2" "Popcorn C 2" "Popcorn R 2" visible=(@nfunction>4) endparam ; complex param m1power caption="Mandelbrot 1 power" default=(2,0) visible=((@fn1=="Mandelbrot 1")||(@fn2=="Mandelbrot 1")||(@fn3=="Mandelbrot 1")||\ (@fn4=="Mandelbrot 1")||(@fn5=="Mandelbrot 1")||(@fn6=="Mandelbrot 1")) endparam complex param j1power caption="Julia 1 power" default=(2,0) visible=((@fn1=="Julia 1")||(@fn2=="Julia 1")||(@fn3=="Julia 1")||\ (@fn4=="Julia 1")||(@fn5=="Julia 1")||(@fn6=="Julia 1")) endparam complex param j1param caption="Julia 1 parameter" default=(0,1) visible=((@fn1=="Julia 1")||(@fn2=="Julia 1")||(@fn3=="Julia 1")||\ (@fn4=="Julia 1")||(@fn5=="Julia 1")||(@fn6=="Julia 1")) endparam complex param nm1power caption="Newton M 1 power" default=(3,0) visible=((@fn1=="Newton M 1")||(@fn2=="Newton M 1")||(@fn3=="Newton M 1")||\ (@fn4=="Newton M 1")||(@fn5=="Newton M 1")||(@fn6=="Newton M 1")) endparam complex param nm1weight caption="Newton M 1 nova fac" default=1 visible=((@fn1=="Newton M 1")||(@fn2=="Newton M 1")||(@fn3=="Newton M 1")||\ (@fn4=="Newton M 1")||(@fn5=="Newton M 1")||(@fn6=="Newton M 1")) endparam complex param nj1power caption="Newton J 1 power" default=(4,0) visible=((@fn1=="Newton J 1")||(@fn2=="Newton J 1")||(@fn3=="Newton J 1")||\ (@fn4=="Newton J 1")||(@fn5=="Newton J 1")||(@fn6=="Newton J 1")) endparam complex param nj1param caption="Newton J 1 parameter" default=(1,0) visible=((@fn1=="Newton J 1")||(@fn2=="Newton J 1")||(@fn3=="Newton J 1")||\ (@fn4=="Newton J 1")||(@fn5=="Newton J 1")||(@fn6=="Newton J 1")) endparam complex param nj1weight caption="Newton J 1 nova fac" default=1 visible=((@fn1=="Newton J 1")||(@fn2=="Newton J 1")||(@fn3=="Newton J 1")||\ (@fn4=="Newton J 1")||(@fn5=="Newton J 1")||(@fn6=="Newton J 1")) endparam complex param pc1h caption="complex step size 1" default=(0.1,0) visible=((@fn1=="Popcorn C 1")||(@fn2=="Popcorn C 1")||(@fn3=="Popcorn C 1")||\ (@fn4=="Popcorn C 1")||(@fn5=="Popcorn C 1")||(@fn6=="Popcorn C 1")) endparam complex param pc1c caption="complex frequency 1" default=(3,0) visible=((@fn1=="Popcorn C 1")||(@fn2=="Popcorn C 1")||(@fn3=="Popcorn C 1")||\ (@fn4=="Popcorn C 1")||(@fn5=="Popcorn C 1")||(@fn6=="Popcorn C 1")) endparam func pc1out caption="complex outer function 1" default=sin() visible=((@fn1=="Popcorn C 1")||(@fn2=="Popcorn C 1")||(@fn3=="Popcorn C 1")||\ (@fn4=="Popcorn C 1")||(@fn5=="Popcorn C 1")||(@fn6=="Popcorn C 1")) endfunc func pc1in caption="complex inner function 1" default=tan() visible=((@fn1=="Popcorn C 1")||(@fn2=="Popcorn C 1")||(@fn3=="Popcorn C 1")||\ (@fn4=="Popcorn C 1")||(@fn5=="Popcorn C 1")||(@fn6=="Popcorn C 1")) endfunc float param pr1h caption="real step size 1" default=0.1 visible=((@fn1=="Popcorn R 1")||(@fn2=="Popcorn R 1")||(@fn3=="Popcorn R 1")||\ (@fn4=="Popcorn R 1")||(@fn5=="Popcorn R 1")||(@fn6=="Popcorn R 1")) endparam float param pr1c caption="real frequency 1" default=3 visible=((@fn1=="Popcorn R 1")||(@fn2=="Popcorn R 1")||(@fn3=="Popcorn R 1")||\ (@fn4=="Popcorn R 1")||(@fn5=="Popcorn R 1")||(@fn6=="Popcorn R 1")) endparam func pr1out caption="real outer function 1" default=sin() visible=((@fn1=="Popcorn R 1")||(@fn2=="Popcorn R 1")||(@fn3=="Popcorn R 1")||\ (@fn4=="Popcorn R 1")||(@fn5=="Popcorn R 1")||(@fn6=="Popcorn R 1")) endfunc func pr1in caption="real inner function 1" default=tan() visible=((@fn1=="Popcorn R 1")||(@fn2=="Popcorn R 1")||(@fn3=="Popcorn R 1")||\ (@fn4=="Popcorn R 1")||(@fn5=="Popcorn R 1")||(@fn6=="Popcorn R 1")) endfunc complex param m2power caption="Mandelbrot 2 power" default=(4,0) visible=((@fn1=="Mandelbrot 2")||(@fn2=="Mandelbrot 2")||(@fn3=="Mandelbrot 2")||\ (@fn4=="Mandelbrot 2")||(@fn5=="Mandelbrot 2")||(@fn6=="Mandelbrot 2")) endparam complex param j2power caption="Julia 2 power" default=(4,0) visible=((@fn1=="Julia 2")||(@fn2=="Julia 2")||(@fn3=="Julia 2")||\ (@fn4=="Julia 2")||(@fn5=="Julia 2")||(@fn6=="Julia 2")) endparam complex param j2param caption="Julia 2 parameter" default=(-1.26,0) visible=((@fn1=="Julia 2")||(@fn2=="Julia 2")||(@fn3=="Julia 2")||\ (@fn4=="Julia 2")||(@fn5=="Julia 2")||(@fn6=="Julia 2")) endparam complex param nm2power caption="Newton M 2 power" default=(3,0) visible=((@fn1=="Newton M 2")||(@fn2=="Newton M 2")||(@fn3=="Newton M 2")||\ (@fn4=="Newton M 2")||(@fn5=="Newton M 2")||(@fn6=="Newton M 2")) endparam complex param nm2weight caption="Newton M 2 nova fac" default=1 visible=((@fn1=="Newton M 2")||(@fn2=="Newton M 2")||(@fn3=="Newton M 2")||\ (@fn4=="Newton M 2")||(@fn5=="Newton M 2")||(@fn6=="Newton M 2")) endparam complex param nj2power caption="Newton J 2 power" default=(4,0) visible=((@fn1=="Newton J 2")||(@fn2=="Newton J 2")||(@fn3=="Newton J 2")||\ (@fn4=="Newton J 2")||(@fn5=="Newton J 2")||(@fn6=="Newton J 2")) endparam complex param nj2param caption="Newton J 2 parameter" default=(1,0) visible=((@fn1=="Newton J 2")||(@fn2=="Newton J 2")||(@fn3=="Newton J 2")||\ (@fn4=="Newton J 2")||(@fn5=="Newton J 2")||(@fn6=="Newton J 2")) endparam complex param nj2weight caption="Newton J 2 nova fac" default=(1,0) visible=((@fn1=="Newton J 2")||(@fn2=="Newton J 2")||(@fn3=="Newton J 2")||\ (@fn4=="Newton J 2")||(@fn5=="Newton J 2")||(@fn6=="Newton J 2")) endparam complex param pc2h caption="complex step size 2" default=(0.1,0) visible=((@fn1=="Popcorn C 2")||(@fn2=="Popcorn C 2")||(@fn3=="Popcorn C 2")||\ (@fn4=="Popcorn C 2")||(@fn5=="Popcorn C 2")||(@fn6=="Popcorn C 2")) endparam complex param pc2c caption="complex frequency 2" default=(3,0) visible=((@fn1=="Popcorn C 2")||(@fn2=="Popcorn C 2")||(@fn3=="Popcorn C 2")||\ (@fn4=="Popcorn C 2")||(@fn5=="Popcorn C 2")||(@fn6=="Popcorn C 2")) endparam func pc2out caption="complex outer function 2" default=sin() visible=((@fn1=="Popcorn C 2")||(@fn2=="Popcorn C 2")||(@fn3=="Popcorn C 2")||\ (@fn4=="Popcorn C 2")||(@fn5=="Popcorn C 2")||(@fn6=="Popcorn C 2")) endfunc func pc2in caption="complex inner function 2" default=tan() visible=((@fn1=="Popcorn C 2")||(@fn2=="Popcorn C 2")||(@fn3=="Popcorn C 2")||\ (@fn4=="Popcorn C 2")||(@fn5=="Popcorn C 2")||(@fn6=="Popcorn C 2")) endfunc float param pr2h caption="real step size 2" default=0.1 visible=((@fn1=="Popcorn R 2")||(@fn2=="Popcorn R 2")||(@fn3=="Popcorn R 2")||\ (@fn4=="Popcorn R 2")||(@fn5=="Popcorn R 2")||(@fn6=="Popcorn R 2")) endparam float param pr2c caption="real frequency 2" default=3 visible=((@fn1=="Popcorn R 2")||(@fn2=="Popcorn R 2")||(@fn3=="Popcorn R 2")||\ (@fn4=="Popcorn R 2")||(@fn5=="Popcorn R 2")||(@fn6=="Popcorn R 2")) endparam func pr2out caption="real outer function 2" default=sin() visible=((@fn1=="Popcorn R 2")||(@fn2=="Popcorn R 2")||(@fn3=="Popcorn R 2")||\ (@fn4=="Popcorn R 2")||(@fn5=="Popcorn R 2")||(@fn6=="Popcorn R 2")) endfunc func pr2in caption="real inner function 2" default=tan() visible=((@fn1=="Popcorn R 2")||(@fn2=="Popcorn R 2")||(@fn3=="Popcorn R 2")||\ (@fn4=="Popcorn R 2")||(@fn5=="Popcorn R 2")||(@fn6=="Popcorn R 2")) endfunc ; ; interpolation ; heading caption="Interpolation" endheading ; ; 2 functions ; param slider2_type caption="slider type" default=0 enum="constant" "cos(iter)" "sin(iter)" "tanh(iter)" \ "cos(real)" "sin(imag)" "tanh(mag)" "angle" visible=(@nfunction=="2") endparam float param slider2 caption="slider value" default=1.5 min=1 max=2 hint="1 for z1, 2 for z2" visible=((@nfunction=="2")&&(@slider2_type=="constant")) endparam float param freq2 caption="frequency" default=1 min=0 visible=((@nfunction=="2")&&(@slider2_type!="constant")) endparam ; ; 3 functions ; param interp3_type caption="interpolation type" default=0 enum="Lagrange" "Bezier" "Fourier" visible=(@nfunction=="3") endparam param slider3_type caption="slider type" default=0 enum="constant" "cos(iter)" "sin(iter)" "tanh(iter)" \ "cos(real)" "sin(imag)" "tanh(mag)" "angle" visible=(@nfunction=="3") endparam float param slider3 caption="slider value" default=2 min=1 max=3 hint="1 for z1, 2 for z2, 3 for z3" visible=((@nfunction=="3")&&(@slider3_type=="constant")) endparam float param freq3 caption="frequency" default=1 min=0 visible=((@nfunction=="3")&&(@slider3_type!="constant")) endparam ; ; 4 functions ; param interp4_type caption="interpolation type" default=0 enum="Lagrange" "Bezier" "Fourier" visible=(@nfunction=="4") endparam param slider4_type caption="slider type" default=0 enum="constant" "cos(iter)" "sin(iter)" "tanh(iter)" \ "cos(real)" "sin(imag)" "tanh(mag)" "angle" visible=(@nfunction=="4") endparam float param slider4 caption="slider value" default=2.5 min=1 max=4 hint="1 for z1 to 4 for z4" visible=((@nfunction=="4")&&(@slider4_type=="constant")) endparam float param freq4 caption="frequency" default=1 min=0 visible=((@nfunction=="4")&&(@slider4_type!="constant")) endparam ; ; 5 functions ; param interp5_type caption="interpolation type" default=0 enum="Lagrange" "Bezier" "Fourier" visible=(@nfunction=="5") endparam param slider5_type caption="slider type" default=0 enum="constant" "cos(iter)" "sin(iter)" "tanh(iter)" \ "cos(real)" "sin(imag)" "tanh(mag)" "angle" visible=(@nfunction=="5") endparam float param slider5 caption="slider value" default=3 min=1 max=5 hint="1 for z1 to 5 for z5" visible=((@nfunction=="5")&&(@slider5_type=="constant")) endparam float param freq5 caption="frequency" default=1 min=0 visible=((@nfunction=="5")&&(@slider5_type!="constant")) endparam ; ; 6 functions ; param interp6_type caption="interpolation type" default=0 enum="Lagrange" "Bezier" "Fourier" visible=(@nfunction=="6") endparam param slider6_type caption="slider type" default=0 enum="constant" "cos(iter)" "sin(iter)" "tanh(iter)" \ "cos(real)" "sin(imag)" "tanh(mag)" "angle" visible=(@nfunction=="6") endparam float param slider6 caption="slider value" default=3.5 min=1 max=6 hint="1 for z1 to 6 for z6" visible=((@nfunction=="6")&&(@slider6_type=="constant")) endparam float param freq6 caption="frequency" default=1 min=0 visible=((@nfunction=="6")&&(@slider6_type!="constant")) endparam } fourier-popcorn { ; Kerry Mitchell 17May2015 ; ; This is a complex-valued implementation and generalization ; of Cliff Pickover's "popcorn" algorithm. His method iterates ; 2 real variables like this: ; ; xnew = xold - h * sin(a*y + tan(b*y)) ; ynew = yold - h * sin(a*x + tan(b*x)) ; ; where a = 1. The current method generalizes the above by: ; using truncated Fourier series instead of just single sin or tan function ; allowing for complex values of a (slope) ; having the same Fourier series parameters (basic controls) or ; having different parameters for the 4 series (x inner, x outer, ; y inner, and y outer) ; init: complex temp=(0,0) complex tempx=(0,0) complex tempy=(0,0) complex temp2=(0,0) complex temp2x=(0,0) complex temp2y=(0,0) complex tempin=(0,0) complex tempinx=(0,0) complex tempiny=(0,0) complex tempout=(0,0) complex tempoutx=(0,0) complex tempouty=(0,0) complex x=real(#pixel) complex y=imag(#pixel) complex xnew=(0,0) complex ynew=(0,0) complex z=#pixel int iterm=0 int jterm=0 int parity=1 loop: ; ; basic controls ; if(@control_type=="basic") ; ; choose what inner variable to use ; tempinx=y tempiny=x ; ; compute the inner Fourier series ; tempx=0 tempy=0 iterm=0 while(iterm<@ntermall) iterm=iterm+1 if(@functypeall=="sin odd pos") jterm=2*iterm-1 tempx=tempx+sin(tempinx*jterm)/(jterm^@powerall) tempy=tempy+sin(tempiny*jterm)/(jterm^@powerall) elseif(@functypeall=="cos odd pos") jterm=2*iterm-1 tempx=tempx+cos(tempinx*jterm)/(jterm^@powerall) tempy=tempy+cos(tempiny*jterm)/(jterm^@powerall) elseif(@functypeall=="sin all pos") jterm=iterm tempx=tempx+sin(tempinx*jterm)/(jterm^@powerall) tempy=tempy+sin(tempiny*jterm)/(jterm^@powerall) elseif(@functypeall=="cos all pos") jterm=iterm tempx=tempx+cos(tempinx*jterm)/(jterm^@powerall) tempy=tempy+cos(tempiny*jterm)/(jterm^@powerall) elseif(@functypeall=="sin odd alt") jterm=2*iterm-1 parity=(iterm%2)*2-1 tempx=tempx+parity*sin(tempinx*jterm)/(jterm^@powerall) tempy=tempy+parity*sin(tempiny*jterm)/(jterm^@powerall) elseif(@functypeall=="cos odd alt") jterm=2*iterm-1 parity=(iterm%2)*2-1 tempx=tempx+parity*cos(tempinx*jterm)/(jterm^@powerall) tempy=tempy+parity*cos(tempiny*jterm)/(jterm^@powerall) elseif(@functypeall=="sin all alt") jterm=iterm parity=(iterm%2)*2-1 tempx=tempx+parity*sin(tempinx*jterm)/(jterm^@powerall) tempy=tempy+parity*sin(tempiny*jterm)/(jterm^@powerall) elseif(@functypeall=="cos all alt") jterm=iterm parity=(iterm%2)*2-1 tempx=tempx+parity*cos(tempinx*jterm)/(jterm^@powerall) tempy=tempy+parity*cos(tempiny*jterm)/(jterm^@powerall) elseif(@functypeall=="sin general") jterm=iterm tempx=tempx+@funcall(jterm)*sin(tempinx*jterm)/(jterm^@powerall) tempy=tempy+@funcall(jterm)*sin(tempiny*jterm)/(jterm^@powerall) elseif(@functypeall=="cos general") jterm=iterm tempx=tempx+@funcall(jterm)*cos(tempinx*jterm)/(jterm^@powerall) tempy=tempy+@funcall(jterm)*cos(tempiny*jterm)/(jterm^@powerall) endif endwhile ; ; choose what outer variable to use ; tempoutx=y tempouty=x ; ; compute the outer Fourier series ; temp2x=0 temp2y=0 iterm=0 while(iterm<@ntermall) iterm=iterm+1 if(@functypeall=="sin odd pos") jterm=2*iterm-1 temp2x=temp2x+sin((@slopeall*tempoutx+tempx)*jterm)/(jterm^@powerall) temp2y=temp2y+sin((@slopeall*tempouty+tempy)*jterm)/(jterm^@powerall) elseif(@functypeall=="cos odd pos") jterm=2*iterm-1 temp2x=temp2x+cos((@slopeall*tempoutx+tempx)*jterm)/(jterm^@powerall) temp2y=temp2y+cos((@slopeall*tempouty+tempy)*jterm)/(jterm^@powerall) elseif(@functypeall=="sin all pos") jterm=iterm temp2x=temp2x+sin((@slopeall*tempoutx+tempx)*jterm)/(jterm^@powerall) temp2y=temp2y+sin((@slopeall*tempouty+tempy)*jterm)/(jterm^@powerall) elseif(@functypeall=="cos all pos") jterm=iterm temp2x=temp2x+cos((@slopeall*tempoutx+tempx)*jterm)/(jterm^@powerall) temp2y=temp2y+cos((@slopeall*tempouty+tempy)*jterm)/(jterm^@powerall) elseif(@functypeall=="sin odd alt") jterm=2*iterm-1 parity=(iterm%2)*2-1 temp2x=temp2x+parity*sin((@slopeall*tempoutx+tempx)*jterm)/(jterm^@powerall) temp2y=temp2y+parity*sin((@slopeall*tempouty+tempy)*jterm)/(jterm^@powerall) elseif(@functypeall=="cos odd alt") jterm=2*iterm-1 parity=(iterm%2)*2-1 temp2x=temp2x+parity*cos((@slopeall*tempoutx+tempx)*jterm)/(jterm^@powerall) temp2y=temp2y+parity*cos((@slopeall*tempouty+tempy)*jterm)/(jterm^@powerall) elseif(@functypeall=="sin all alt") jterm=iterm parity=(iterm%2)*2-1 temp2x=temp2x+parity*sin((@slopeall*tempoutx+tempx)*jterm)/(jterm^@powerall) temp2y=temp2y+parity*sin((@slopeall*tempouty+tempy)*jterm)/(jterm^@powerall) elseif(@functypeall=="cos all alt") jterm=iterm parity=(iterm%2)*2-1 temp2x=temp2x+parity*cos((@slopeall*tempoutx+tempx)*jterm)/(jterm^@powerall) temp2y=temp2y+parity*cos((@slopeall*tempouty+tempy)*jterm)/(jterm^@powerall) elseif(@functypeall=="sin general") jterm=iterm temp2x=temp2x+@funcall(jterm)*sin((@slopeall*tempoutx+tempx)*jterm)/(jterm^@powerall) temp2y=temp2y+@funcall(jterm)*sin((@slopeall*tempouty+tempy)*jterm)/(jterm^@powerall) elseif(@functypeall=="cos general") jterm=iterm temp2x=temp2x+@funcall(jterm)*cos((@slopeall*tempoutx+tempx)*jterm)/(jterm^@powerall) temp2y=temp2y+@funcall(jterm)*cos((@slopeall*tempouty+tempy)*jterm)/(jterm^@powerall) endif endwhile xnew=x+@hall*temp2x ynew=y+@hall*temp2y x=xnew y=ynew z=x+flip(y) ; ; advanced controls ; else ; ; x equation ; ; choose what inner variable to use ; if(@vartypexin=="x") tempin=x elseif(@vartypexin=="y") tempin=y elseif(@vartypexin=="x+y") tempin=x+y elseif(@vartypexin=="y-x") tempin=y-x elseif(@vartypexin=="x*y") tempin=x*y elseif(@vartypexin=="y/x") tempin=y/x endif ; ; compute the inner Fourier series ; temp=0 iterm=0 while(iterm<@ntermxin) iterm=iterm+1 if(@functypexin=="sin odd pos") jterm=2*iterm-1 temp=temp+sin(tempin*jterm)/(jterm^@powerxin) elseif(@functypexin=="cos odd pos") jterm=2*iterm-1 temp=temp+cos(tempin*jterm)/(jterm^@powerxin) elseif(@functypexin=="sin all pos") jterm=iterm temp=temp+sin(tempin*jterm)/(jterm^@powerxin) elseif(@functypexin=="cos all pos") jterm=iterm temp=temp+cos(tempin*jterm)/(jterm^@powerxin) elseif(@functypexin=="sin odd alt") jterm=2*iterm-1 parity=(iterm%2)*2-1 temp=temp+parity*sin(tempin*jterm)/(jterm^@powerxin) elseif(@functypexin=="cos odd alt") jterm=2*iterm-1 parity=(iterm%2)*2-1 temp=temp+parity*cos(tempin*jterm)/(jterm^@powerxin) elseif(@functypexin=="sin all alt") jterm=iterm parity=(iterm%2)*2-1 temp=temp+parity*sin(tempin*jterm)/(jterm^@powerxin) elseif(@functypexin=="cos all alt") jterm=iterm parity=(iterm%2)*2-1 temp=temp+parity*cos(tempin*jterm)/(jterm^@powerxin) elseif(@functypexin=="sin general") jterm=iterm temp=temp+@funcxin(jterm)*sin(tempin*jterm)/(jterm^@powerxin) elseif(@functypexin=="cos general") jterm=iterm temp=temp+@funcxin(jterm)*cos(tempin*jterm)/(jterm^@powerxin) endif endwhile ; ; choose what outer variable to use ; if(@vartypexout=="x") tempout=x elseif(@vartypexout=="y") tempout=y elseif(@vartypexout=="x+y") tempout=x+y elseif(@vartypexout=="y-x") tempout=y-x elseif(@vartypexout=="x*y") tempout=x*y elseif(@vartypexout=="y/x") tempout=y/x endif ; ; compute the outer Fourier series ; temp2=0 iterm=0 while(iterm<@ntermxout) iterm=iterm+1 if(@functypexout=="sin odd pos") jterm=2*iterm-1 temp2=temp2+sin((@slopexout*tempout+temp)*jterm)/(jterm^@powerxout) elseif(@functypexout=="cos odd pos") jterm=2*iterm-1 temp2=temp2+cos((@slopexout*tempout+temp)*jterm)/(jterm^@powerxout) elseif(@functypexout=="sin all pos") jterm=iterm temp2=temp2+sin((@slopexout*tempout+temp)*jterm)/(jterm^@powerxout) elseif(@functypexout=="cos all pos") jterm=iterm temp2=temp2+cos((@slopexout*tempout+temp)*jterm)/(jterm^@powerxout) elseif(@functypexout=="sin odd alt") jterm=2*iterm-1 parity=(iterm%2)*2-1 temp2=temp2+parity*sin((@slopexout*tempout+temp)*jterm)/(jterm^@powerxout) elseif(@functypexout=="cos odd alt") jterm=2*iterm-1 parity=(iterm%2)*2-1 temp2=temp2+parity*cos((@slopexout*tempout+temp)*jterm)/(jterm^@powerxout) elseif(@functypexout=="sin all alt") jterm=iterm parity=(iterm%2)*2-1 temp2=temp2+parity*sin((@slopexout*tempout+temp)*jterm)/(jterm^@powerxout) elseif(@functypexout=="cos all alt") jterm=iterm parity=(iterm%2)*2-1 temp2=temp2+parity*cos((@slopexout*tempout+temp)*jterm)/(jterm^@powerxout) elseif(@functypexout=="sin general") jterm=iterm temp2=temp2+@funcxout(jterm)*sin((@slopexout*tempout+temp)*jterm)/(jterm^@powerxout) elseif(@functypexout=="cos general") jterm=iterm temp2=temp2+@funcxout(jterm)*cos((@slopexout*tempout+temp)*jterm)/(jterm^@powerxout) endif endwhile xnew=x+@hx*temp2 ; ; y equation ; ; choose what inner variable to use ; if(@vartypeyin=="x") tempin=x elseif(@vartypeyin=="y") tempin=y elseif(@vartypeyin=="x+y") tempin=x+y elseif(@vartypeyin=="y-x") tempin=y-x elseif(@vartypeyin=="x*y") tempin=x*y elseif(@vartypeyin=="y/x") tempin=y/x endif ; ; compute the inner Fourier series ; temp=0 iterm=0 while(iterm<@ntermyin) iterm=iterm+1 if(@functypeyin=="sin odd pos") jterm=2*iterm-1 temp=temp+sin(tempin*jterm)/(jterm^@poweryin) elseif(@functypeyin=="cos odd pos") jterm=2*iterm-1 temp=temp+cos(tempin*jterm)/(jterm^@poweryin) elseif(@functypeyin=="sin all pos") jterm=iterm temp=temp+sin(tempin*jterm)/(jterm^@poweryin) elseif(@functypeyin=="cos all pos") jterm=iterm temp=temp+cos(tempin*jterm)/(jterm^@poweryin) elseif(@functypeyin=="sin odd alt") jterm=2*iterm-1 parity=(iterm%2)*2-1 temp=temp+parity*sin(tempin*jterm)/(jterm^@poweryin) elseif(@functypeyin=="cos odd alt") jterm=2*iterm-1 parity=(iterm%2)*2-1 temp=temp+parity*cos(tempin*jterm)/(jterm^@poweryin) elseif(@functypeyin=="sin all alt") jterm=iterm parity=(iterm%2)*2-1 temp=temp+parity*sin(tempin*jterm)/(jterm^@poweryin) elseif(@functypeyin=="cos all alt") jterm=iterm parity=(iterm%2)*2-1 temp=temp+parity*cos(tempin*jterm)/(jterm^@poweryin) elseif(@functypeyin=="sin general") jterm=iterm temp=temp+@funcyin(jterm)*sin(tempin*jterm)/(jterm^@poweryin) elseif(@functypeyin=="cos general") jterm=iterm temp=temp+@funcyin(jterm)*cos(tempin*jterm)/(jterm^@poweryin) endif endwhile ; ; choose what outer variable to use ; if(@vartypeyout=="x") tempout=x elseif(@vartypeyout=="y") tempout=y elseif(@vartypeyout=="x+y") tempout=x+y elseif(@vartypeyout=="y-x") tempout=y-x elseif(@vartypeyout=="x*y") tempout=x*y elseif(@vartypeyout=="y/x") tempout=y/x endif ; ; compute the outer Fourier series ; temp2=0 iterm=0 while(iterm<@ntermyout) iterm=iterm+1 if(@functypeyout=="sin odd pos") jterm=2*iterm-1 temp2=temp2+sin((@slopeyout*tempout+temp)*jterm)/(jterm^@poweryout) elseif(@functypeyout=="cos odd pos") jterm=2*iterm-1 temp2=temp2+cos((@slopeyout*tempout+temp)*jterm)/(jterm^@poweryout) elseif(@functypeyout=="sin all pos") jterm=iterm temp2=temp2+sin((@slopeyout*tempout+temp)*jterm)/(jterm^@poweryout) elseif(@functypeyout=="cos all pos") jterm=iterm temp2=temp2+cos((@slopeyout*tempout+temp)*jterm)/(jterm^@poweryout) elseif(@functypeyout=="sin odd alt") jterm=2*iterm-1 parity=(iterm%2)*2-1 temp2=temp2+parity*sin((@slopeyout*tempout+temp)*jterm)/(jterm^@poweryout) elseif(@functypeyout=="cos odd alt") jterm=2*iterm-1 parity=(iterm%2)*2-1 temp2=temp2+parity*cos((@slopeyout*tempout+temp)*jterm)/(jterm^@poweryout) elseif(@functypeyout=="sin all alt") jterm=iterm parity=(iterm%2)*2-1 temp2=temp2+parity*sin((@slopeyout*tempout+temp)*jterm)/(jterm^@poweryout) elseif(@functypeyout=="cos all alt") jterm=iterm parity=(iterm%2)*2-1 temp2=temp2+parity*cos((@slopeyout*tempout+temp)*jterm)/(jterm^@poweryout) elseif(@functypeyout=="sin general") jterm=iterm temp2=temp2+@funcyout(jterm)*sin((@slopeyout*tempout+temp)*jterm)/(jterm^@poweryout) elseif(@functypeyout=="cos general") jterm=iterm temp2=temp2+@funcyout(jterm)*cos((@slopeyout*tempout+temp)*jterm)/(jterm^@poweryout) endif endwhile ynew=y+@hy*temp2 x=xnew y=ynew z=x+flip(y) endif bailout: |z|<@bailout default: title="Fourier Popcorn" heading text="Uses Cliff Pickover's Popcorn routine, substituting Fourier \ series for the sine and tangent functions." endheading ; ; general parameters ; heading caption="General parameters" endheading param control_type caption="control type" default=0 enum="basic" "advanced" endparam float param bailout caption="bailout value" default=1000 endparam ; ; basic parameters ; heading caption="Fourier series parameters" visible=(@control_type=="basic") endheading complex param hall caption="step size" default=0.1 visible=(@control_type=="basic") endparam param functypeall caption="function type" default=0 enum="sin odd pos" "cos odd pos" "sin all pos" "cos all pos" \ "sin odd alt" "cos odd alt" "sin all alt" "cos all alt" \ "sin general" "cos general" visible=(@control_type=="basic") endparam complex param powerall caption="power" default=1 visible=(@control_type=="basic") endparam int param ntermall caption="# terms" default=10 min=0 visible=(@control_type=="basic") endparam complex param slopeall caption="slope" default=1 visible=(@control_type=="basic") endparam func funcall caption="function" default=tan() visible=((@control_type=="basic")&&((@functypeall=="sin general")\ ||(@functypeall=="cos general"))) endfunc ; ; advanced parameters ; ; x inner parameters ; heading caption="x inner parameters" visible=(@control_type=="advanced") endheading complex param hx caption="step size" default=0.1 visible=(@control_type=="advanced") endparam param vartypexin caption="inner variable type" default=1 enum="x" "y" "x+y" "y-x" "x*y" "y/x" visible=(@control_type=="advanced") endparam param functypexin caption="function type" default=1 enum="sin odd pos" "cos odd pos" "sin all pos" "cos all pos" \ "sin odd alt" "cos odd alt" "sin all alt" "cos all alt" \ "sin general" "cos general" visible=(@control_type=="advanced") endparam complex param powerxin caption="power" default=1 visible=(@control_type=="advanced") endparam int param ntermxin caption="# terms" default=10 min=0 visible=(@control_type=="advanced") endparam func funcxin caption="function" default=cos() visible=((@control_type=="advanced")&&((@functypexin=="sin general")\ ||(@functypexin=="cos general"))) endfunc ; ; x outer parameters ; heading caption="x outer parameters" visible=(@control_type=="advanced") endheading param vartypexout caption="outer variable type" default=1 enum="x" "y" "x+y" "y-x" "x*y" "y/x" visible=(@control_type=="advanced") endparam param functypexout caption="function type" default=1 enum="sin odd pos" "cos odd pos" "sin all pos" "cos all pos" \ "sin odd alt" "cos odd alt" "sin all alt" "cos all alt" \ "sin general" "cos general" visible=(@control_type=="advanced") endparam complex param powerxout caption="power" default=1 visible=(@control_type=="advanced") endparam int param ntermxout caption="# terms" default=10 min=0 visible=(@control_type=="advanced") endparam complex param slopexout caption="slope" default=1 visible=(@control_type=="advanced") endparam func funcxout caption="function" default=cos() visible=((@control_type=="advanced")&&((@functypexout=="sin general")\ ||(@functypexout=="cos general"))) endfunc ; ; y inner parameters ; heading caption="y inner parameters" visible=(@control_type=="advanced") endheading complex param hy caption="step size" default=0.1 visible=(@control_type=="advanced") endparam param vartypeyin caption="inner variable type" default=0 enum="x" "y" "x+y" "y-x" "x*y" "y/x" visible=(@control_type=="advanced") endparam param functypeyin caption="function type" default=0 enum="sin odd pos" "cos odd pos" "sin all pos" "cos all pos" \ "sin odd alt" "cos odd alt" "sin all alt" "cos all alt" \ "sin general" "cos general" visible=(@control_type=="advanced") endparam complex param poweryin caption="power" default=1 visible=(@control_type=="advanced") endparam int param ntermyin caption="# terms" default=10 min=0 visible=(@control_type=="advanced") endparam func funcyin caption="function" default=sin() visible=((@control_type=="advanced")&&((@functypeyin=="sin general")\ ||(@functypeyin=="cos general"))) endfunc ; ; y outer parameters ; heading caption="y outer parameters" visible=(@control_type=="advanced") endheading param vartypeyout caption="outer variable type" default=0 enum="x" "y" "x+y" "y-x" "x*y" "y/x" visible=(@control_type=="advanced") endparam param functypeyout caption="function type" default=0 enum="sin odd pos" "cos odd pos" "sin all pos" "cos all pos" \ "sin odd alt" "cos odd alt" "sin all alt" "cos all alt" \ "sin general" "cos general" visible=(@control_type=="advanced") endparam complex param poweryout caption="power" default=1 visible=(@control_type=="advanced") endparam int param ntermyout caption="# terms" default=10 min=0 visible=(@control_type=="advanced") endparam complex param slopeyout caption="slope" default=1 visible=(@control_type=="advanced") endparam func funcyout caption="function" default=sin() visible=((@control_type=="advanced")&&((@functypeyout=="sin general")\ ||(@functypeyout=="cos general"))) endfunc } breaking-newton-real { ; Kerry Mitchell 28Jul2018 ; ; force chaos into newton's method ; by changing c and/or z and/or Newton factor each iteration ; init: complex c=(0,0) complex dz=(0,0) complex g=(0,0) complex gp=(0,0) complex incrementc=(0,0) complex incrementfac=(0,0) complex incrementz=(0,0) complex newtfac=(0,0) complex z=(0,0) complex zc=(0,0) float cx=0 float cy=0 float dx=0 float dy=0 float facx=0 float facy=0 float gx=0 float gxp=0 float gy=0 float gyp=0 float x=0 float y=0 ; ; initializations ; if(@pixel_type=="initial c") c=#pixel incrementc=@cinc zc=@initialz incrementz=@zinc newtfac=@initialfac incrementfac=@facinc elseif(@pixel_type=="c change") c=@initialc incrementc=#pixel zc=@initialz incrementz=@zinc newtfac=@initialfac incrementfac=@facinc elseif(@pixel_type=="initial z") c=@initialc incrementc=@cinc zc=#pixel incrementz=@zinc newtfac=@initialfac incrementfac=@facinc elseif(@pixel_type=="z change") c=@initialc incrementc=@cinc zc=@initialz incrementz=#pixel newtfac=@initialfac incrementfac=@facinc elseif(@pixel_type=="initial Newton factor") c=@initialc incrementc=@cinc zc=@initialz incrementz=@zinc newtfac=#pixel incrementfac=@facinc elseif(@pixel_type=="Newton factor change") c=@initialc incrementc=@cinc zc=@initialz incrementz=@zinc newtfac=@initialfac incrementfac=#pixel endif loop: ; ; iterate ; ; x equation ; cx=real(c) facx=real(newtfac) x=real(zc) if(@x_type=="x^2 = c") gx=x^2-cx gxp=2*x elseif(@x_type=="x^4 = c") gx=x^4-cx gxp=4*x^3 elseif(@x_type=="x^6 = c") gx=x^6-cx gxp=6*x^5 elseif(@x_type=="sin(x) = c") gx=sin(@freqx*x)-cx gxp=@freqx*cos(@freqx*x) elseif(@x_type=="cos(x) = c") gx=cos(@freqx*x)-cx gxp=-@freqx*sin(@freqx*x) elseif(@x_type=="tanh(x) = c") gx=tanh(@freqx*x)-cx gxp=@freqx/sqr(cosh(@freqx*x)) elseif(@x_type=="exp(x) = c") gxp=exp(x) gx=gxp-cx endif dx=gx/gxp x=x-facx*dx ; ; y equation ; cy=imag(c) facy=imag(newtfac) y=imag(zc) if(@y_type=="y^2 = c") gy=y^2-cy gyp=2*y elseif(@y_type=="y^4 = c") gy=y^4-cy gyp=4*y^3 elseif(@y_type=="y^6 = c") gy=y^6-cy gyp=6*y^5 elseif(@y_type=="sin(y) = c") gy=sin(@freqy*y)-cy gyp=@freqy*cos(@freqy*y) elseif(@y_type=="cos(y) = c") gy=cos(@freqy*y)-cy gyp=-@freqy*sin(@freqy*y) elseif(@y_type=="tanh(y) = c") gy=tanh(@freqy*y)-cy gyp=@freqy/sqr(cosh(@freqy*y)) elseif(@y_type=="exp(y) = c") gyp=exp(y) gy=gyp-cy endif dy=gy/gyp y=y-facy*dy ; ; combine both equations & find new zc ; g=gx+flip(gy) gp=gxp+flip(gyp) dz=dx+flip(dy) zc=x+flip(y) ; ; change c ; if(@changec=="add") c=c+incrementc elseif(@changec=="multiply") c=c*incrementc elseif(@changec=="power") c=c^incrementc endif ; ; change z ; if(@changez=="add") zc=zc+incrementz elseif(@changez=="multiply") zc=zc*incrementz elseif(@changez=="power") zc=zc^incrementz endif ; ; change factor ; if(@changefac=="add") newtfac=newtfac+incrementfac elseif(@changefac=="multiply") newtfac=newtfac*incrementfac elseif(@changefac=="power") newtfac=newtfac^incrementfac endif ; ; set z for coloring ; if(@ztype=="iterate") z=zc elseif(@ztype=="function") z=g elseif(@ztype=="derivative") z=gp elseif(@ztype=="difference") z=1/dz endif bailout: |1/dz|<@bailout default: title="Breaking Newton - Real" heading text="Attempts to solve two real-valued equations,\ one for x and one for y, using Newton's method.\ The equations generally don't have solutions. \ Chaos may be introduced by changing c, z, and/\ or the Newton factor at each iteration." endheading ; ; general parameters ; heading caption="general parameters" endheading param pixel_type caption="pixel type" default=4 enum="initial c" "c change" "initial z" "z change" "initial Newton factor" "Newton factor change" endparam param x_type caption="x type" default=0 enum="x^2 = c" "x^4 = c" "x^6 = c" "sin(x) = c" "cos(x) = c" "tanh(x) = c" "exp(x) = c" endparam float param freqx caption="frequency" default=2 visible=((@x_type=="sin(x) = c")||(@x_type=="cos(x) = c")||(@x_type=="tanh(x) = c")) endparam param y_type caption="y type" default=0 enum="y^2 = c" "y^4 = c" "y^6 = c" "sin(y) = c" "cos(y) = c" "tanh(y) = c" "exp(y) = c" endparam float param freqy caption="frequency" default=3 visible=((@y_type=="sin(y) = c")||(@y_type=="cos(y) = c")||(@y_type=="tanh(y) = c")) endparam float param bailout caption="bailout" default=1000000 endparam ; ; c parameters ; heading caption="c parameters" endheading complex param initialc caption="initial c" default=(2,3) visible=(@pixel_type!="initial c") endparam param changec caption="change c" default=0 enum="none" "add" "multiply" "power" endparam complex param cinc caption="change amount" default=1 visible=((@changec!="none")&&(@pixel_type!="c change")) endparam ; ; z parameters ; heading caption="z parameters" endheading complex param initialz caption="initial z" default=(1,2) visible=(@pixel_type!="initial z") endparam param changez caption="change z" default=2 enum="none" "add" "multiply" "power" endparam complex param zinc caption="change amount" default=(2,-3) visible=((@changez!="none")&&(@pixel_type!="z change")) endparam param ztype caption="z type" default=0 enum="iterate" "function" "derivative" "difference" endparam ; ; Newton factor parameters ; heading caption="Newton factor parameters" endheading complex param initialfac caption="initial factor" default=(1,1) visible=(@pixel_type!="initial Newton factor") endparam param changefac caption="change factor" default=0 enum="none" "add" "multiply" "power" endparam complex param facinc caption="change amount" default=1 visible=((@changefac!="none")&&(@pixel_type!="Newton factor change")) endparam } breaking-newton-complex { ; Kerry Mitchell 28Jul2018 ; ; force chaos into newton's method ; by changing c and/or z and/or Newton factor each iteration ; init: complex c=(0,0) complex dz=(0,0) complex g=(0,0) complex gp=(0,0) complex incrementc=(0,0) complex incrementfac=(0,0) complex incrementz=(0,0) complex lhs=(0,0) complex lhsp=(0,0) complex newtfac=(0,0) complex rhs=(0,0) complex rhsp=(0,0) complex z=(0,0) complex zc=(0,0) ; ; initializations ; if(@pixel_type=="initial c") c=#pixel incrementc=@cinc zc=@initialz incrementz=@zinc newtfac=@initialfac incrementfac=@facinc elseif(@pixel_type=="c change") c=@initialc incrementc=#pixel zc=@initialz incrementz=@zinc newtfac=@initialfac incrementfac=@facinc elseif(@pixel_type=="initial z") c=@initialc incrementc=@cinc zc=#pixel incrementz=@zinc newtfac=@initialfac incrementfac=@facinc elseif(@pixel_type=="z change") c=@initialc incrementc=@cinc zc=@initialz incrementz=#pixel newtfac=@initialfac incrementfac=@facinc elseif(@pixel_type=="initial Newton factor") c=@initialc incrementc=@cinc zc=@initialz incrementz=@zinc newtfac=#pixel incrementfac=@facinc elseif(@pixel_type=="Newton factor change") c=@initialc incrementc=@cinc zc=@initialz incrementz=@zinc newtfac=@initialfac incrementfac=#pixel endif loop: ; ; iterate ; ; lefthand side of equation ; if(@lhs_type=="power") lhs=zc^@lpower lhsp=@lpower*zc^(@lpower-1) elseif(@lhs_type=="exp") lhs=exp(zc) lhsp=lhs elseif(@lhs_type=="log") lhs=log(zc) lhsp=1/zc elseif(@lhs_type=="sin") lhs=sin(@lfreq*zc) lhsp=@lfreq*cos(@lfreq*zc) elseif(@lhs_type=="cos") lhs=cos(@lfreq*zc) lhsp=-@lfreq*sin(@lfreq*zc) elseif(@lhs_type=="tan") lhs=tan(@lfreq*zc) lhsp=@lfreq/sqr(cos(@lfreq*zc)) elseif(@lhs_type=="sinh") lhs=sinh(@lfreq*zc) lhsp=@lfreq*cosh(@lfreq*zc) elseif(@lhs_type=="cosh") lhs=cosh(@lfreq*zc) lhsp=@lfreq*sinh(@lfreq*zc) elseif(@lhs_type=="tanh") lhs=tanh(@lfreq*zc) lhsp=@lfreq/sqr(cosh(@lfreq*zc)) else lhs=c lhsp=0 endif ; ; righthand side of equation ; if(@rhs_type=="power") rhs=zc^@rpower rhsp=@rpower*zc^(@rpower-1) elseif(@rhs_type=="exp") rhs=exp(zc) rhsp=rhs elseif(@rhs_type=="log") rhs=log(zc) rhsp=1/zc elseif(@rhs_type=="sin") rhs=sin(@rfreq*zc) rhsp=@rfreq*cos(@rfreq*zc) elseif(@rhs_type=="cos") rhs=cos(@rfreq*zc) rhsp=-@rfreq*sin(@rfreq*zc) elseif(@rhs_type=="tan") rhs=tan(@rfreq*zc) rhsp=@rfreq/sqr(cos(@rfreq*zc)) elseif(@rhs_type=="sinh") rhs=sinh(@rfreq*zc) rhsp=@rfreq*cosh(@rfreq*zc) elseif(@rhs_type=="cosh") rhs=cosh(@rfreq*zc) rhsp=@rfreq*sinh(@rfreq*zc) elseif(@rhs_type=="tanh") rhs=tanh(@rfreq*zc) rhsp=@rfreq/sqr(cosh(@rfreq*zc)) else rhs=c rhsp=0 endif ; ; combine both sides & find new zc ; g=lhs-rhs gp=lhsp-rhsp dz=g/gp zc=zc-newtfac*dz ; ; change c ; if(@changec=="add") c=c+incrementc elseif(@changec=="multiply") c=c*incrementc elseif(@changec=="power") c=c^incrementc endif ; ; change z ; if(@changez=="add") zc=zc+incrementz elseif(@changez=="multiply") zc=zc*incrementz elseif(@changez=="power") zc=zc^incrementz endif ; ; change factor ; if(@changefac=="add") newtfac=newtfac+incrementfac elseif(@changefac=="multiply") newtfac=newtfac*incrementfac elseif(@changefac=="power") newtfac=newtfac^incrementfac endif ; ; set z for coloring ; if(@ztype=="iterate") z=zc elseif(@ztype=="function") z=g elseif(@ztype=="derivative") z=gp elseif(@ztype=="difference") z=1/dz endif bailout: |1/dz|<@bailout default: title="Breaking Newton - Complex" heading text="Attempts to solve equations of the form: lefthand = \ righthand, using Newton's method. Chaos may be \ introduced by changing c, z, and/or the Newton \ factor at each iteration." endheading ; ; general parameters ; heading caption="general parameters" endheading param pixel_type caption="pixel type" default=4 enum="initial c" "c change" "initial z" "z change" "initial Newton factor" "Newton factor change" endparam param lhs_type caption="lefthand type" default=1 enum="c" "power" "exp" "log" "sin" "cos" "tan" "sinh" "cosh" "tanh" endparam complex param lpower caption="power" default=4 visible=(@lhs_type=="power") endparam complex param lfreq caption="frequency" default=2 visible=(@lhs_type>3) endparam param rhs_type caption="righthand type" default=0 enum="c" "power" "exp" "log" "sin" "cos" "tan" "sinh" "cosh" "tanh" endparam complex param rpower caption="power" default=3 visible=(@rhs_type=="power") endparam complex param rfreq caption="frequency" default=3 visible=(@rhs_type>3) endparam float param bailout caption="bailout" default=1000000 endparam ; ; c parameters ; heading caption="c parameters" visible=((@lhs_type=="c")||(@rhs_type=="c")) endheading complex param initialc caption="initial c" default=1 visible=((@lhs_type=="c")||(@rhs_type=="c")&&(@pixel_type!="initial c")) endparam param changec caption="change c" default=0 enum="none" "add" "multiply" "power" visible=((@lhs_type=="c")||(@rhs_type=="c")) endparam complex param cinc caption="change amount" default=1 visible=(((@lhs_type=="c")||(@rhs_type=="c"))&&(@changec!="none")&&(@pixel_type!="c change")) endparam ; ; z parameters ; heading caption="z parameters" endheading complex param initialz caption="initial z" default=0.01 visible=(@pixel_type!="initial z") endparam param changez caption="change z" default=0 enum="none" "add" "multiply" "power" endparam complex param zinc caption="change amount" default=1 visible=((@changez!="none")&&(@pixel_type!="z change")) endparam param ztype caption="z type" default=0 enum="iterate" "function" "derivative" "difference" endparam ; ; Newton factor parameters ; heading caption="Newton factor parameters" endheading complex param initialfac caption="initial factor" default=1 visible=(@pixel_type!="initial Newton factor") endparam param changefac caption="change factor" default=0 enum="none" "add" "multiply" "power" endparam complex param facinc caption="change amount" default=1 visible=((@changefac!="none")&&(@pixel_type!="Newton factor change")) endparam } compound-mandelbrot { ; Kerry Mitchell 26Nov2019 ; ; f(z) = ((z^n+c)/(z^m+c))^p+c ; init: complex c=#pixel complex z=(0,0) if(@initialz_type=="pixel") z=c else z=@initialz endif loop: z=((z^@npower+c)/(z^@mpower+c))^@ppower+c bailout: |z|<@bailout default: title="Compound Mandelbrot" heading text="Uses the formula z = ((z^m + c)/(z^n + c))^p + c; 3 exponents." endheading param initialz_type caption="initial z" default=0 enum="pixel" "constant" endparam complex param initialz caption="initial z value" default=(0,0) visible=(@initialz_type=="constant") endparam complex param npower caption="numerator power" default=(2,0) endparam complex param mpower caption="denominator power" default=(1,0) endparam complex param ppower caption="overall power" default=(2,0) endparam float param bailout caption="bailout" default=1000 endparam switch: type="compound-julia" julparam=#pixel npower=npower mpower=mpower ppower=ppower bailout=bailout } compound-julia { ; Kerry Mitchell 26Nov2019 ; ; f(z) = ((z^n+c)/(z^m+c))^p+c ; init: complex c=@julparam complex z=#pixel loop: z=((z^@npower+c)/(z^@mpower+c))^@ppower+c bailout: |z|<@bailout default: title="Compound Julia" heading text="Uses the formula z = ((z^m + c)/(z^n + c))^p + c; 3 exponents." endheading complex param julparam caption="Julia parameter" default=(0,1) endparam complex param npower caption="numerator power" default=(2,0) endparam complex param mpower caption="denominator power" default=(1,0) endparam complex param ppower caption="overall power" default=(2,0) endparam float param bailout caption="bailout" default=1000 endparam switch: type="compound-mandelbrot" npower=npower mpower=mpower ppower=ppower bailout=bailout } mixed-up-multiplication-mandelbrot { ; Kerry Mitchell 27Nov2019 ; ; Instead of using regular complex multiplication, this method uses a base ; shape (= unit circle normally). Use the polar angle of z to reach back ; to the base shape and find its coordinates. Then, use the actual and base ; magnitudes to determine a scale factor, and the arc length to determine ; the angle (angle = arc length / base magnitude). From there, the magnitude ; of z^power = scale factor ^ power, and angle of z^power = power * angle. ; $define debug global: complex corner[20] float pitch_s=0 float pitch_trad=0 float smax=0 float tdegmax[20] float twopi=2*#pi int gi=0 ; ; cruciform settings: central square side & four other squares, one ; on each side of central square ; if(@shape_type=="cruciform") corner[0]=(3,0) corner[1]=(3,1) corner[2]=(1,1) corner[3]=(1,3) corner[4]=(-1,3) corner[5]=(-1,1) corner[6]=(-3,1) corner[7]=(-3,-1) corner[8]=(-1,-1) corner[9]=(-1,-3) corner[10]=(1,-3) corner[11]=(1,-1) corner[12]=(3,-1) corner[13]=(3,0) ; ; rescale so that corner[0] = (1,0) ; find degree measures of corners ; gi=-1 while(gi<12) gi=gi+1 corner[gi]=corner[gi]/3 tdegmax[gi]=(atan2(corner[gi])/#pi*180+720)%360 endwhile elseif(@shape_type=="triangle") corner[0]=(1,0) corner[1]=(-1+flip(sqrt(3)))/2 corner[2]=(-1-flip(sqrt(3)))/2 tdegmax[0]=0 tdegmax[1]=120 tdegmax[2]=240 tdegmax[3]=360 elseif(@shape_type=="star") corner[0]=(1,0) corner[1]=@inrad*(1,1)/sqrt(2) corner[2]=(0,1) corner[3]=@inrad*(-1,1)/sqrt(2) corner[4]=(-1,0) corner[5]=@inrad*(-1,-1)/sqrt(2) corner[6]=(0,-1) corner[7]=@inrad*(1,-1)/sqrt(2) corner[8]=(1,0) tdegmax[0]=0 tdegmax[1]=45 tdegmax[2]=90 tdegmax[3]=135 tdegmax[4]=180 tdegmax[5]=225 tdegmax[6]=270 tdegmax[7]=315 tdegmax[8]=360 endif ; ; gear settings ; if(@shape_type=="gear") pitch_trad=twopi/@nteeth smax=#pi*(1+@rsmall) pitch_s=smax/@nteeth endif init: complex arccenter=(0,0) complex c=#pixel complex compk=(0,0) complex w=(0,0) complex z=#pixel float afac=0 float bfac=0 float cfac=0 float dcrit=1/(1+@rsmall) float dtooth=0 float h1=0 float k1=0 float k=0 float phi=0 float phimax=0 float r=0 float s=0 float slope=0 float tdeg=0 float third=1/3 float trad=0 float x=0 float xb=0 float x3=0 float y=0 float yb=0 float y3=0 int itooth=0 loop: ; ; decompose z ; x=real(z), y=imag(z) ; ; square ; if(@shape_type=="square") ; ; determine arc length from basis shape ; phimax=8 ; ; find scale factor k ; k=abs(x) if(abs(y)>k) k=abs(y) endif ; ; find standard polar angle ; trad=atan2(z) if(trad<0) trad=trad+2*#pi endif tdeg=trad/#pi*180 ; ; use polar angle to find coordinates of point on base shape ; and base shape arc length ; if(tdeg<45) ; upper right side xb=1, yb=y/k, s=yb elseif(tdeg<135) ; top xb=x/k, yb=1, s=2-xb elseif(tdeg<225) ; left side xb=-1, yb=y/k, s=4-yb elseif(tdeg<315) ; bottom xb=x/k, yb=-1, s=6+xb else ; lower right side xb=1, yb=y/k, s=8+yb endif phi=s ; ; raise z to power ; k=k^@power, phi=(@power*phi)%phimax ; ; use phi and k to return new x & y and add c ; if(phi<1) ; upper right side xb=1, yb=phi elseif(phi<3) ; top xb=2-phi, yb=1 elseif(phi<5) ; left side xb=-1, yb=4-phi elseif(phi<7) ; bottom xb=phi-6, yb=-1 else ; lower right side xb=1, yb=phi-8 endif x=xb*k, y=yb*k z=x+flip(y)+c ; ; triangle ; elseif(@shape_type=="triangle") ; ; determine arc length from basis shape ; third=sqrt(3) phimax=3*third ; ; find standard magnitude and polar angle ; r=cabs(z) trad=atan2(z) tdeg=(trad/#pi*180+720)%360 trad=tdeg/180*#pi ; ; use polar angle to find coordinates of point on base shape ; and base shape arc length ; if(tdegk) k=abs(y) endif ; ; find standard polar angle ; trad=atan2(z) if(trad<0) trad=trad+2*#pi endif tdeg=trad/#pi*180 ; ; use polar angle to find coordinates of point on base shape ; and base shape arc length ; if(tdeg<45) ; upper right side xb=1, yb=y/k, s=yb elseif(tdeg<135) ; top xb=x/k, yb=1, s=2-xb elseif(tdeg<225) ; left side xb=-1, yb=y/k, s=4-yb elseif(tdeg<315) ; bottom xb=x/k, yb=-1, s=6+xb else ; lower right side xb=1, yb=y/k, s=8+yb endif phi=s ; ; raise z to power ; k=k^@power, phi=(@power*phi)%phimax ; ; use phi and k to return new x & y and add c ; if(phi<1) ; upper right side xb=1, yb=phi elseif(phi<3) ; top xb=2-phi, yb=1 elseif(phi<5) ; left side xb=-1, yb=4-phi elseif(phi<7) ; bottom xb=phi-6, yb=-1 else ; lower right side xb=1, yb=phi-8 endif x=xb*k, y=yb*k z=x+flip(y)+c ; ; triangle ; elseif(@shape_type=="triangle") ; ; determine arc length from basis shape ; third=sqrt(3) phimax=3*third ; ; find standard magnitude and polar angle ; r=cabs(z) trad=atan2(z) tdeg=(trad/#pi*180+720)%360 trad=tdeg/180*#pi ; ; use polar angle to find coordinates of point on base shape ; and base shape arc length ; if(tdeg0) fp2=(@power-1)*@power*(ziterate^(@power-2)) if(@solntype>2) fp3=(@power-2)*(@power-1)*@power*(ziterate^(@power-3)) if(@solntype>4) fp4=(@power-3)*(@power-2)*(@power-1)*@power*(ziterate^(@power-4)) if(@solntype>6) fp5=(@power-4)*(@power-3)*(@power-2)*(@power-1)*@power*(ziterate^(@power-5)) if(@solntype>8) fp6=(@power-5)*(@power-4)*(@power-3)*(@power-2)*(@power-1)*@power*(ziterate^(@power-6)) endif endif endif endif endif endif elseif(@eqntype=="sum of 4 powers = c") f=\ @coeff1*ziterate^@power1+\ @coeff2*ziterate^@power2+\ @coeff3*ziterate^@power3+\ @coeff4*ziterate^@power4-c fp=\ @coeff1*@power1*ziterate^(@power1-1)+\ @coeff2*@power2*ziterate^(@power2-1)+\ @coeff3*@power3*ziterate^(@power3-1)+\ @coeff4*@power4*ziterate^(@power4-1) if(@solntype>0) fp2=\ @coeff1*(@power1-1)*@power1*ziterate^(@power1-2)+\ @coeff2*(@power2-1)*@power2*ziterate^(@power2-2)+\ @coeff3*(@power3-1)*@power3*ziterate^(@power3-2)+\ @coeff4*(@power4-1)*@power4*ziterate^(@power4-2) if(@solntype>2) fp3=\ @coeff1*(@power1-2)*(@power1-1)*@power1*ziterate^(@power1-3)+\ @coeff2*(@power2-2)*(@power2-1)*@power2*ziterate^(@power2-3)+\ @coeff3*(@power3-2)*(@power3-1)*@power3*ziterate^(@power3-3)+\ @coeff4*(@power4-2)*(@power4-1)*@power4*ziterate^(@power4-3) if(@solntype>4) fp4=\ @coeff1*(@power1-3)*(@power1-2)*(@power1-1)*@power1*ziterate^(@power1-4)+\ @coeff2*(@power2-3)*(@power2-2)*(@power2-1)*@power2*ziterate^(@power2-4)+\ @coeff3*(@power3-3)*(@power3-2)*(@power3-1)*@power3*ziterate^(@power3-4)+\ @coeff4*(@power4-3)*(@power4-2)*(@power4-1)*@power4*ziterate^(@power4-4) if(@solntype>6) fp5=\ @coeff1*(@power1-4)*(@power1-3)*(@power1-2)*(@power1-1)*@power1*ziterate^(@power1-5)+\ @coeff2*(@power2-4)*(@power2-3)*(@power2-2)*(@power2-1)*@power2*ziterate^(@power2-5)+\ @coeff3*(@power3-4)*(@power3-3)*(@power3-2)*(@power3-1)*@power3*ziterate^(@power3-5)+\ @coeff4*(@power4-4)*(@power4-3)*(@power4-2)*(@power4-1)*@power4*ziterate^(@power4-5) if(@solntype>8) fp6=\ @coeff1*(@power1-5)*(@power1-4)*(@power1-3)*(@power1-2)*(@power1-1)*@power1*ziterate^(@power1-6)+\ @coeff2*(@power2-5)*(@power2-4)*(@power2-3)*(@power2-2)*(@power2-1)*@power2*ziterate^(@power2-6)+\ @coeff3*(@power3-5)*(@power3-4)*(@power3-3)*(@power3-2)*(@power3-1)*@power3*ziterate^(@power3-6)+\ @coeff4*(@power4-5)*(@power4-4)*(@power4-3)*(@power4-2)*(@power4-1)*@power4*ziterate^(@power4-6) endif endif endif endif endif elseif(@eqntype=="z^n + c = sin(z)") temp1=sin(ziterate), temp2=cos(ziterate) f=ziterate^@power+c-temp1 fp=@power*ziterate^(@power-1)-temp2 if(@solntype>0) fp2=(@power-1)*@power*ziterate^(@power-2)+temp1 if(@solntype>2) fp3=(@power-2)*(@power-1)*@power*ziterate^(@power-3)+temp2 if(@solntype>4) fp4=(@power-3)*(@power-2)*(@power-1)*@power*ziterate^(@power-4)-temp1 if(@solntype>6) fp5=(@power-4)*(@power-3)*(@power-2)*(@power-1)*@power*ziterate^(@power-5)-temp2 if(@solntype>8) fp6=(@power-5)*(@power-4)*(@power-3)*(@power-2)*(@power-1)*@power*ziterate^(@power-6)+temp1 endif endif endif endif endif elseif(@eqntype=="z^n = c*cos(z)") temp1=c*cos(ziterate), temp2=c*sin(ziterate) f=ziterate^@power-temp1 fp=@power*ziterate^(@power-1)+temp2 if(@solntype>0) fp2=(@power-1)*@power*ziterate^(@power-2)+temp1 if(@solntype>2) fp3=(@power-2)*(@power-1)*@power*ziterate^(@power-3)-temp2 if(@solntype>4) fp4=(@power-3)*(@power-2)*(@power-1)*@power*ziterate^(@power-4)-temp1 if(@solntype>6) fp5=(@power-4)*(@power-3)*(@power-2)*(@power-1)*@power*ziterate^(@power-5)+temp2 if(@solntype>8) fp6=(@power-5)*(@power-4)*(@power-3)*(@power-2)*(@power-1)*@power*ziterate^(@power-6)+temp1 endif endif endif endif endif elseif(@eqntype=="z^n + c = tan(z)") temp1=cos(ziterate), temp2=sin(ziterate), temp3=sqr(temp2) f=ziterate^@power+c-tan(ziterate) fp=@power*ziterate^(@power-1)-temp1^(-2) if(@solntype>0) fp2=(@power-1)*@power*ziterate^(@power-2)-2*temp1^(-3)*temp2 if(@solntype>2) fp3=(@power-2)*(@power-1)*@power*ziterate^(@power-3)-2*temp1^(-4)*(1+2*temp3) if(@solntype>4) fp4=(@power-3)*(@power-2)*(@power-1)*@power*ziterate^(@power-4)-\ 8*temp2*temp1^(-5)*(2+temp3) if(@solntype>6) fp5=(@power-4)*(@power-3)*(@power-2)*(@power-1)*@power*ziterate^(@power-5)-\ 8*temp1^(-6)*(temp3*(2*temp3+11)+2) if(@solntype>8) fp6=(@power-5)*(@power-4)*(@power-3)*(@power-2)*(@power-1)*@power*ziterate^(@power-6)-\ 16*temp2*temp1^(-7)*(2*temp3*(temp3+13)+17) endif endif endif endif endif elseif(@eqntype=="z^n = c*tan(z)") temp1=cos(ziterate), temp2=sin(ziterate), temp3=sqr(temp2) f=ziterate^@power-c*tan(ziterate) fp=@power*ziterate^(@power-1)-c*temp1^(-2) if(@solntype>0) fp2=(@power-1)*@power*ziterate^(@power-2)-2*c*temp1^(-3)*temp2 if(@solntype>2) fp3=(@power-2)*(@power-1)*@power*ziterate^(@power-3)-2*c*temp1^(-4)*(1+2*temp3) if(@solntype>4) fp4=(@power-3)*(@power-2)*(@power-1)*@power*ziterate^(@power-4)-\ 8*c*temp2*temp1^(-5)*(2+temp3) if(@solntype>6) fp5=(@power-4)*(@power-3)*(@power-2)*(@power-1)*@power*ziterate^(@power-5)-\ 8*c*temp1^(-6)*(temp3*(2*temp3+11)+2) if(@solntype>8) fp6=(@power-5)*(@power-4)*(@power-3)*(@power-2)*(@power-1)*@power*ziterate^(@power-6)-\ 16*c*temp2*temp1^(-7)*(2*temp3*(temp3+13)+17) endif endif endif endif endif elseif(@eqntype=="sin(z+c) = cos(c*z)") temp1=sin(ziterate+c), temp2=cos(c*ziterate) temp3=cos(ziterate+c), temp4=sin(c*ziterate) f=temp1-temp2 fp=temp3+c*temp4 if(@solntype>0) fp2=-temp1+sqr(c)*temp2 if(@solntype>2) fp3=-temp3-(c^3)*temp4 if(@solntype>4) fp4=temp1-(c^4)*temp2 if(@solntype>6) fp5=temp3+(c^5)*temp4 if(@solntype>8) fp6=-temp1+(c^6)*temp2 endif endif endif endif endif elseif(@eqntype=="sum of 4 sines = c") temp1=@amp1*sin(@freq1*ziterate), temp2=@amp2*sinh(@freq2*ziterate) temp3=@amp3*sinh(@freq3*ziterate), temp4=@amp4*sin(@freq4*ziterate) temp5=@amp1*cos(@freq1*ziterate), temp6=@amp2*cosh(@freq2*ziterate) temp7=@amp3*cosh(@freq3*ziterate), temp8=@amp4*cos(@freq4*ziterate) f=temp1+temp2+temp3+temp4-c fp=@freq1*temp5+@freq2*temp6+@freq3*temp7+@freq4*temp8 if(@solntype>0) fp2=-(@freq1^2)*temp1+(@freq2^2)*temp2+(@freq3^2)*temp3-(@freq4^2)*temp4 if(@solntype>2) fp3=-(@freq1^3)*temp5+(@freq2^3)*temp6+(@freq3^3)*temp7-(@freq4^3)*temp8 if(@solntype>4) fp4=(@freq1^4)*temp1+(@freq2^4)*temp2+(@freq3^4)*temp3+(@freq4^4)*temp4 if(@solntype>6) fp5=(@freq1^5)*temp5+(@freq2^5)*temp6+(@freq3^5)*temp7+(@freq4^5)*temp8 if(@solntype>8) fp6=-(@freq1^6)*temp1+(@freq2^6)*temp2+(@freq3^6)*temp3-(@freq4^6)*temp4 endif endif endif endif endif elseif(@eqntype=="sum of 4 cosines = c") temp1=@amp1*cos(@freq1*ziterate+c), temp2=@amp2*cos(@freq2*ziterate+c) temp3=@amp3*cosh(@freq3*ziterate+c), temp4=@amp4*cosh(@freq4*ziterate+c) temp5=@amp1*sin(@freq1*ziterate+c), temp6=@amp2*sin(@freq2*ziterate+c) temp7=@amp3*sinh(@freq3*ziterate+c), temp8=@amp4*sinh(@freq4*ziterate+c) f=temp1+temp2+temp3+temp4 fp=-@freq1*temp5-@freq2*temp6+@freq3*temp7+@freq4*temp8 if(@solntype>0) fp2=-(@freq1^2)*temp1-(@freq2^2)*temp2+(@freq3^2)*temp3+(@freq4^2)*temp4 if(@solntype>2) fp3=+(@freq1^3)*temp5+(@freq2^3)*temp6+(@freq3^3)*temp7+(@freq4^3)*temp8 if(@solntype>4) fp4=+(@freq1^4)*temp1+(@freq2^4)*temp2+(@freq3^4)*temp3+(@freq4^4)*temp4 if(@solntype>6) fp5=-(@freq1^5)*temp5-(@freq2^5)*temp6+(@freq3^5)*temp7+(@freq4^5)*temp8 if(@solntype>8) fp6=-(@freq1^6)*temp1-(@freq2^6)*temp2+(@freq3^6)*temp3+(@freq4^6)*temp4 endif endif endif endif endif elseif(@eqntype=="exp(cz) = log(z)/c") temp1=exp(c*ziterate), temp2=log(ziterate) f=temp1-temp2/c fp=c*temp1-1/(c*ziterate) if(@solntype>0) fp2=sqr(c)*temp1+1/(c*sqr(ziterate)) if(@solntype>2) fp3=(c^3)*temp1-2/(c*ziterate^3) if(@solntype>4) fp4=(c^4)*temp1+6/(c*ziterate^4) if(@solntype>6) fp5=(c^5)*temp1-24/(c*ziterate^5) if(@solntype>8) fp6=(c^6)*temp1+120/(c*ziterate^6) endif endif endif endif endif elseif(@eqntype=="z^c = c^z") temp1=c^ziterate, temp2=log(c) f=ziterate^c-temp1 fp=c*ziterate^(c-1)-temp2*temp1 if(@solntype>0) fp2=(c-1)*c*ziterate^(c-2)-(temp2^2)*temp1 if(@solntype>2) fp3=(c-2)*(c-1)*c*ziterate^(c-3)-(temp2^3)*temp1 if(@solntype>4) fp4=(c-3)*(c-2)*(c-1)*c*ziterate^(c-4)-(temp2^4)*temp1 if(@solntype>6) fp5=(c-4)*(c-3)*(c-2)*(c-1)*c*ziterate^(c-5)-(temp2^5)*temp1 if(@solntype>8) fp6=(c-5)*(c-4)*(c-3)*(c-2)*(c-1)*c*ziterate^(c-6)-(temp2^6)*temp1 endif endif endif endif endif endif ; ; generate next iterate ; if(@solntype=="Newton (order 1)") dz1=-relaxation1*f/fp dz=dz1 elseif(@solntype=="Halley (order 2)") dz1=-relaxation1*f/fp dz2=-relaxation2*f/(fp+dz1/2*fp2) dz=dz2 elseif(@solntype=="order 2b") ; ; uses quadratic equation to solve for dz ; dz3=sqrt(sqr(fp)-2*f*fp2) dz1=(-f+dz3)/fp2, dz2=(-f+dz3)/fp2 dz4=dz2 if(cabs(f+dz1*fp)0)) endparam func relax2_func caption="relaxation 2 function" default=ident() visible=(@solntype>0) endfunc complex param relax3 caption="relaxation 3" default=(1,0) visible=((@pixeltype!="relaxation 3")&&(@pixeltype!="all relaxations")&&(@solntype>2)) endparam func relax3_func caption="relaxation 3 function" default=ident() visible=(@solntype>2) endfunc complex param relax4 caption="relaxation 4" default=(1,0) visible=((@pixeltype!="relaxation 4")&&(@pixeltype!="all relaxations")&&(@solntype>4)) endparam func relax4_func caption="relaxation 4 function" default=ident() visible=(@solntype>4) endfunc complex param relax5 caption="relaxation 5" default=(1,0) visible=((@pixeltype!="relaxation 5")&&(@pixeltype!="all relaxations")&&(@solntype>6)) endparam func relax5_func caption="relaxation 5 function" default=ident() visible=(@solntype>6) endfunc complex param relax6 caption="relaxation 6" default=(1,0) visible=((@pixeltype!="relaxation 6")&&(@pixeltype!="all relaxations")&&(@solntype>8)) endparam func relax6_func caption="relaxation 6 function" default=ident() visible=(@solntype>8) endfunc } extra-foam { ; Kerry Mitchell 12 June 2021 ; ; Generalization of "Mandelbrot Foam" from fractal forums ; https://fractalforums.org/fractal-mathematics-and-new-theories/28/mandelbrot-foam-math/1665/msg8427#msg8427 ; original: ; w = a*w/z ; z = z^2 + w^2 + c ; ; powers of w and z in w and z formulas are parameters ; ; added parallel/series modes: ; parallel: compute new w and new z independently ; series: compute new w and use that for new z ; ; pixel_type parameter allows the pixel to represent either complex parameter (or both) or the initial values ; of either complex variable (or both). ; init: complex q=(0,0) complex c=(0,0) complex w=(0,0) complex wnew=(0,0) complex z=(0,0) complex znew=(0,0) ; ; Use pixel value to set parameters (like a Mandelbrot set) and/or ; initialize variables (like a Julia set) ; if(@pixel_type=="q") q=#pixel c=@cinit if(@wq==true) w=q else w=@winit endif if(@zc==true) z=c else z=@zinit endif elseif(@pixel_type=="c") q=@qinit c=#pixel if(@wq==true) w=q else w=@winit endif if(@zc==true) z=c else z=@zinit endif elseif(@pixel_type=="q = c") q=#pixel c=#pixel if(@wq==true) w=q else w=@winit endif if(@zc==true) z=c else z=@zinit endif elseif(@pixel_type=="initial w") q=@qinit c=@cinit w=#pixel if(@zc==true) z=c else z=@zinit endif elseif(@pixel_type=="initial z") q=@qinit c=@cinit if(@wq==true) w=q else w=@winit endif z=#pixel elseif(@pixel_type=="w = z") q=@qinit c=@cinit w=#pixel z=#pixel elseif(@pixel_type=="all in") q=#pixel c=#pixel w=#pixel z=#pixel endif loop: ; ; Series: compute new w and use that for new z. ; Parallel: compute new w and new z independently. ; if(@circuit_type=="series") w=q*w^@wpowerinw*z^@zpowerinw z=z^@zpowerinz+w^@wpowerinz+c elseif(@circuit_type=="parallel") wnew=q*w^@wpowerinw*z^@zpowerinw znew=z^@zpowerinz+w^@wpowerinz+c w=wnew, z=znew endif bailout: |z|<@bailout default: title="Extra Foam" ; ; General Parameters ; heading caption="General Parameters" endheading param pixel_type caption="pixel type" default=6 enum="q" "c" "q = c" "initial w" "initial z" "w = z" "all in" endparam bool param wq caption="w = q" default=true visible=((@pixel_type=="q")||(@pixel_type=="c")||(@pixel_type=="q = c")||(@pixel_type=="initial z")) endparam bool param zc caption="z = c" default=true visible=((@pixel_type=="q")||(@pixel_type=="c")||(@pixel_type=="q = c")||(@pixel_type=="initial w")) endparam param circuit_type caption="circuit type" default=0 enum="series" "parallel" endparam float param bailout caption="bailout" default=1000 endparam ; ; Initializations ; heading caption="Initializations" endheading complex param qinit caption="q" default=(1,0) visible=((@pixel_type=="c")||(@pixel_type=="initial w")||(@pixel_type=="initial z")||(@pixel_type=="w = z")) endparam complex param cinit caption="c" default=(1,0) visible=((@pixel_type=="q")||(@pixel_type=="initial w")||(@pixel_type=="initial z")||(@pixel_type=="w = z")) endparam complex param winit caption="initial w" default=(0,0) visible=((@wq==false)&&(@pixel_type!="initial w")&&(@pixel_type!="w = z")) endparam complex param zinit caption="initial z" default=(0,0) visible=((@zc==false)&&(@pixel_type!="initial z")&&(@pixel_type!="w = z")) endparam ; ; Variable Powers ; heading caption="Variable Powers" endheading complex param wpowerinw caption="w power in w" default=1 endparam complex param zpowerinw caption="z power in w" default=-1 endparam complex param wpowerinz caption="w power in z" default=2 endparam complex param zpowerinz caption="z power in z" default=2 endparam } round-and-transform { ; Kerry Mitchell 27Nov2021 ; ; Each iteration, round z_old to the nearest mulitple of round_base and then ; transform the rounded result to z_new. Alternatively, transform the residual, ; z_rounded - z_old. Optionally, the round_base can also be transformed each ; iteration. ; $define debug init: complex base_amp=(0,0) complex base_offset=(0,0) complex base_power=(0,0) complex roundbase=(0,0) complex z=(0,0) complex zinc=(0,0) complex zold=(0,0) complex znew=(0,0) complex zround=(0,0) complex zresidual=(0,0) complex z_amp=(0,0) complex z_offset=(0,0) complex z_power=(0,0) float dx=0 float dy=0 ; ; initializations ; roundbase=@q_roundbase base_amp=@q_base_amp base_freq=@q_base_freq base_power=@q_base_power base_offset=@q_base_offset znew=@q_z_initial z_amp=@q_z_amp z_freq=@q_z_freq z_power=@q_z_power z_offset=@q_z_offset if(@pixel_type=="initial base") roundbase=#pixel elseif(@pixel_type=="base amplitude") base_amp=#pixel elseif(@pixel_type=="base frequency") base_freq=#pixel elseif(@pixel_type=="base power") base_power=#pixel elseif(@pixel_type=="base offset") base_offset=#pixel elseif(@pixel_type=="initial z") znew=#pixel elseif(@pixel_type=="z amplitude") z_amp=#pixel elseif(@pixel_type=="z frequency") z_freq=#pixel elseif(@pixel_type=="z power") z_power=#pixel elseif(@pixel_type=="z offset") z_offset=#pixel endif loop: ; ; transform the rounding base ; if(@base_transform==true) roundbase=base_amp*@basefn(base_freq*roundbase)^base_power+base_offset endif ; ; round zold: zround=round(zold/roundbase)*roundbase ; zold=znew zround=round(zold/roundbase)*roundbase ; ; transform zround into znew ; if(@use_mod=="rounded") znew=zround znew=z_amp*@zfn(z_freq*znew)^z_power+z_offset elseif(@use_mod=="residual") znew=zround-zold znew=z_amp*@zfn(z_freq*znew)^z_power+z_offset elseif(@use_mod=="no transform") endif ; ; set z to send to coloring formula ; if(@z_type=="rounding base") z=roundbase elseif(@z_type=="rounded z") z=zround elseif(@z_type=="transformed z") z=znew elseif(@z_type=="last absolute residual") z=zround-zold elseif(@z_type=="sum absolute residuals") zresidual=zresidual+(zround-zold) z=zresidual elseif(@z_type=="last relative residual") z=(zround-zold)/roundbase elseif(@z_type=="sum relative residuals") zresidual=zresidual+(zround-zold)/roundbase z=zresidual elseif(@z_type=="last unit residual") zinc=zround-zold dx=real(zinc), dy=imag(zinc) zinc=(0,0) if(dx>0) zinc=1 elseif(dx<0) zinc=-1 endif if(dy>0) zinc=zinc+(0,1) elseif(dy<0) zinc=zinc-(0,1) endif z=zinc elseif(@z_type=="sum unit residuals") zinc=zround-zold dx=real(zinc), dy=imag(zinc) zinc=(0,0) if(dx>0) zinc=1 elseif(dx<0) zinc=-1 endif if(dy>0) zinc=zinc+(0,1) elseif(dy<0) zinc=zinc-(0,1) endif zresidual=zresidual+zinc z=zresidual endif bailout: |z|<@bailout default: title="Round and Transform" ; ; general parameters ; heading caption="General Parameters" endheading param pixel_type caption="pixel type" default=5 enum="initial base" "base amplitude" "base frequency" "base power" "base offset"\ "initial z" "z amplitude" "z frequency" "z power" "z offset" endparam param z_type caption="z type" default=8 enum="rounding base" "rounded z" "transformed z" "last absolute residual"\ "sum absolute residuals" "last relative residual" "sum relative residuals"\ "last unit residual" "sum unit residuals" endparam float param bailout caption="bailout" default=1000 endparam ; ; rounding base parameters ; heading caption="Rounding Base Parameters" endheading complex param q_roundbase caption="initial rounding base" default=(1,2) visible=(@pixel_type!="initial base") endparam bool param base_transform caption="transform base" default=true endparam func basefn caption="base function" default=ident() visible=(@base_transform==true) endfunc complex param q_base_amp caption="base amplitude" default=(1.6,-1.2) visible=((@base_transform==true)&&(@pixel_type!="base amplitude")) endparam complex param q_base_freq caption="base frequency" default=(1,0) visible=((@base_transform==true)&&(@pixel_type!="base frequency")) endparam complex param q_base_power caption="base power" default=(1,0) visible=((@base_transform==true)&&(@pixel_type!="base power")) endparam complex param q_base_offset caption="base offset" default=(0,0) visible=((@base_transform==true)&&(@pixel_type!="base offset")) endparam ; ; z transform parameters ; heading caption="z Transform Parameters" endheading complex param q_z_initial caption="initial z" default=(0,1) visible=(@pixel_type!="initial z") endparam param use_mod caption="what to transform" default=0 enum="rounded" "residual" "no transform" endparam func zfn caption="z function" default=ident() visible=(@use_mod!="no transform") endfunc complex param q_z_amp caption="z amplitude" default=(1,0) visible=((@use_mod!="no transform")&&(@pixel_type!="z amplitude")) endparam complex param q_z_freq caption="z frequency" default=(1,0) visible=((@use_mod!="no transform")&&(@pixel_type!="z frequency")) endparam complex param q_z_power caption="z power" default=(1,0) visible=((@use_mod!="no transform")&&(@pixel_type!="z power")) endparam complex param q_z_offset caption="z offset" default=(0,0) visible=((@use_mod!="no transform")&&(@pixel_type!="z offset")) endparam }