Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Testing latest pari + WASM + node.js... and it works?! Wow.

28495 views
License: GPL3
ubuntu2004
Function: derivn
Section: polynomials
C-Name: derivn
Prototype: GLDn
Help: derivn(x,n,{v}): n-th derivative of x with respect to v, or to the main
 variable of x if v is omitted.
Doc:
 $n$-th derivative of $x$ with respect to the main
 variable if $v$ is omitted, and with respect to $v$ otherwise; the integer
 $n$ must be nonnegative. The derivative
 of a scalar type is zero, and the derivative of a vector or matrix is done
 componentwise. One can use $x'$, $x''$, etc., as a shortcut if the
 derivative is with respect to the main variable of $x$.

 By definition, the main variable of a \typ{POLMOD} is the main variable among
 the coefficients from its two polynomial components (representative and
 modulus); in other words, assuming a polmod represents an element of
 $R[X]/(T(X))$, the variable $X$ is a mute variable and the derivative is
 taken with respect to the main variable used in the base ring $R$.

 \bprog
 ? f = (x/y)^5;
 ? derivn(f, 2)
 %2 = 20/y^5*x^3
 ? f''
 %3 = 20/y^5*x^3
 ? derivn(f, 2, 'x) \\ same since 'x is the main variable
 %4 = 20/y^5*x^3
 ? derivn(f, 2, 'y)
 %5 = 30/y^7*x^5
 @eprog

 This function also operates on closures, in which case the variable
 must be omitted. It returns a closure performing a numerical
 differentiation as per \kbd{derivnum}:
 \bprog
 ? f(x) = x^10;
 ? g = derivn(f, 5)
 ? g(1)
 %3 = 30240.000000000000000000000000000000000

 ? derivn(zeta, 2)(0)
 %4 = -2.0063564559085848512101000267299604382
 ? zeta''(0)
 %5 = -2.0063564559085848512101000267299604382
 @eprog