示例#1
0
 public Polynomial differentiate(int order) {
   double coef;
   double power;
   Polynomial result = new Polynomial();
   Polynomial derivTerm;
   for (Map.Entry<Double, Double> e : this.entrySet()) {
     coef = e.getValue();
     power = e.getKey();
     if (order <= power) {
       derivTerm =
           new Polynomial(
               new double[][] {{power - order, coef * numutil.MathTools.binomNum(power, order)}});
       result = result.add(derivTerm);
     }
   }
   return result;
 }
示例#2
0
 public Polynomial antiderivative(int order) {
   double coef;
   double power;
   Polynomial result = new Polynomial();
   Polynomial antiderivTerm;
   // for each term, raise its power by order amount and divide coefficient by
   // (order+power)!/power!
   for (Map.Entry<Double, Double> e : this.entrySet()) {
     coef = e.getValue();
     power = e.getKey();
     antiderivTerm =
         new Polynomial(
             new double[][] {
               {power + order, coef / numutil.MathTools.binomNum(power + order, order)}
             });
     result = result.add(antiderivTerm);
   }
   return result;
 }