Java Finance and mathematics

Source: Internet
Author: User

1, Commons-math/commons-lang-math

The above two packets are under Apache, the former is more powerful than the latter, the latter have the function before, the latter mainly to solve some of the usual procedures in the basic mathematical calculations, mainly in the range of Judgments (*range), random number generation (jvmrandom,randomutils), Fractional processing (fraction), digital conversion, size judgment (numberutils) and so on. The former can handle more complex data analysis (org.apache.commons.math.analysis), complex numbers (Org.apache.commons.math.complex), Distributed processing (org.apache.commons.math.distribution), Data prediction Estimation (org.apache.commons.math.estimation), fractions, genetics ( Org.apache.commons.math.genetics), Geometry (org.apache.commons.math.geometry), linear algebra (Org.apache.commons.math.linear), Optimization (org.apache.commons.math.optimization), Statistics (ORG.APACHE.COMMONS.MATH.STAT), Transfer (Org.apache.commons.math.transform ), and some common tool classes (Org.apache.commons.math.util).

Example: To find the intersection of two lines, the first two endpoints are (0,0), (1,1), the other two endpoints respectively (1,0), (0,1).

Train of thought: the intersection of a straight line is actually a solution of a two-yuan first-time equation. The solution of the equation can actually be transformed into a matrix in linear algebra. such as 3x+y=4 and x+2y=3 this two-yuan equation. Convert to Matrix:

You can now use the Realmatrix of the bread org.apache.commons.math.geometry class.


Double[][] Coefficientsdata = {3, 1}, {1, 2}};

Realmatrix coefficients = new Realmatriximpl (coefficientsdata);

Double[] Constants = {4, 3};

Double[] Solution = Coefficients.solve (constants);

System.out.println ("Their intersections are: x=" + solution[0] + "; y=" + solution[1]);

Summary: If you want to use the appropriate functionality (for example, variance variance is in the statistics Stat package), you can see how to use the APIs and official examples in the corresponding packages.

2, Jsjava

This plug-in, almost with the JS language rewrite the Apache Commons lang function, is actually above the Commons-math JS version (Jsjava-math.js), mainly has

1) jsjava-core.js:include Jsjava core Classes

2) jsjava-ajax.js:include Jsjava ajax Classes

3) jsjava-anim.js:include Jsjava animation classes

4) jsjava-math.js:include Jsjava math Classes

5) jsjava-blog.js:include Jsjava Blog Classes

6) Jsjava-comp.js:include Jsjava components classes

7) Jsjava-info.js:include Jsjava information classes

3, Jmathlib

Jmathlib is a Java open source class library used to compute complex mathematical expressions and graphically display the results of calculations. It is a clone of Matlab, Octave, Freemat, Scilab, but it is completely implemented by pure Java.

4, Matlab for Java

Provides Java interface to invoke some methods in MATLAB.

5, Jscience

The Jscience package is a powerful, Java™-based physical and mathematical library that provides a single architecture for all development, designed to help build synergies across different scientific domains. It is mainly the synergy of physics, Mathematics and Economy 3 aspects.

6, Jama

It is mainly used to solve the Cholesky decomposition in basic linear algebra, eigenvalues and eigenvectors, Lu decomposition, matrix columns, singular value decomposition


Summary of JAMA capabilities

Object manipulation

Set elements
Get elements

Elementary Operations

Scalar multiplication
Element-wise multiplication
Element-wise Division
unary minus


Symmetric eigenvalue
Nonsymmetric Eigenvalue

Equation Solution

Nonsingular Systems
Least squares

Derived quantities

Condition number

Here's an ax=b, 3x3 matrix, and then use Ax-b to detect overflow values.

Double[][] Array = {{1.,2.,3},{4.,5.,6.},{7.,8.,10.}};
Matrix A = new Matrix (array);
Matrix B = matrix.random (3,1);
Matrix x = a.solve (b);
Matrix residual = a.times (x). minus (b);
Double rnorm = Residual.norminf ();

7, Summary: Overall commons-math/commons-lang-math This is a good choice, documents and examples are more.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.