the function polyder returns the numerator polynomial with the bad sign. For example [a,b]=polyder([3 6 9],[2 1 0]) returns
--> a =
9 36 9
b =
4 4 1 0 0
but the good polynomial a is -9 -36 -9.
back in 2007 I contributed a polyder function (and other functions) to FREEMAT. I see now that it has been replaced by a different, possibly more complete, function that, unfortunately is yielding a wrong result.
I am posting here again my original contribution in the hope that it will help someone in the future. If the FREEMAT development team wishes, they can use it to correct their own version:
% POLYDER POLYDER Polynomial Differentiation% % Usage% % The polyder function returns the polynomial coefficients resulting% from differentiation of polynomial p. The syntax for its use is either% % pder = polyder(p)% % for the derivitave of polynomial p, or% % convp1p2der = polyder(p1,p2)% % for the derivitave of polynomial conv(p1,p2), or still% % [nder,dder] = polyder(n,d)% % for the derivative of polynomial n/d (nder/dder). In all cases the% polynomial coefficients are assumed to be in decreasing degree.% % This is a small contribution to FreeMat% made by Paulo Xavier Candeias under GPL% (2007-06-14)% function[pder1,pder2]=polyder(p1,p2)ifnargin<1||nargout>narginerror('wrong use (see help polyder)');elseifnargin<2p2=1;endzp1=[0,p1(:).']; zp2 = [0,p2(:).'];pd1p2=conv(zp1(1:end-1).*(length(zp1)-1:-1:1),zp2);p1pd2=conv(zp1,zp2(1:end-1).*(length(zp2)-1:-1:1));ifnargout<2pder1=pd1p2+p1pd2;pder2=0;elsepder1=pd1p2-p1pd2;pder2=conv(zp2,zp2);endpder1=pder1(min(find(pder1,1),length(pder1)):end);pder2=pder2(min(find(pder2,1),length(pder2)):end);
Happy coding,
Paulo
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
back in 2007 I contributed a polyder function (and other functions) to FREEMAT. I see now that it has been replaced by a different, possibly more complete, function that, unfortunately is yielding a wrong result.
I am posting here again my original contribution in the hope that it will help someone in the future. If the FREEMAT development team wishes, they can use it to correct their own version:
Happy coding,
Paulo