Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

How can you compute Itō Integrals with Mathematica? I tried searching through the documentations but I didn't find anything.

P.S. I was not at all sure how to tag this question. I had to put in at least one tag, and I do not have enough reputation to create a new one. Somebody with more rep can feel free to tag it appropriately.

share|improve this question
I could explain how to solve a Stratonovich SDE (which is simply related to an Ito SDE). Would that be enough or do you need more? –  acl Mar 18 '12 at 11:21
What is an Itô Integral? (please include links to this kind of information in your questions) –  Mr.Wizard Mar 18 '12 at 12:31

5 Answers 5

While I cannot answer your question I would like to point at Computational Financial Mathematics using MATHEMATICA®: Optimal Trading in Stocks and Options, which should answer it.

From the index: Mathematica graphics

share|improve this answer
Welcome to Mathematica.SE Guido! I changed the link to the American Amazon store instead of the German one to make it somewhat more useful to the general public here, and added a part of the index that I hope will be relevant in judging whether or not this book is useful. I note that the book is from 2002, so that is multiple versions of MMA ago. –  Sjoerd C. de Vries Mar 18 '12 at 13:45
Thanks for helping out. I need to learn more about the 'rules of the road' on a forum like this one. –  gwr Mar 18 '12 at 14:32
The cited book by Stojanovic will of course be obsolescent is some regards, given that it was published in 2002, well before the whole bundle of financial functions were added. –  murray Mar 18 '12 at 15:30
Glad to be of service.If you need any help several useful links are on top of the page. There's the ubiquitous FAQ, but also for informal chatting our chat room and for formal questions about the function of the site itself our meta-site. On the meta site you'll also find a MMA tool to automatically upload MMA graphics here. –  Sjoerd C. de Vries Mar 18 '12 at 15:40
@SjoerdC.deVries That tool is a godsend. I used to avoid questions that required a graphics upload. –  tkott Mar 19 '12 at 18:34

Mathematica doesn't have built-in functions to compute things around Ito integrals.

I know two authors who have done packages around this, I've never used them though.

From Mark Fisher (see the stochastic calculus paragraph for ItosLemma and EulerSimulate packages) http://www.markfisher.net/~mefisher/mma/mathematica.html

From Wilfrid Kendall

Here's an example of how you could generate paths of a Black-Scholes process. You can generalize this example to more complex cases (if you look for optimizations you'll find that inverting the FoldList and Map leads to a better speed but the code is less readable.)

SimpleBSPaths[S0_,r_,sigma_,nPaths_,dt_,nTimeSteps_,seed_:1] :=
Module[ {randomNumbers},


    randomNumbers = RandomReal[NormalDistribution[],{nPaths,nTimeSteps-1}];

    Map[ (*equivalent to a loop for each path*)
        FoldList[ (*equivalent to a loop for each timestep*)
            (#1 Exp[(r-1./2 sigma^2) dt + sigma Sqrt[dt] #2])& (*#1= St-1, #2=n01 for this path and timestep*)
            # (*all random numbers for this path, has dimension {nTimeSteps-1}*)
        ]& (*produced path of dimension {nTimeSteps}*)
        randomNumbers (*all random numbers for all paths, has dimension {nPaths,nTimeSteps-1}*)
    ] (*produced paths of dimension {nPaths,nTimeSteps}*)



Similarly for correlated Black-Scholes paths

SimpleMultiBSPaths[S0_,r_,sigma_,correlMatrix_,nPaths_,dt_,nTimeSteps_,seed_:1] :=
    Module[ {randomNumbers,sigmaDiag,covar,A, numberOfUnderlyings},


        sigmaDiag = DiagonalMatrix@sigma;
        covar = sigmaDiag.correlMatrix.sigmaDiag;
        A = Transpose@CholeskyDecomposition@covar;

        randomNumbers = RandomReal[NormalDistribution[],{nPaths,nTimeSteps-1,numberOfUnderlyings}];

        Map[ (*equivalent to a loop for each path*)
            FoldList[ (*equivalent to a loop for each timestep*)
                (#1 Exp[(r-1./2 sigma^2) dt + Sqrt[dt] A.#2])& (*#1= St-1, #2=n01s for this path and timestep*)
                # (*all random numbers for this path, has dimension {nTimeSteps-1,numberOfUnderlyings}*)
            ]& (*produced path of dimension {nTimeSteps,numberOfUnderlyings}*)
            randomNumbers (*all random numbers for all paths, has dimension {nPaths,nTimeSteps-1,numberOfUnderlyings}*)
        ] (*produced paths of dimension {nPaths,nTimeSteps,numberOfUnderlyings}*)


S0 = {100, 105};
r = 0.03;
sigma = {0.2, 0.3};
correlMatrix = {{1., 0.8}, {0.8, 1.}};
nPaths = 5;
dt = 1/12.;
nTimeSteps = 24;
paths = SimpleMultiBSPaths[S0, r, sigma, correlMatrix, nPaths, dt, nTimeSteps];
(*Displays two correlated underlyings on one path*)
paths[[1]] // Transpose // ListLinePlot
share|improve this answer
Well done. Can you implement the Euler-Maruyama or SRK method for finding the weak solution of Black-Scholes SDE in Mathematica? –  Fazlollah Soleymani Sep 1 '13 at 16:23

It looks like Wolfram have written some stochastic stuff for their finance platform:


These are presumably internally written (by Michael Kelly?) add on packages.

share|improve this answer

One good way would be to attend my Warsaw University seminar ;-) Seriously, you should specify if you are interested in symbolic or numerical computation. It is a very different thing (just as in the stochastic case) Stojanovic's book has a nice implementation of the multi-dimensional Ito formula - which is essentially a (continuous) stochastic calculus analogue of the chain rule in ordinary calculus. Since it is a lot more complicated than the chain rule, it is useful to be able to use a computer algebra system for this purpose. Computing Ito integrals numerically is quite a different matter and is basically the same thing as "simulation". Stojanovic implementation is for Mathematica 3 so it is way too inefficient compared with what you can do in version 6 and later. Remember - the key thing is that it is much faster to generate random vectors and arrays than individual random numbers that are their elements.


Well, for numerical Ito integrals you could always take a look at my old demonstration on Wolfram's Demonstrations Project.

share|improve this answer
Both, actually. I am taking a course in Financial Mathematics, and we rely on hand calculation and Excel. I trust neither my hand calculations nor Excel, so I figured I ought try doing this in Mathematica, hence the question. –  Mr Alpha Mar 20 '12 at 17:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.