# Java Math

## Writing math algorithms using a Java math class

A typical Java math class offers elementary trigonometric, logarithmic, and exponential methods. Consider more complex math like solving for this integral:

$\int_0^5 x^2$

Using a Java math class, programming to solve this integral requires the following considerations.

• Choice of algorithm: to use for numerical integration
• Memory management: to assign sufficient physical memory to variables
• Floating point considerations: to avoid numeric overflows and underflows
• Programming logic: to use nested loops for iterative solutions and matrix operations

Comparing a lengthy Java program to the single-line command integral(@(x) x.^2, 0, 5), which translates directly to a Java call like integral_xSq(1,0,5), allows mathematicians to focus on the math rather than on programming. Packages like MATLAB® and related toolboxes designed to handle such complexity can be a lucrative option when used with MATLAB Compiler SDK.