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: