Pochhammer(x,n) for Negative x - Does any one know how to deal with this in Matlab etc?

686 Views Asked by At

I've tried to use a script that evaluates the Pochhammer symbol (rising factorial) in Matlab, but it fails to evaluate Pochhammer(x,n) whenever x is a negative number even though the expression is valid when x is negative (wolfram alpha and mathematica give answers for stuff like Pochhammer(-3,2)).

Can anyone help me get Pochhammer working in Matlab for negative arguments?

Thanks in advance,

Alex

1

There are 1 best solutions below

7
On BEST ANSWER

Assuming you're not doing anything too computing intensive, just write your own:

function p = rising_factorial(x, n)
    p = 1; 
    for k = 0:(n - 1)
        p = p * (x + k); 
    end
end

Also this might be off-topic. Stack overflow may be better-suited.