Finding root using finmath library in java

359 Views Asked by At

I am trying to implement the Internal Rate Of Return of some cashflows.

0 = (c1/(1+r)) + (c2/(1+r)^2) + (c3/(1+r)^3) .... like formula and we will be finding the root r.

At this point I am end up with a java library called finmath.

It has a package named net.finmath.rootfinder including these classes

BisectionSearch 
NewtonsMethod   
SecantMethod

That is ok so far. But, when I try to make use of with my formula there is no method expecting me to enter c1, c2, c3 values as list. The only methods these classes implements are

double  getAccuracy() 
double  getBestPoint() 
double  getNextPoint() 
int     getNumberOfIterations() 
boolean isDone() 
void    setValueAndDerivative(double value, double derivative) 

My question is how can I make use of this library to solve my equation? I hope some one have any idea about making use of this library.

1

There are 1 best solutions below

1
On BEST ANSWER

Bisection Method, Newton's method, Secant Methods are some methods that are used to find/estimate the root of an equation. (Do some maths to know about those methods). To use those mathematical methods, you should have a algebraic equation.

I think the classes you stated implements those mathematical methods of root finding. You should make your equation by substituting values for c1, c2, c3,... and after that you can use those java methods. I think you have to implement you java method to find the value of the mathematical expression when a value for r is given. (Mathematical expression, not the equation)