This is the third in a series of posts looking at our current ArrayFire examples. The code can be compiled and run from `arrayfire/examples/`

when you download and install the ArrayFire library. Today we will discuss the examples found in the `financial/`

directory.

In these examples, my machine has the following configuration:

1 2 3 4 5 6 7 |
ArrayFire v1.9 (build XXXXXXX) by AccelerEyes (64-bit Linux) License: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX CUDA toolkit 5.0, driver 304.54 GPU0 Quadro 6000, 6144 MB, Compute 2.0 (single,double) Display Device: GPU0 Quadro 6000 Memory Usage: 5549 MB free (6144 MB total)... |

There are a number of applications of ArrayFire and GPU programming in the world of finance and markets. Here we have an example of Black-Scholes, which is a model for computing options prices in the stock market. Understanding how this model works isn't necessary to understand this example. In fact, ArrayFire improves the relationship between the scientist/mathematician/analyst who needs to use a particular model, and the programmer who has to write it. Rather than having a whole bunch of nasty GPU code getting in the way and obscuring the algorithm, ArrayFire allows the algorithm to take precedence in your code, and express itself naturally. Take a look at the following snippet of algorithm code:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// S = Underlying stock price // X = Strike Price // R = Risk free rate of interest // V = Volatility // T = Time to maturity array d1 = log(S / X); d1 = d1 + (R + (V*V)*0.5) * T; d1 = d1 / (V*sqrt(T)); array d2 = d1 - (V*sqrt(T)); C = S * cnd(d1) - (X * exp((-R)*T) * cnd(d2)); P = X * exp((-R)*T) * cnd(-d2) - (S * cnd(-d1)); |

In this snippet, it is really easy to see what the mathematics are doing. We don't even have to deal with for-loops because of the way ArrayFire naturally works with the array data type.

Using ArrayFire can simplify many mathematical algorithms and bring the speed of the GPU to the analyst without forcing him or her to waste valuable time with the details of GPU kernel coding. So go ahead, see which algorithms *you* can run on the GPU by downloading the ArrayFire library today!

---

**Posts in this series:**

- ArrayFire Examples (Part 1 of 8) – Getting Started
- ArrayFire Examples (Part 2 of 8) – Benchmarks
- ArrayFire Examples (Part 3 of 8) – Financial
- ArrayFire Examples (Part 4 of 8) - Image Processing
- ArrayFire Examples (Part 5 of 8) - Machine Learning
- ArrayFire Examples (Part 6 of 8) - Multiple GPU
- ArrayFire Examples (Part 7 of 8) - PDE

** **