Polynomial ArithmeticΒΆ
Example of how to perform basic arithmetic on polynomials.
1public static void main( String[] args ) {
2 Polynomial a = Polynomial.wrap(5,-2,3,0.5,30.4);
3 Polynomial b = Polynomial.wrap(-0.4,8.4,-2.3);
4
5 System.out.println("a = "+a);
6 System.out.println("b = "+b);
7 System.out.println("a + b = "+PolynomialOps.add(a,b,null));
8 System.out.println("a * b = "+PolynomialOps.multiply(a, b, null));
9
10 // Declare storage for the quotient and the remainder
11 Polynomial q = new Polynomial(10);
12 Polynomial r = new Polynomial(10);
13 PolynomialOps.divide(a, b, q,r);
14 System.out.println("a / b = ( "+q+" , "+r+" )");
15 System.out.println("Derivative a = "+PolynomialOps.derivative(a,null));
16}