MAX-FINDING

creator:  Peter Knipp
repo:  github.com/pknipp/calculus

back to math APIs page
back to calculus page
differentiation
integration
root-finding
1st order differential equations
2nd order differential equations

In the url bar after 'https://basic-calculus.herokuapp.com/max-finding type the following:

/<point at which to start search for a maximum>/<function of x>

Note that this will not necessarily find the local maximum which is closest to the input point. The function may be any algebraically legal combination of the variable letter(s), numbers, parentheses, and/or binary operations +, -, *, ** (encouraged) or ^ (discouraged), PI and/or the most common unary functions: abs, acos, acosh, acot, acoth, acsc, acsch, asec, asech, asin, asinh, atan, atanh, cbrt, ceil, cos, cot, csc, exp, exp2, exp_m1, floor, fract, ln, ln_1p, log10, log2, sec, signum, sin, sqrt, tan, and trunc. (See docs for more information.) To represent division you must use either div, d, DIV or D because the usual division symbol (/) has special meaning in a url. Implied multiplication is allowed. Spaces are allowed but discouraged.
The construction rules for the values of any variable in the url are the same as those for the function except - of course - it cannot include the letter which represents the variable.
example:To find a local maximum of the function sin x + x/2 while starting the search at x = 1, type /1/sin(x)+xd2 after the current url address. The coordinates for this result should be (2.094..., 1.913...). If you want to find a local minimum, simply multiply your function by -1.
algorithms: simple bisection (and quadratic interpolation?)
json: Type '/api' in the url bar immediately before 'max-finding' if you would like the result in json rather than in html. A successful response will contain six properties. 'xi' is the location where the search starts, 'x' is where the search ends, 'f' is the function value there, 'bracket_steps' is the number of steps required to find numbers on either side of (ie, to 'bracket') the maximum, and 'max_steps' is the subsequent number of steps required for the algorithm to find this maximum to within the absolute accuracy specified in the last property: 'epsilon'. An unsuccessful response will have one property: 'message' (a string reporting the error).