


function dxp=getPowerDeriv(x,p,k)
The k-th derivative of x^p
INPUTS
x: base
p: power
k: derivative order
OUTPUTS
dxp: k-th derivative of x^p
SPECIAL REQUIREMENTS
none

0001 function dxp=getPowerDeriv(x,p,k) 0002 %function dxp=getPowerDeriv(x,p,k) 0003 % The k-th derivative of x^p 0004 % 0005 % INPUTS 0006 % x: base 0007 % p: power 0008 % k: derivative order 0009 % 0010 % OUTPUTS 0011 % dxp: k-th derivative of x^p 0012 % 0013 % SPECIAL REQUIREMENTS 0014 % none 0015 0016 % Copyright (C) 2011 Dynare Team 0017 % 0018 % This file is part of Dynare. 0019 % 0020 % Dynare is free software: you can redistribute it and/or modify 0021 % it under the terms of the GNU General Public License as published by 0022 % the Free Software Foundation, either version 3 of the License, or 0023 % (at your option) any later version. 0024 % 0025 % Dynare is distributed in the hope that it will be useful, 0026 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0027 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0028 % GNU General Public License for more details. 0029 % 0030 % You should have received a copy of the GNU General Public License 0031 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 0032 0033 if (abs(x) < 1e-12) && (p > 0) && (k >= p) && (abs(p - round(p)) < 1e-12) 0034 dxp = 0; 0035 else 0036 dxp = x^(p-k); 0037 for i=0:k-1 0038 dxp = dxp*p; 0039 p = p-1; 0040 end 0041 end 0042 end