How can I find negative factorial ? (-0.5)!

12 visualizaciones (últimos 30 días)
esam baker
esam baker el 9 de Ag. de 2022
Respondida: Bruno Luong el 9 de Ag. de 2022
How can I find negative factorial ? (-0.5)!
any one can help me the code to fined negative factorial as (-0.5)

Respuesta aceptada

the cyclist
the cyclist el 9 de Ag. de 2022
Editada: the cyclist el 9 de Ag. de 2022
Use the gamma function:
x = -0.5;
gamma(x+1) % gamma(x+1) is equal to factorial(x)
ans = 1.7725

Más respuestas (2)

John D'Errico
John D'Errico el 9 de Ag. de 2022
Editada: John D'Errico el 9 de Ag. de 2022
Simple. Yes, you could use MATLAB, IF you knew that the extension of the function factorial(n) onto the real line is just gamma(n+1). So you might just do this:
gamma(-0.5 + 1)
ans = 1.7725
Or if you want a prettier form...
gamma(sym(-0.5) + 1)
ans = 
Perhaps a tricky way is to use the Euler reflection formula.
It tells us that
gamma(z)*gamma(1-z) = pi/sin(pi*z)
Now, recalling the relation between factorial and gamma, and accepting that factorial can indeed be extended onto the real line, we can write that as:
factorial(z-1)*factorial(-z) = pi/sin(pi*z)
Does that help us in any way? When happens when z = 1/2? z=1/2 is actully a truly magic number in our problem.
factorial(1/2 - 1)*factorial(-1/2) = [factorial(-1/2)]^2 = pi/sin(pi/2)
Does that help us?
Since sin(pi/2) = 1, then we see the square of the desired factorial we wanted to compute is just pi.
And therefore?
factorial(-1/2) = sqrt(pi)
Neat. I never even needed to use MATLAB. Pencil and paper was enough. Unless, of course, I was too lazy to do the math. It is always more fun to do the math.
  4 comentarios
esam baker
esam baker el 9 de Ag. de 2022
Sir your answer was very helpful to me, I Am very grateful for your reply.
Bruno Luong
Bruno Luong el 9 de Ag. de 2022
@John D'Errico "And therefore? factorial(-1/2) = sqrt(pi)"
Do you have to dsicard the negative solution -sqrt(pi) before this conclusion?

Iniciar sesión para comentar.


Bruno Luong
Bruno Luong el 9 de Ag. de 2022
There are actually different ways of extending factorial function, see here
So rigourously your question is not precise to be answered

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by