Regularizied hypergeometric function gives an error for z being greater than 1.

조회 수: 7 (최근 30일)
Hi,
I'm having truble with using the hypergeometric function used in frational derivtives of log(ax+b). Using the formula from Wolfram:
Where is the regularizied hypergeometric function in the first fraction (fraction1 in code). This is the function that gives me problems.
Since, hypergeom(c,d,z) function is the genral one to convert it to the regularized version I needed to divide it by gamma(d), according to This post.
function [result] = natural_log_frac_derivative(a,b,x,n)
fraction1 = ((a*x^(1-n)) * (hypergeom([1,1],[2-n],-a*x/b))/gamma([2-n]))/b;
fraction2 = floor((pi()-angle(b)-angle(1+(a*x)/b))/(2*pi()));
fraction3 = (x^(-n)*(2*j*pi()*fraction2+log10(b)))/gamma(1-n);
result = fraction1+fraction3;
end
The exact problem lies when I try to get a larger derivative than the first. n>1 gives an error.
natural_log_frac_derivative(1,1,2,1)
Gives a 1/3 result as expected.
natural_log_frac_derivative(1,1,2,2)
Gives the following error (line 5 is the second line in the code above):
Error using sym/hypergeom (line 43)
Invalid arguments.
Error in sym.useSymForNumeric (line 165)
res = cast(fn(args{:}),superiorfloat(varargin{:}));
Error in hypergeom (line 41)
h = sym.useSymForNumeric(@hypergeom,n,d,z);
Error in natural_log_frac_derivative (line 5)
fraction1 = ((a*x^(1-n)) * (hypergeom([1,1],[2-n],-a*x/b))/gamma([2-n]))/b;
Any ideas how to fix this so the function is not limited to n = 1?
Thank you in advanced.

채택된 답변

David Goodmanson
David Goodmanson 2020년 7월 22일
편집: David Goodmanson 2020년 7월 22일
Hi Wojciech,
I am assuming that there is no problem when n is not an integer, only when n is a positive integer greater than 1. In that case there is an identity available in terms of a different F21, but at least there is no need for that when a and b are positive real, and probably also when a and b both have positive real part. When n is an integer, then straight differentiation shows that
dn/dxn log(ax+b) = (-)^(n-1)*(n-1)!*a^n/(ax+b)^n
  댓글 수: 1
Wojciech Kalinowski
Wojciech Kalinowski 2020년 7월 22일
Hi David,
So just add a IF statment to check if z is a natural number or not, and if it is evaulated using that method?
That does indeed work. Thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by