commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luc Maisonobe <Luc.Maison...@free.fr>
Subject Re: commons math and the finite difference method
Date Mon, 01 Jun 2009 13:39:34 GMT
Julien Martin a écrit :
> Hello,
> 
> I am trying to put into practice the finite difference method using
> commons math 2.0. I am in reference to the following book: "Options,
> futures and other derivatives" by John Hull. I have attached a gif of
> page 445 of the 6th edition of the book. Note that I assume that the
> discretisation of the differential equation has already being achieved.

Image attachements are filtered out from messages to this list, so we
cannot see them.

> 
> I am at a loss about how to NUMERICALLY resolve the system of equations
> in section (17.31). As I will have a system of M-1 equations each having
> three terms on the left-hand side member, it is not possible to use a
> square matrix.

I guess you are trying to solve an overdetermined linear system, i.e. a
system A.X = B with A having M-1 rows (M > 4) and 3 columns.

Such systems are solved in least square sense. Instead of finding X such
that A.X is exactly B, we find the X value that minimizes || A.X - B ||.
This is done by using the Q.R decomposition.

Commons-math supports this decomposition. Here is a rough idea of what
you should do:

 RealMatrix a = ...;
 RealVector b = ...;
 RealVector x = new QRDecompositionImpl(a).getSolver().solve(b);

The QRDecompositionImpl class is currently in the
org.apache.commons.math.linear.decomposition package. We are currently
discussing on the developers list to decide if this package should
remain or if it should disappear and all the classes be pushed up
directly in the linear package. If we do this, you will only need to
update your import statement once commons-math 2.0 is officially out.

Luc

> 
> Can anyone please point me to the relevant parts of the commons math API
> and give me clues as to how to numerically resolve the equation system
> please?
> 
> Thanks in advance,
> 
> Julien.
> 
> 
> ------------------------------------------------------------------------
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message