SERVING THE QUANTITATIVE FINANCE COMMUNITY

• 1
• 2
• 3
• 4
• 5
• 7

lovenatalya
Posts: 287
Joined: December 10th, 2013, 5:54 pm

### Re: Silly questions

Late to the party.

I like Alan's heat equation idea immensely. In fact the Fourier solution and the image solution are just the two (dual) sides of the Poisson summation formula converging faster at $t\searrow 0$ and $t\rightarrow\infty$ respectively. One possible drawback of the $\frac1t$ solution is the integration of the Green's function has to be enumerated either as a sum of error functions or numerically. Both the Chebyshev polynomial series method of outrun and Fourier series method of ppauper are good, but, just as outrun has pointed out, they converge slowly. The reason is, just as outrun suspected, due to the discontinuity in the derivative of the original function. The convergence speed is $O(\frac1n)$ or even lower, where $n$ is the index of the series. Also the derivative close to the vertex is not uniformly convergent but osciallates around the discontinuity. This is called the Gibbs phenomenon. All of these approximations are actually analytical functions (as in their Taylor power series are convergent), not only infinitely differentiable.

Here are 2 more approximations satisfying the requirement.

1.  A silly one that is not analytic (Taylor power series is undefined at two points) but infinitely differentiable that does satisfy the requirement.  For the sake of convenience I linear transform the Cuchulainn's hat function into the absolute function $|x|$. My approximation is simply $|x|+e^{\frac{b}{(x+a)(x-a)}}\Theta(a^2-x^2)$ where $a>0$ and $b>0$ are parameters to be adjusted according to your requirement of the fidelity of the approximation, and $\Theta$ is the Heaviside function. The trajectory of my approximating function simply rounds off the sharp corner near it and assumes the shape of original function away from the corner with the whole curve being infinitely differentiable.

2. Any smoothing summation kernel, convolution or not, would work. The smoothness (differentiability or analycity) of the resulting function is determined by that of the kernel. The convergence can be controlled by a parameter. It is then the Dirac delta functional. A simple example of this is simply the convolution operator $\Phi[t,f]:=\frac1{\sqrt t}\phi\big(\frac{\cdot}{\sqrt t}\big)*f(\cdot)$, where $\phi$ is, for example, the standard Gaussian function. The convolution is analytic since $\phi$ is and the convolution uniformly converges with high speed to $f$ as $t\rightarrow0$. This example is just the heat equation solution with the initial condition extended by the zero function to infinity, dispensing with the finite boundary condition and thus the infinite source images for the Green's function, or reflection and shifting of $f$.
$\phi\big(\frac{x}{\sqrt t}) = exp(-x^2/4t)$,  Yes?
So, the motivation is to solve heat equation in an infinite rod and the solution is a convolution integral between this kernel and $f$? I just need to get to the stage to roll out a solution which is what Alan sketched? I need to check those steps,

Your solution is a kind of stroke of genius.
$\phi\big(\frac{x}{\sqrt t}) = \frac1{\sqrt{2\pi}}\exp\big(-\frac{x^2}{2t}\big)$ with measure $dx$. Do keep in mind, as I have said in my last post, you can replace $\sqrt t$ with $t^k$ for a corresponding positive $k$ to achieve any desired convergence speed.

Yes to all your questions, except (just to state the obvious to be safe) to emphasize that we extend the wedge shape of $f$ to infinity for the convolution with $\phi$. Basically, it is the shape (after linear transformation) of $|x|$. Please do check Alan's expression. It has the right look but I have not checked the exact computation.

Do you like my solution #1? I thought it was even better. What may be your reservation?

Oh, you flatter me.   Thank you.

Cuchulainn
Topic Author
Posts: 61524
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### Re: Silly questions

I think lovenatalya's #2 solution is the best so far. Leads to a simple analytic form containing just a couple cumnormals and a couple exponentials -- that's it!. No infinite sum and infinitely smooth.

With no checking, something like: define

$u(t,x) = 2 x \left[ \Phi(\frac{1/2 - x}{\sqrt{t}}) - \Phi(-\frac{x}{\sqrt{t}}) \right] - \sqrt{\frac{2 t}{\pi}} \left[ e^{-(1/2-x)^2/2 t} - e^{-x^2/ 2 t} \right]$,

where $\Phi(\cdot)$ is the cumnormal function.

Then, the approximating function is

$f(t,x) = u(t,x) + u(t,1-x)$,

converging to the desired $f(x)$ as $t \downarrow 0$.

Likely typos or errors, so needs to be re-done carefully!
The above formula of 4 terms is formed by integration by parts I presume. Since f() is linear I can see how the last two terms roll out. I can also see the 2nd term but where does the first term come from?
Indeed, f() must have compact support. i.e. identically zero outside a closed interval.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget

Cuchulainn
Topic Author
Posts: 61524
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### Re: Silly questions

Just to recap: the solution of the 1d heat equation in an infinite rod with initial condition $f$ whose support is the interval $(a,b)$ is given by the convolution integral

$u(x,t)= \dfrac {1} {2 \sqrt{\pi t}} \int _{a}^{b} f(v) \exp(- (x-v)^2/4t) dv$.

So, this is the start position to find the regularizer?

Q: to check Alan's formula with let's say $f(v) = 2v$ we use integration by parts, yes? In this case a closed solution is possible.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget

outrun
Posts: 4573
Joined: April 29th, 2016, 1:40 pm

### Re: Silly questions

So truncating is fine? You will not longer have smoothness everywhere

edit:
instead of truncating F(x) with -1<x<+1 you can do a transform F(tan(h)) with -pi/2 < h < pi/2.

ppauper
Posts: 70239
Joined: November 15th, 2001, 1:29 pm

### Re: Silly questions

if you want something with compact support, go with one of the truncated series

Otherwise, (related to the heat conduction solution on an infinite rod)
Cuch's original function was $2xH(x)+2(1-2x)H(x-1/2)+2(x-1)H(x-1)$
just replace the Heaviside step functions by (complementary) error functions
$x\,\mathrm{erfc}(-x/\epsilon)+(1-2x)\,\mathrm{erfc}(-(x-1/2)/\epsilon)+(x-1)\,\mathrm{erfc}(-(x-1)/\epsilon)$
with $\epsilon\ge 0$

as $\epsilon\to 0+$ you recover the original function

lovenatalya
Posts: 287
Joined: December 10th, 2013, 5:54 pm

### Re: Silly questions

Just to recap: the solution of the 1d heat equation in an infinite rod with initial condition $f$ whose support is the interval $(a,b)$ is given by the convolution integral

$u(x,t)= \dfrac {1} {2 \sqrt{\pi t}} \int _{a}^{b} f(v) \exp(- (x-v)^2/4t) dv$.

So, this is the start position to find the regularizer?

Q: to check Alan's formula with let's say $f(v) = 2v$ we use integration by parts, yes? In this case a closed solution is possible.
Your integral formula is correct. Integration by parts is indeed the way to get all the terms in Alan's formula. Each straight line segment produces two terms, one with the error function, the other with the exponential (coming from the boundary condition at the sharp corner when you integrate by parts).

Regarding your requirement for the approximating function to be compactly supported, do you require the whole function to be infinitely differentiable, especially at $\{0,1\}$? And where do you want the zeros to be, strictly outside of $(0,1)$ or outside of $(-\epsilon, 1+\epsilon)$ for some $\epsilon>0$?

1) If not, you just need to either cut off once the $u(x,t)$ hits zero or shift it upward by $|u(0,t)|$.

2) If you do, a finite sum of "nice" functions will not achieve that. By "nice" functions, I mean any usual algebraic, transcendental functions, or error functions without any essential singularities. The reason is that these functions are analytic and zeroing their values in an interval forces them to vanish on the whole line by virtue of the analytic continuation. In that consideration, I would like to again bring your attention again to my solution #1. It gives you all you want, infinite differentiability and compact-supportedness, by virtue of its essential singularities.

It would be better if you can completely specify all your requirements rigorously (Do you want the approximating function to be nonnegative, for example?) so as not to leave any ambiguities. Of course, I understand maybe you do not have that luxury as of now as you are exploring your options.

lovenatalya
Posts: 287
Joined: December 10th, 2013, 5:54 pm

### Re: Silly questions

if you want something with compact support, go with one of the truncated series
It depends on whether he wants the whole approximating function to be infinitely differentiable particularly at $\{0,1\}$.
Otherwise, (related to the heat conduction solution on an infinite rod)
Cuch's original function was $2xH(x)+2(1-2x)H(x-1/2)+2(x-1)H(x-1)$
just replace the Heaviside step functions by (complementary) error functions
$x\,\mathrm{erfc}(-x/\epsilon)+(1-2x)\,\mathrm{erfc}(-(x-1/2)/\epsilon)+(x-1)\,\mathrm{erfc}(-(x-1)/\epsilon)$
with $\epsilon\ge 0$

as $\epsilon\to 0+$ you recover the original function
This expression strictly speaking is not compact-supported, since it is negative outside of any interval containing $(0,1)$, even though the value decays exponentially as $|x|\rightarrow\infty$. The biggest dips below zero happen at $\{0,1\}$. We do not know whether Cuchulainn would allow the approximating function to be negative. It would be nice if he specifies all requirements at the outset.

ppauper
Posts: 70239
Joined: November 15th, 2001, 1:29 pm

### Re: Silly questions

if you want something with compact support, go with one of the truncated series
It depends on whether he wants the whole approximating function to be infinitely differentiable particularly at $\{0,1\}$.
Otherwise, (related to the heat conduction solution on an infinite rod)
Cuch's original function was $2xH(x)+2(1-2x)H(x-1/2)+2(x-1)H(x-1)$
just replace the Heaviside step functions by (complementary) error functions
$x\,\mathrm{erfc}(-x/\epsilon)+(1-2x)\,\mathrm{erfc}(-(x-1/2)/\epsilon)+(x-1)\,\mathrm{erfc}(-(x-1)/\epsilon)$
with $\epsilon\ge 0$

as $\epsilon\to 0+$ you recover the original function
This expression strictly speaking is not compact-supported
No one said it was.
I said that if cuch wanted something with compact support, he should go with a truncated sum, and otherwise (i.e. if he doesn't require compact support) go with the error function expression

ppauper
Posts: 70239
Joined: November 15th, 2001, 1:29 pm

### Re: Silly questions

Just to recap: the solution of the 1d heat equation in an infinite rod with initial condition $f$ whose support is the interval $(a,b)$ is given by the convolution integral

$u(x,t)= \dfrac {1} {2 \sqrt{\pi t}} \int _{a}^{b} f(v) \exp(- (x-v)^2/4t) dv$.
using the function cuch gave originally, this gives

$x\,\mathrm{erf}(x/(2t^{1/2}))+(1-2x)\mathrm{erf}((x-1/2)/(2t^{1/2})) +(x-1)\mathrm{erf}(x-1)/(2t^{1/2}))$
$+\frac{2t^{1/2}}{\pi^{1/2}}\left[e^{-x^{2}/(4t)}-2e^{-(x-1/2)^{2}/(4t)}+e^{-(x-1)^{2}/(4t)}\right]$

the solution I posted had erfc instead of erf and didn't have the exponential terms

ppauper
Posts: 70239
Joined: November 15th, 2001, 1:29 pm

### Re: Silly questions

if you want something with compact support, go with one of the truncated series
It depends on whether he wants the whole approximating function to be infinitely differentiable particularly at $\{0,1\}$.
For the Fourier series, we have
$f_{N}(x)=\sum_{m=1}^{N}\frac{8}{m^2\pi^2}e^{-c^{2}m^{2}\pi^{2}t}\sin\frac{m\pi}{2}\sin m\pi x$
which is infinitely differentiable for finite $N$ (as is the Chebyshev series)
Similarly, $g_{\epsilon}(x)=x\,\mathrm{erfc}(-x/\epsilon)+(1-2x)\,\mathrm{erfc}(-(x-1/2)/\epsilon)+(x-1)\,\mathrm{erfc}(-(x-1)/\epsilon)$ is infinitely differentiable for $\epsilon\ne 0$

Cuchulainn
Topic Author
Posts: 61524
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### Re: Silly questions

Excellent posts here! I had a requirement indeed and the discussion became more general(which is also good!). To put things in context:

1. Approximating PDE by FDM can produce oscillations in the solution(option price) and derivatives when the initial condition (payoff) is not very smooth. Many time steps can be needed for the bespoke hat function when used as initial condition for the 1d heat equation on (0,1) with Dirichlet boundary conditions. In fact, my exact solution was precisely what ppauper wrote down.
2. I want to test pauper's function $g_{\varepsilon}$ as new initial condition. We should get faster convergence.
3. The next question is to determine feasibility how to use erf(x) for let's say put payoff (BTW call payoff does not have compact support).

In FDM the tendency is to 'smooth' initial conditions in finite-dimensional space (cubic splines, averaging etc.) but these introduce new issues.

4. lovenatlya's proposal #1 next.

//
One more thing: what is the accuracy as a function of $\varepsilon$. In other words, how do we choose this parameter? e.g. 0.001 etc.?
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget

ppauper
Posts: 70239
Joined: November 15th, 2001, 1:29 pm

### Re: Silly questions

//
One more thing: what is the accuracy as a function of $\varepsilon$. In other words, how do we choose this parameter? e.g. 0.001 etc.?
I haven't done anything rigorous, but I fired up maple and plotted the difference between $g_{\epsilon}$ and cuch's function,
$\epsilon=0.1$ largest absolute error $\approx 0.05$ (meaning the difference between the two functions)
$\epsilon=0.01$ largest absolute error $\approx 0.005$
$\epsilon=0.001$ largest absolute error $\approx 0.0015$
$\epsilon=0.0001$ largest absolute error $\approx 5\times10^{-5}$

Cuchulainn
Topic Author
Posts: 61524
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### Re: Silly questions

Concerning the requirement, the original function should only be bevelled at x = 1/2 while its form remains unchanged outside a small neighbourhood of x = 1/2 while still having a new well-posed PDE whose solution is 'close' to that of the original PDE.  Based on my exact solution only 1 error function is needed?

An initial  sanity check is to compute the arc length (and area?) from the original and mollified functions.

http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget

ppauper
Posts: 70239
Joined: November 15th, 2001, 1:29 pm

### Re: Silly questions

so
$2x\,\mathrm{Heaviside}(x)+(1-2x)\,\mathrm{erfc}(-(x-1/2)/\epsilon)+2(x-1)\,\mathrm{Heaviside}(x-1)$

the area under that between 0 and 1 is I believe
$(-1/2+\epsilon^2)\,\mathrm{erf}(1/(2\epsilon))+1-\epsilon/\pi^{1/2}\exp(-1/(4\epsilon^2))$

Cuchulainn
Topic Author
Posts: 61524
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### Re: Silly questions

so
$2x\,\mathrm{Heaviside}(x)+(1-2x)\,\mathrm{erfc}(-(x-1/2)/\epsilon)+2(x-1)\,\mathrm{Heaviside}(x-1)$

the area under that between 0 and 1 is I believe
$(-1/2+\epsilon^2)\,\mathrm{erf}(1/(2\epsilon))+1-\epsilon/\pi^{1/2}\exp(-1/(4\epsilon^2))$
Looks nice and symmetric.
What area when $\varepsilon = 0.01$? (exact area = 0.5)
I suppose a graph in Maple is easy?
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...

 JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...

GZIP: On