def fdiff(self, argindex=4): from diofant import Sum if argindex == 1: # Diff wrt n raise ArgumentIndexError(self, argindex) elif argindex == 2: # Diff wrt a n, a, b, x = self.args k = Dummy("k") f1 = 1 / (a + b + n + k + 1) f2 = ((a + b + 2*k + 1) * RisingFactorial(b + k + 1, n - k) / ((n - k) * RisingFactorial(a + b + k + 1, n - k))) return Sum(f1 * (jacobi(n, a, b, x) + f2*jacobi(k, a, b, x)), (k, 0, n - 1)) elif argindex == 3: # Diff wrt b n, a, b, x = self.args k = Dummy("k") f1 = 1 / (a + b + n + k + 1) f2 = (-1)**(n - k) * ((a + b + 2*k + 1) * RisingFactorial(a + k + 1, n - k) / ((n - k) * RisingFactorial(a + b + k + 1, n - k))) return Sum(f1 * (jacobi(n, a, b, x) + f2*jacobi(k, a, b, x)), (k, 0, n - 1)) elif argindex == 4: # Diff wrt x n, a, b, x = self.args return S.Half * (a + b + n + 1) * jacobi(n - 1, a + 1, b + 1, x) else: raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=2): if argindex == 2: # Diff wrt x n, x = self.args return 2*n*hermite(n - 1, x) else: # wrt n raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=2): if argindex == 2: # Diff wrt x n, x = self.args return ((n + 1) * chebyshevt(n + 1, x) - x * chebyshevu(n, x)) / (x**2 - 1) else: # wrt n raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=2): if argindex == 2: # Diff wrt x n, x = self.args return n * chebyshevu(n - 1, x) else: # wrt n raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=3): if argindex != 3: raise ArgumentIndexError(self, argindex) nap = Tuple(*[a + 1 for a in self.ap]) nbq = Tuple(*[b + 1 for b in self.bq]) fac = Mul(*self.ap) / Mul(*self.bq) return fac * hyper(nap, nbq, self.argument)
def fdiff(self, argindex=1): if len(self.args) == 3: n, z, m = self.args fm, fn = sqrt(1 - m * sin(z)**2), 1 - n * sin(z)**2 if argindex == 1: return (elliptic_e(z, m) + (m - n) * elliptic_f(z, m) / n + (n**2 - m) * elliptic_pi(n, z, m) / n - n * fm * sin(2 * z) / (2 * fn)) / (2 * (m - n) * (n - 1)) elif argindex == 2: return 1 / (fm * fn) elif argindex == 3: return (elliptic_e(z, m) / (m - 1) + elliptic_pi(n, z, m) - m * sin(2 * z) / (2 * (m - 1) * fm)) / (2 * (n - m)) else: n, m = self.args if argindex == 1: return (elliptic_e(m) + (m - n) * elliptic_k(m) / n + (n**2 - m) * elliptic_pi(n, m) / n) / (2 * (m - n) * (n - 1)) elif argindex == 2: return (elliptic_e(m) / (m - 1) + elliptic_pi(n, m)) / (2 * (n - m)) raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=2): if argindex == 2: # Diff wrt x n, x = self.args return -assoc_laguerre(n - 1, 1, x) else: # wrt n raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=1): """ Returns the first derivative of the function. """ if argindex == 1: return 1/self.args[0] else: raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=3): if argindex == 3: # Diff wrt x # Find better formula, this is unsuitable for x = 1 n, m, x = self.args return 1/(x**2 - 1)*(x*n*assoc_legendre(n, m, x) - (m + n)*assoc_legendre(n - 1, m, x)) else: # wrt n, m raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=2): if argindex == 2: # Diff wrt x # Find better formula, this is unsuitable for x = 1 n, x = self.args return n/(x**2 - 1)*(x*legendre(n, x) - legendre(n - 1, x)) else: # wrt n raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=1): if argindex == 1: # I didn't know if there is a better way to handle default arguments k = 0 if len(self.args) > 1: k = self.args[1] return self.func(self.args[0], k + 1) else: raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=1): z, m = self.args fm = sqrt(1 - m * sin(z)**2) if argindex == 1: return 1 / fm elif argindex == 2: return (elliptic_e(z, m) / (2 * m * (1 - m)) - elliptic_f(z, m) / (2 * m) - sin(2 * z) / (4 * (1 - m) * fm)) raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex): x, y = self.args if argindex == 1: # Diff wrt x return beta(x, y) * (digamma(x) - digamma(x + y)) elif argindex == 2: # Diff wrt y return beta(x, y) * (digamma(y) - digamma(x + y)) else: raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=2): from diofant import meijerg, unpolarify if argindex == 2: a, z = self.args return -exp(-unpolarify(z)) * z**(a - 1) elif argindex == 1: a, z = self.args return uppergamma(a, z) * log(z) + meijerg([], [1, 1], [0, 0, a], [], z) else: raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=3): from diofant import Sum if argindex == 1: # Diff wrt n raise ArgumentIndexError(self, argindex) elif argindex == 2: # Diff wrt a n, a, x = self.args k = Dummy("k") factor1 = 2 * (1 + (-1)**(n - k)) * (k + a) / ((k + n + 2*a) * (n - k)) factor2 = 2*(k + 1) / ((k + 2*a) * (2*k + 2*a + 1)) + \ 2 / (k + n + 2*a) kern = factor1*gegenbauer(k, a, x) + factor2*gegenbauer(n, a, x) return Sum(kern, (k, 0, n - 1)) elif argindex == 3: # Diff wrt x n, a, x = self.args return 2*a*gegenbauer(n - 1, a + 1, x) else: raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=1): if len(self.args) == 2: z, m = self.args if argindex == 1: return sqrt(1 - m * sin(z)**2) elif argindex == 2: return (elliptic_e(z, m) - elliptic_f(z, m)) / (2 * m) else: z = self.args[0] if argindex == 1: return (elliptic_e(z) - elliptic_k(z)) / (2 * z) raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=4): if argindex == 3: # Diff wrt theta n, m, theta, phi = self.args return (m * cot(theta) * Ynm(n, m, theta, phi) + sqrt((n - m)*(n + m + 1)) * exp(-I*phi) * Ynm(n, m + 1, theta, phi)) elif argindex == 4: # Diff wrt phi n, m, theta, phi = self.args return I * m * Ynm(n, m, theta, phi) else: # diff wrt n, m, etc raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=3): from diofant import Sum if argindex == 2: # Diff wrt alpha n, alpha, x = self.args k = Dummy("k") return Sum(assoc_laguerre(k, alpha, x) / (n - alpha), (k, 0, n - 1)) elif argindex == 3: # Diff wrt x n, alpha, x = self.args return -assoc_laguerre(n - 1, alpha + 1, x) else: # wrt n raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=1): from diofant import polygamma if argindex == 1: # http://functions.wolfram.com/GammaBetaErf/Binomial/20/01/01/ n, k = self.args return binomial(n, k)*(polygamma(0, n + 1) - polygamma(0, n - k + 1)) elif argindex == 2: # http://functions.wolfram.com/GammaBetaErf/Binomial/20/01/02/ n, k = self.args return binomial(n, k)*(polygamma(0, n - k + 1) - polygamma(0, k + 1)) else: raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=1): """ Return the first derivative of this function. """ x = self.args[0] if len(self.args) == 1: if argindex == 1: return LambertW(x)/(x*(1 + LambertW(x))) else: k = self.args[1] if argindex == 1: return LambertW(x, k)/(x*(1 + LambertW(x, k))) raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=2): if argindex != 2: raise ArgumentIndexError(self, argindex) return self.__class__(self.order - 1, self.argument) - \ self * (self.order + 1)/self.argument
def fdiff(self, argindex=1): if argindex == 1: return DiracDelta(self.args[0]) else: raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=1): if argindex == 1: return polygamma(0, self.args[0]) else: raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=2): if argindex == 2: n, z = self.args[:2] return polygamma(n + 1, z) else: raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=1): from diofant import gamma, polygamma if argindex == 1: return gamma(self.args[0] + 1)*polygamma(0, self.args[0] + 1) else: raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=1): if argindex == 1: return airyaiprime(self.args[0]) else: raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=1): if argindex == 1: return self.args[0] * airybi(self.args[0]) else: raise ArgumentIndexError(self, argindex)
def fdiff(self, argindex=2): if argindex != 2: raise ArgumentIndexError(self, argindex) return (self._b / 2 * self.__class__(self.order - 1, self.argument) - self._a / 2 * self.__class__(self.order + 1, self.argument))