MCPcopy Index your code
hub / github.com/Aghajari/MathParser / limit

Method limit

MathParser/src/com/aghajari/math/Functions.java:197–220  ·  view source on GitHub ↗
(MathParser parser, String variable, String exp)

Source from the content-addressed store, hash-verified

195 }
196
197 public static double limit(MathParser parser, String variable, String exp) throws MathParserException {
198 MathParser newParser = parser.clone();
199 variable = variable.replace("->", "=");
200 if (!variable.contains("="))
201 throw new MathInvalidParameterException("limit(): invalid variable (" + variable + "), must be something like x->2");
202
203 String[] var = variable.split("=");
204 String variableName = var[0];
205 if (!Utils.isIdentifier(variableName))
206 throw new MathInvalidParameterException("limit(): invalid variable name (" + variableName + ")");
207
208 double a;
209 var[1] = Utils.realTrim(var[1]);
210 if (var[1].equalsIgnoreCase("+inf") || var[1].equalsIgnoreCase("inf"))
211 a = Double.POSITIVE_INFINITY;
212 else if (var[1].equalsIgnoreCase("-inf"))
213 a = Double.NEGATIVE_INFINITY;
214 else
215 a = newParser.parse(var[1]);
216
217 //newParser.setRoundEnabled(false);
218 newParser.addVariable(variableName, 0, 0);
219 return LimitFunction.limit(newParser, newParser.getVariable(variableName), exp, a);
220 }
221
222 public static double derivative(MathParser parser, String variableName, String exp, double x) throws MathParserException {
223 if (!Utils.isIdentifier(variableName))

Callers 1

limMethod · 0.95

Calls 7

isIdentifierMethod · 0.95
realTrimMethod · 0.95
parseMethod · 0.95
addVariableMethod · 0.95
limitMethod · 0.95
getVariableMethod · 0.95
cloneMethod · 0.80

Tested by

no test coverage detected