Solve Financial equation in Java?

236 Views Asked by At

I'm trying to solve a bit complex equation in order to find the Yield of a bond. I know the dirty price (computed with the clean price and the accrued interest) and I know how to write the price of the bond with the Yield which is the variable I want.

Well, in fact I just want to know how to solve an equation of this type:

Equation to solve

There is no need to understand the financial logic, I just want to know how to solve this equation. I want to find r in a nutshell

I know Maple and Scilab do it very easily (a fonction solve is implemented), but in Java ? Is there an API or a framework that can solve my equation, is it possible to use Maple in a Java program ?

2

There are 2 best solutions below

3
xenteros On

You can make the left side of the equation 0 by -124,155. Then find r for which the right side is larger than 0 and one for which it's less than 0. Then use bisection for finding r for which the right side equals 0.

0
DSkoog On

To answer the question on if you can run Maple code in Java, the answer is yes. OpenMaple is a suite of functions that allows you to access Maple algorithms and data structures in compiled C, Java, or Visual Basic programs.

Here's an example from Maple's help: http://www.maplesoft.com/support/help/maple/view.aspx?path=OpenMaple%2fJava%2fExamples