|
29 | 29 | import org.matheclipse.core.interfaces.IExpr;
|
30 | 30 | import org.matheclipse.core.interfaces.IReal;
|
31 | 31 | import org.matheclipse.core.interfaces.ISymbol;
|
| 32 | +import org.matheclipse.core.numerics.integral.ClenshawCurtis; |
| 33 | +import org.matheclipse.core.numerics.integral.GaussLobatto; |
| 34 | +import org.matheclipse.core.numerics.integral.NewtonCotes; |
32 | 35 | import org.matheclipse.core.numerics.integral.Quadrature;
|
33 | 36 | import org.matheclipse.core.numerics.integral.Quadrature.QuadratureResult;
|
34 | 37 | import org.matheclipse.core.numerics.integral.TanhSinh;
|
@@ -127,17 +130,39 @@ public static double integrate(String method, IAST list, final double min, final
|
127 | 130 | integrator = new TrapezoidIntegrator();
|
128 | 131 | } else if ("GaussKronrod".equalsIgnoreCase(method)) {
|
129 | 132 | return gausKronrodRule(maxIterations, f, min, max);
|
| 133 | + } else if ("ClenshawCurtisRule".equalsIgnoreCase(method)) { |
| 134 | + Quadrature quadrature = new ClenshawCurtis(Config.SPECIAL_FUNCTIONS_TOLERANCE, 1000); |
| 135 | + QuadratureResult result = quadrature.integrate(f, min, max); |
| 136 | + if (result.converged) { |
| 137 | + return result.estimate; |
| 138 | + } |
| 139 | + // NIntegrate failed to converge after `1` refinements in `2` in the region `3`. |
| 140 | + throw new ArgumentTypeException("ncvi", F.List(F.ZZ(result.evaluations), xVar, list.rest())); |
130 | 141 | } else if ("DoubleExponential".equalsIgnoreCase(method)) {
|
131 |
| - Quadrature quadrature = new TanhSinh(1e-8, 1000); |
| 142 | + Quadrature quadrature = new TanhSinh(Config.SPECIAL_FUNCTIONS_TOLERANCE, maxIterations); |
| 143 | + QuadratureResult result = quadrature.integrate(f, min, max); |
| 144 | + if (result.converged) { |
| 145 | + return result.estimate; |
| 146 | + } |
| 147 | + // NIntegrate failed to converge after `1` refinements in `2` in the region `3`. |
| 148 | + throw new ArgumentTypeException("ncvi", F.List(F.ZZ(result.evaluations), xVar, list.rest())); |
| 149 | + } else if ("GaussLobatto".equalsIgnoreCase(method)) { |
| 150 | + Quadrature quadrature = new GaussLobatto(Config.SPECIAL_FUNCTIONS_TOLERANCE, 1000); |
| 151 | + QuadratureResult result = quadrature.integrate(f, min, max); |
| 152 | + if (result.converged) { |
| 153 | + return result.estimate; |
| 154 | + } |
| 155 | + // NIntegrate failed to converge after `1` refinements in `2` in the region `3`. |
| 156 | + throw new ArgumentTypeException("ncvi", F.List(F.ZZ(result.evaluations), xVar, list.rest())); |
| 157 | + |
| 158 | + } else if ("NewtonCotesRule".equalsIgnoreCase(method)) { |
| 159 | + Quadrature quadrature = new NewtonCotes(Config.SPECIAL_FUNCTIONS_TOLERANCE, 1000); |
132 | 160 | QuadratureResult result = quadrature.integrate(f, min, max);
|
133 | 161 | if (result.converged) {
|
134 | 162 | return result.estimate;
|
135 | 163 | }
|
136 | 164 | // NIntegrate failed to converge after `1` refinements in `2` in the region `3`.
|
137 | 165 | throw new ArgumentTypeException("ncvi", F.List(F.ZZ(result.evaluations), xVar, list.rest()));
|
138 |
| - // Errors. printMessage(S.NIntegrate, "ncvi", F.List(F.ZZ(result.evaluations), xVar, |
139 |
| - // list.rest()), |
140 |
| - // engine); |
141 | 166 | } else {
|
142 | 167 | if (maxPoints > 1000) {
|
143 | 168 | // github 150 - avoid StackOverflow from recursion
|
|
0 commit comments