Function Repository Resource:

SaundersDigitPlot

Source Notebook

Make a Saunders plot of a function

Contributed by: Jan Mangaldan

ResourceFunction["SaundersDigitPlot"][f,b,k,{x,xmin,xmax},{y,ymin,ymax}]

makes a Saunders plot of the kth base‐b digit of f as a function of x and y.

ResourceFunction["SaundersDigitPlot"][f,b,k,{x,y}reg]

takes the variables {x,y} to be in the geometric region reg.

Details and Options

A Saunders plot plots the digit of f which is the coefficient of b-k,
ResourceFunction["SaundersDigitPlot"] treats the variables in the fourth and fifth arguments as local, effectively using Block.
ResourceFunction["SaundersDigitPlot"] has attribute HoldAll, and evaluates f only after assigning specific numerical values to the independent variables.
In some cases, it may be more efficient to use Evaluate to evaluate f symbolically before specific numerical values are assigned to the independent variables.
ResourceFunction["SaundersDigitPlot"] supports most of the options of DensityPlot.

Examples

Basic Examples (3) 

A Saunders plot of a function's first base-10 digit to the right of the decimal point:

In[1]:=
ResourceFunction["SaundersDigitPlot"][
 Sin[x] Sin[y], 10, 1, {x, -4, 4}, {y, -3, 3}, PlotPoints -> 55]
Out[1]=

Visualize the third binary digit:

In[2]:=
ResourceFunction["SaundersDigitPlot"][
 Sin[x] Sin[y], 2, 3, {x, -4, 4}, {y, -3, 3}, PlotPoints -> 55]
Out[2]=

Use a different color scheme and legend:

In[3]:=
ResourceFunction["SaundersDigitPlot"][
 Sin[x] Sin[y], 2, 3, {x, -4, 4}, {y, -3, 3}, ColorFunction -> GrayLevel, PlotLegends -> Automatic, PlotPoints -> 55]
Out[3]=

Scope (3) 

Use a non-integer base:

In[4]:=
ResourceFunction["SaundersDigitPlot"][
 Sin[x + Cos[y]], \[Pi], 2, {x, -2, 2}, {y, -2, 2}, PlotPoints -> 45]
Out[4]=

Use PlotPoints and MaxRecursion to control adaptive sampling:

In[5]:=
ResourceFunction["SaundersDigitPlot"][
 Sin[x y], 10, 2, {x, 0, 4}, {y, 0, 4}, MaxRecursion -> 5, PlotPoints -> 25]
Out[5]=

The domain may be specified by a region:

In[6]:=
ResourceFunction["SaundersDigitPlot"][
 Sin[x + Cos[y]], 10, 1, {x, y} \[Element] Disk[{0, 0}, 3], PlotPoints -> 55]
Out[6]=

Options (5) 

ColorFunction (3) 

Explicitly specify a color function:

In[7]:=
ResourceFunction["SaundersDigitPlot"][
 Re[Sin[x + I y]], 2, 3, {x, -\[Pi], \[Pi]}, {y, -\[Pi], \[Pi]}, ColorFunction -> (GrayLevel[1 - #] &), PlotPoints -> 75]
Out[7]=

Use an indexed color:

In[8]:=
ResourceFunction["SaundersDigitPlot"][
 Re[Sin[x + I y]], 5, 1, {x, -\[Pi], \[Pi]}, {y, -\[Pi], \[Pi]}, ColorFunction -> 61, PlotPoints -> 75]
Out[8]=

Use a named color gradient:

In[9]:=
ResourceFunction["SaundersDigitPlot"][
 Re[Sin[x + I y]], 5, 1, {x, -\[Pi], \[Pi]}, {y, -\[Pi], \[Pi]}, ColorFunction -> "BrightBands", PlotPoints -> 75]
Out[9]=

PlotLegends (2) 

Show a legend for the digits:

In[10]:=
ResourceFunction["SaundersDigitPlot"][
 Im[Sin[x + I y]], 5, 1, {x, -\[Pi], \[Pi]}, {y, -\[Pi], \[Pi]}, PlotLegends -> Automatic, PlotPoints -> 75]
Out[10]=

Use Placed to change legend position:

In[11]:=
ResourceFunction["SaundersDigitPlot"][
 Im[Sin[x + I y]], 5, 1, {x, -\[Pi], \[Pi]}, {y, -\[Pi], \[Pi]}, PlotLegends -> Placed[Automatic, Before], PlotPoints -> 75]
Out[11]=

Neat Examples (1) 

Visualize the base-5 digits of a doubly periodic function:

In[12]:=
ResourceFunction["SaundersDigitPlot"][
 Re[JacobiSN[x + I y, 1/2]], 5, 1, {x, -2 EllipticK[1/2], 2 EllipticK[1/2]}, {y, -2 EllipticK[1/2], 2 EllipticK[1/2]}, ColorFunction -> 61, PlotPoints -> 205]
Out[12]=

Version History

  • 1.0.0 – 22 January 2021

Source Metadata

Related Resources

License Information