# Can someone check this boundary condition for me?

At the moment I'm comparing plots between the implicit numerical Black-Scholes PDE and the Monte-Carlo Method for the Black-Scholes equation. However, for the particular boundary condition I'm using I'm having a bit of difficulty finding the error in the code, so I thought I should post it here.

I'm currently using an initial condition for the 'option' at time $T$ maturity to be $-\frac{2}{\pi}\tan^{-1}\left(\frac{1}{ \tan((S_{t}\pi) / 2)}\right)$ where $S_{T}$ is the spot price. (This equation is for the sawtooth wave as given here: https://en.wikipedia.org/wiki/Sawtooth_wave)

In addition, the other boundary condition as $S_{t} \rightarrow \infty$ is $0$ (I know this is not a good boundary condition but it's enough for what I need). Anyway, the issue I'm having is that when I use the above initial condition in both the PDE and Monte Carlo programs they both generate different plots, which is an issue I don't have when when I use other trigonometric functions (such as $\sin(S_{t}/5)$etc.). The parameters are exactly the same, and I've taken it over a sufficiently large interval ($0$ to $400$), so I'm unsure what the problem could be. If it's not too much trouble, could someone try using these boundary conditions in their program to check how it should look?

EDIT: I forgot to include the parameters I had for the programs - I took Maturity time $T$ to be equal to $1$, interest rate equal to $0$, volatility equal to $0.25$ and spot price ranging from $0$ to $400$. The PDE is an implicit numerical scheme, and there are 1600 grid points in space and 2000 in time. The Monte-Carlo simulation was run 50000 at each grid point (the MC also has 1600 space grid points). In addition, the payoff is $-\frac{2}{\pi}\tan^{-1}\left(\frac{1}{ \tan((S_{t}\pi) / 2)}\right)$

I've attached a picture below of how the plots look:

Domain from 0 to 10:

• several questions: Are you solving the PDE numerically or using the formula? If numerical, what scheme and how many grid points? How many Monte Carlo runs? I assume the inverse tan function is a payoff?
– bcf
Commented Jul 25, 2016 at 11:31
• Thanks for the reply! I've updated the original comment with the answer to all your questions, please let me know if you need any further information Commented Jul 25, 2016 at 13:30

Judging from the oscillations near $S=0$, it looks like the payoff function is causing these problems.
Your payoff should go towards -1 as $S$ goes towards zero, but your computer might just evaluate it at $S=0$, producing nonsense as a result. Depending on the exact implementation, this will then spread through the neighborhood of that point, causing these ripples.
• From the plot the payoff does seem to got to $-1$ as $S$ goes to zero (at least the Monte Carlo plot does). At any rate, do you happen to have any suggestions as to what needs to be changed? I'm really not sure anymore what else I can do... Commented Jul 25, 2016 at 14:17
• Sure, I've added the picture now. I made the first (initial) boundary condition (i.e. the payoff) to be equal to:$-\frac{2}{\pi}\tan^{-1}\left(\frac{1}{ \tan((S_{t}\pi) / 2)}\right)$, where for $S_{t}$ (the spot price) I get the code to iterate over a range of values such that $S_{t} = Smin + j*ds$ and $ds = (S_{max}-S_{min})/N$ (note that $j$ is just an iterating term for each grid point 'step' and $N$ is the maximum grid point). The other boundary conditions (as $S_{t} \rightarrow \infty$) are set to $0$. I hope that helps! Commented Jul 25, 2016 at 22:02
• Thanks, you were right about how the payoff being the issue and being equal to $-1$ as $S$ approaches $0$, and I think I've resolved the issue now - I didn't comprehend what you wrote in your original comment (It was around 12:30 at night when I replied to you so I was quite tired!) but now that I've tried it out I've managed to get both plots to match by increasing the grid points on the PDE to 6000. I was under the impression that the Monte Carlo plot was wrong so I spent all my time trying to make it work :( Thanks again! Commented Jul 25, 2016 at 23:01