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

4 ビュー (過去 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 Center および File ExchangeLogical についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by