Regularizied hypergeometric function gives an error for z being greater than 1.
1 回表示 (過去 30 日間)
古いコメントを表示
Wojciech Kalinowski
2020 年 7 月 22 日
コメント済み: Wojciech Kalinowski
2020 年 7 月 22 日
Hi,
I'm having truble with using the hypergeometric function used in frational derivtives of log(ax+b). Using the formula from Wolfram:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/335472/image.png)
Where
is the regularizied hypergeometric function in the first fraction (fraction1 in code). This is the function that gives me problems.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/335475/image.png)
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.
0 件のコメント
採用された回答
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
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!