
Calculate the polynomial coefficients of the Nth derivative of a polynomial coefficient wave

pb
Alternatively, the snippet below shows how to calculate the coefficient wave corresponding to the Nth derivative of W_coef without ever using poly(W_coef, x). It returns this new coefficient wave as a reference to a free wave. You can make it global by using MoveWave or by changing the code to have /O instead of /FREE flags. Or, better yet, just embrace the freeness! (See Programming.ihf if you aren't used to Igor's new free waves.)
As an illustration of how convenient this is, consider the following, where W_coef has, say, 100 terms:
curve_15th_deriv = poly(PolyDeriv(W_coef, 15), x)
Boom! You just (analytically) calculated the 15th derivative of a 100-term polynomial in one line.
Function/WAVE PolyDeriv(coefs, n) // Returns a (free) polynomial coefficient wave that is the nth derivative of the input polynomial coefficient wave Wave coefs // polynomial coefficients Variable n // positive integer >= 1 if(n < numpnts(coefs)) Make/FREE/D/N=(numpnts(coefs)-n) deriv deriv = (factorial(p+n)/factorial(p))*coefs[p+n] else Make/FREE/D/N=1 deriv = 0 endif return deriv End

Forum

Support

Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More