from
slatec
by Ben Barrowes The slatec library converted into matlab functions.
[x,f,d]=dfdtru(x,f,d);
function [x,f,d]=dfdtru(x,f,d);
persistent fact1 fact2 xx ;
if isempty(fact1), fact1=0; end;
if isempty(fact2), fact2=0; end;
if isempty(xx), xx=0; end;
xx = x;
fact1 = xx + 1;
fact2 = xx - 2;
f = xx.*fact1.*fact2;
d = fact1.*fact2 + xx.*(fact1+fact2);
end %subroutine dfdtru