Behavior of the bump function's derivatives

5
Consider the classical C ¥ bump function with support on (-1,1) rescaled so it has magnitude 1 at its center. In[2]:= Bump@x_D := PiecewiseB::ExpB x 2 x 2 - 1 F, Abs@xD < 1>>F; Bump@xD Plot@Bump@xD, 8x, - 1, 1<, Filling AxisD Out[2]= ª x 2 -1+x 2 Abs@xD < 1 0 True Out[3]= -1.0 -0.5 0.5 1.0 0.2 0.4 0.6 0.8 1.0 Observe that the second derivative becomes large in magnitude near the edges of the support. As the absolute value of the function and its derivatives is symmetric about the origin, only half of it is visualized. In[4]:= Plot@Evaluate@Table@Derivative@dD@BumpD@xD, 8d, 0, 2<DD, 8x, 0, 1<, Filling Axis, PlotRange Full, PlotLabel "Zeroth, first, and second derivatives"D Out[4]= 0.2 0.4 0.6 0.8 1.0 5 10 15 20 Zeroth, first, and second derivatives The magnitudes observed grow strikingly as the derivative order increases. In[5]:= Table@8d, N@MaxValue@Abs@Derivative@dD@BumpD@xDD,xDD<, 8d, 0, 7<D MatrixForm Out[5]//MatrixForm= 0 1. 1 2.17036 2 21.0659 3 506.688 4 22604.9 5 1.62107 · 10 6 6 2.21471 · 10 8 7 3.95463 · 10 10

description

An investigation into the behavior of the C^\inf bump function's ill-behaved derivatives and how they may be mitigated for numerical use.

Transcript of Behavior of the bump function's derivatives

Page 1: Behavior of the bump function's derivatives

Consider the classical C¥bump function with support on (-1,1) rescaled so it has magnitude 1 at its center.

In[2]:= Bump@x_D := PiecewiseB::ExpBx2

x2 - 1F, Abs@xD < 1>>F; Bump@xD

Plot@Bump@xD, 8x, -1, 1<, Filling ® AxisD

Out[2]= ã

x2

-1+x2 Abs@xD < 10 True

Out[3]=

-1.0 -0.5 0.5 1.0

0.2

0.4

0.6

0.8

1.0

Observe that the second derivative becomes large in magnitude near the edges of the support. As the absolute value ofthe function and its derivatives is symmetric about the origin, only half of it is visualized.

In[4]:= Plot@Evaluate@Table@Derivative@dD@BumpD@xD, 8d, 0, 2<DD,8x, 0, 1<, Filling ® Axis, PlotRange ® Full,PlotLabel ® "Zeroth, first, and second derivatives"D

Out[4]=

0.2 0.4 0.6 0.8 1.0

5

10

15

20

Zeroth, first, and second derivatives

The magnitudes observed grow strikingly as the derivative order increases.

In[5]:= Table@8d, N@MaxValue@Abs@Derivative@dD@BumpD@xDD, xDD<, 8d, 0, 7<D �� MatrixForm

Out[5]//MatrixForm=

0 1.

1 2.17036

2 21.0659

3 506.688

4 22 604.9

5 1.62107 ´ 106

6 2.21471 ´ 108

7 3.95463 ´ 1010

This growth makes the bump function ill-suited for numerical initialization smoothing on coarse grids. A coarse gridthat can fully resolve the bump function will likely not be able to resolve its derivatives. This lack of resolution maycause ringing to appear and can destabilize a simulation. One fix would be to initialize with a Gaussian rather than abump function. However, Gaussian functions do not have compact support (and alleviating that issue in a C¥-waybrings one back again to bump functions).

Page 2: Behavior of the bump function's derivatives

This growth makes the bump function ill-suited for numerical initialization smoothing on coarse grids. A coarse gridthat can fully resolve the bump function will likely not be able to resolve its derivatives. This lack of resolution maycause ringing to appear and can destabilize a simulation. One fix would be to initialize with a Gaussian rather than abump function. However, Gaussian functions do not have compact support (and alleviating that issue in a C¥-waybrings one back again to bump functions).

One way to alleviate this problem is to use powers of the bump function to minimize the derivative magnitudes up tosome finite derivative order. Powers of the “magnitude-one” bump function still possess that same magnitude at x = 0and remain C¥.

In[6]:= BumpPower@n_D := PiecewiseB::ExpBn ð12

ð12- 1

F, Abs@ð1D < 1>>F &; BumpPower@nD@xD

Plot@Evaluate@Table@Derivative@0D@BumpPower@powerDD@xD, 8power, 1, 7<DD,8x, 0, 1<, Filling ® Axis, PlotRange ® Full,PlotLabel -> "Bump function to increasing powers"D

Out[6]= ã

n x2

-1+x2 Abs@xD < 10 True

Out[7]=

0.2 0.4 0.6 0.8 1.0

0.2

0.4

0.6

0.8

1.0Bump function to increasing powers

Derivative maximum magnitudes seem to decrease with the chosen power up to some limiting case. After that case,the abruptness of the function’s magnitude increase at x = 0 dominates the behavior.

In[8]:= Plot@Evaluate@Table@Derivative@1D@BumpPower@powerDD@xD, 8power, 1, 7<DD,8x, 0, 1<, Filling ® Axis, PlotRange ® Full,PlotLabel ® "First derivative of increasing powers"D

Out[8]=

0.2 0.4 0.6 0.8 1.0

-2.5

-2.0

-1.5

-1.0

-0.5

First derivative of increasing powers

2 BumpFunctionPowers.nb

Page 3: Behavior of the bump function's derivatives

In[9]:= Plot@Evaluate@Table@Derivative@2D@BumpPower@powerDD@xD, 8power, 1, 12<DD,8x, 0, 1<, Filling ® Axis, PlotRange ® Full,PlotLabel ® "Second derivative of increasing powers"D

Out[9]=0.2 0.4 0.6 0.8 1.0

-20

-10

10

20

Second derivative of increasing powers

Spot checking a few powers suggests that low powers best control the second derivative.

In[10]:= MagnitudeBumpPowerDerivative@n_, d_D :=

N@MaxValue@Abs@Derivative@dD@BumpPower@nDD@xDD, xDD

In[11]:= Table@MagnitudeBumpPowerDerivative@n, dD, 8d, 0, 5<, 8n, 1, 7<D �� MatrixForm

Out[11]//MatrixForm=

1. 1. 1. 1. 1. 1. 1.

2.17036 1.91156 1.98514 2.11782 2.26213 2.40592 2.54565

21.0659 10.2802 8.36423 8.06356 10. 12. 14.

506.688 127.416 73.0156 57.093 51.8527 62.4822 75.8722

22 604.9 2881.99 1129.32 687.778 534.214 542.248 595.288

1.62107 ´ 106 103 571. 29 124.4 14 355.1 9722.52 8005.8 7479.46

The table suggests that taking a power near four will optimally control the first and second derivative. Attempting tominimize the derivative absolute magnitudes shows the following continous power-dependence:

In[12]:= Plot@8MagnitudeBumpPowerDerivative@n, 1D,MagnitudeBumpPowerDerivative@n, 2D

<, 8n, 3, 5<, PlotRange ® 8All, 80, Full<<,PlotLabel ® "First and second derivative versus power taken"D

Out[12]=

3.0 3.5 4.0 4.5 5.0

2

4

6

8

10First and second derivative versus power taken

Going to a non-integer power seems to buy very little benefit for the extra computational cost. The integer power 4seems to be a reasonable tradeoff between the first and second derivative’s maximum absolute magnitudes.

BumpFunctionPowers.nb 3

Page 4: Behavior of the bump function's derivatives

In[13]:= BumpPower@4D@xD

Out[13]= ã

4 x2

-1+x2 Abs@xD < 10 True

In[14]:= Plot@Evaluate@Table@Derivative@0D@BumpPower@powerDD@xD, 8power, 81, 4<<DD,8x, 0, 1<, Filling ® Axis, PlotRange ® FullD

Out[14]=

0.2 0.4 0.6 0.8 1.0

0.2

0.4

0.6

0.8

1.0

In[15]:= Plot@Evaluate@Table@Derivative@1D@BumpPower@powerDD@xD, 8power, 81, 4<<DD,8x, 0, 1<, Filling ® Axis, PlotRange ® FullD

Out[15]=

0.2 0.4 0.6 0.8 1.0

-2.0

-1.5

-1.0

-0.5

In[16]:= Plot@Evaluate@Table@Derivative@2D@BumpPower@powerDD@xD, 8power, 81, 4<<DD,8x, 0, 1<, Filling ® Axis, PlotRange ® FullD

Out[16]=

0.2 0.4 0.6 0.8 1.0

-5

5

10

15

20

4 BumpFunctionPowers.nb

Page 5: Behavior of the bump function's derivatives

In[17]:= Plot@Evaluate@Table@Derivative@3D@BumpPower@powerDD@xD, 8power, 81, 4<<DD,8x, 0, 1<, Filling ® Axis, PlotRange ® FullD

Out[17]=

0.2 0.4 0.6 0.8 1.0

-500

-400

-300

-200

-100

100

200

BumpFunctionPowers.nb 5