Buddhabrot

Author

Eric W. Weisstein
August 30, 2026

This notebook downloaded from https://mathworld.wolfram.com/notebooks/Fractals/Buddhabrot.nb.

For more information, see Eric's MathWorld entry https://mathworld.wolfram.com/Buddhabrot.html.

©2026 Wolfram Research, Inc. except for portions noted otherwise

Figure

Orbit-density rendering of the Buddhabrot. The red, green, and blue channels use maximum escape iteration counts 5000, 500, and 50, respectively.

Module[{buddhabrotData,channelData,colorize,counts,image,maxIterations=5000,parametersX,parametersY,samples=sampleCount,thresholds={5000,500,50},width=imageWidth,height=imageWidth,xRange={-2.2`,1.`},yRange={-1.6`,1.6`}},SeedRandom[20260830];parametersX=RandomReal[xRange,samples];parametersY=RandomReal[yRange,samples];buddhabrotData=Compile[{{xSamples,_Real,1},{ySamples,_Real,1},{imageWidthValue,_Integer},{imageHeightValue,_Integer},{iterationLimit,_Integer},{channelThresholds,_Integer,1},{xMinimum,_Real},{xMaximum,_Real},{yMinimum,_Real},{yMaximum,_Real}},Module[{column,cx,cy,hits=Table[0,{3},{imageHeightValue},{imageWidthValue}],imaginaryHistory=Table[0.`,{iterationLimit}],iteration,magnitudeSquared,nextReal,q,realHistory=Table[0.`,{iterationLimit}],row,zr,zi},Do[cx=xSamples[[sample]];cy=ySamples[[sample]];q=(cx-0.25`) (cx-0.25`)+cy cy;If[q (q+cx-0.25`)>0.25` cy cy&&(cx+1.`) (cx+1.`)+cy cy>0.0625`,zr=0.`;zi=0.`;iteration=0;magnitudeSquared=0.`;While[iteration<iterationLimit&&magnitudeSquared≤4.`,nextReal=zr zr-zi zi+cx;zi=2.` zr zi+cy;zr=nextReal;iteration++;realHistory[[iteration]]=zr;imaginaryHistory[[iteration]]=zi;magnitudeSquared=zr zr+zi zi;];If[magnitudeSquared>4.`,Do[zr=realHistory[[pathIndex]];zi=imaginaryHistory[[pathIndex]];If[xMinimum≤zr&&zr<xMaximum&&yMinimum≤zi&&zi<yMaximum,column=1+Floor[(((zr-xMinimum) imageWidthValue)/(xMaximum-xMinimum))];row=1+Floor[(((zi-yMinimum) imageHeightValue)/(yMaximum-yMinimum))];If[iteration≤channelThresholds[[1]],hits[[1,row,column]]++];If[iteration≤channelThresholds[[2]],hits[[2,row,column]]++];If[iteration≤channelThresholds[[3]],hits[[3,row,column]]++]],{pathIndex,iteration}]]],{sample,Length[xSamples]}];hits],CompilationTarget->"C",RuntimeOptions->"Speed"];counts=buddhabrotData[parametersX,parametersY,width,height,maxIterations,thresholds,xRange[[1]],xRange[[2]],yRange[[1]],yRange[[2]]];colorize[array_,lowerQuantile_,gamma_]:=Module[{logged,lower,positive,upper},logged=Log[1.` +GaussianFilter[N[array],1.25`]];positive=Select[Flatten[logged],#1>0.`&];lower=If[positive==={},0.`,Quantile[positive,lowerQuantile]];upper=If[positive==={},1.`,Max[lower+1.`*^-6,Quantile[positive,0.9995`]]];((Clip[((logged-lower)/(upper-lower)),{0.`,1.`}])^gamma)];channelData=MapThread[colorize,{counts,{0.6`,0.6`,0.2`},{0.8`,0.8`,0.7`}}];image=Image[(Transpose2[Reverse[channelData,2], {3,1,2}]),"Real",ColorSpace->"RGB"];ImageRotate[image,-(π/2)]]