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

1 visualización (últimos 30 días)
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.

Respuesta aceptada

David Goodmanson
David Goodmanson el 22 de Jul. de 2020
Editada: David Goodmanson el 22 de Jul. de 2020
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 comentario
Wojciech Kalinowski
Wojciech Kalinowski el 22 de Jul. de 2020
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!

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by