Function reference · Calculus
taylor
Computes a Taylor polynomial of an expression around a point.
Notation
taylor(expression, variable, center, degree)
Write it in an expression: nerdamer('taylor(sin(x),x,0,5)'), or in the Playground.
nerdamer.taylor
nerdamer.taylor(expression: ExpressionInput, variable: ExpressionInput, center: ExpressionInput, degree: ExpressionInput): Expression
A method on the default import. Arguments can be strings, as in Notation.
import { taylor }
import { taylor } from 'nerdamer/calculus';
taylor(expression: ExpressionInput, variable: ExpressionInput, center: ExpressionInput, degree: ExpressionInput): Expression
Import only this function, from nerdamer/calculus.
Parameters
expression- The expression to expand.
variable- The variable to expand in.
center- The point to expand around. It can't depend on
variable. degree- The highest power to keep, a nonnegative integer.
Returns
The polynomial, exact. If the derivatives can't be computed, the call is kept as it is.
Examples
Around another point, the terms are powers of x-1.
taylor(log(x),x,1,3)
// → (-1/2)*(-1+x)^2+(1/3)*(-1+x)^3-1+xOpen in PlaygroundThe center can be symbolic, such as pi.
taylor(cos(x),x,pi,2)
// → -1+(1/2)*(x-pi)^2Open in PlaygroundA polynomial stops once its derivatives are zero, so a high degree is fine.
taylor(x^3+x,x,0,100)
// → x+x^3Open in Playgroundlog(x) has no Taylor polynomial around 0, so the call is kept as it is.
taylor(log(x),x,0,3)
// → taylor(log(x), x, 0, 3)Open in PlaygroundGood to know
- A negative or fractional
degreeis an error. - A symbolic or very large
degreekeeps the call as it is. - The variable is local to the call: a value stored under its name, as in
x:5, isn't substituted inside it.
JavaScript examples
nerdamer.taylor('sin(x)', 'x', 0, 5).text()
// → x+(-1/6)*x^3+(1/120)*x^5