`finmath-experiments`

you may continue in that shell, although it is safer to `/exit`

that shell and restart a new one).
- Open a command shell
- Type
`mkdir git`

(to create a folder`git`

, if you do not have one) - Type
`cd git`

(to enter your`git`

folder) - Next, clone (i.e. download) the repository (
`git`

), change to the cloned directory (`cd`

) and start jshell via Maven (`mvn`

) by typing the following three commands:

Terminal Window

```
git clone https://github.com/finmath/finmath-experiments
cd finmath-experiments
mvn clean compile jshell:run
```

JShell:

```
DoubleUnaryOperator value = strike -> net.finmath.functions.AnalyticFormulas.blackScholesOptionValue(100.0, 0.05, 0.20, 2.0, strike);
(new net.finmath.plots.Plot2D(0.0, 300.0, 100, value)).show();
```

In the following we plot the finite difference approximation of the second derivative of the value of the European option. It can be shown that the second derivative of \( V \) with respect to \( K \) is related to the probability density of \( S(T) \) under \( \mathbb{Q} \), that is \[ \frac{\partial V(T,K)}{\partial K} \ = \ \phi_{S(T)}(K) \ \frac{N(0)}{N(T)} \text{.} \]

JShell:

```
import net.finmath.functions.AnalyticFormulas;
import net.finmath.plots.Plot2D;
DoubleUnaryOperator value = strike -> AnalyticFormulas.blackScholesOptionValue(100.0, 0.05, 0.20, 2.0, strike);
double h = 1E-2;
DoubleUnaryOperator secondDerivative = strike -> (value.applyAsDouble(strike+h) - 2*value.applyAsDouble(strike) + value.applyAsDouble(strike-h))/(2*h);
Plot2D plot = new Plot2D(0.0, 300.0, 100, secondDerivative);
plot.setYAxisNumberFormat(new java.text.DecimalFormat("0.0E00"));
plot.setXAxisLabel("strike").setYAxisLabel("frequency");
plot.show();
```