Invoking the Gamma function fails. Although the Pkg.add downloads the algorithms. I had to write out the gamma function:

gamma=quadgk(z-> (t^(z-1)*exp(z-t)),0,1,rtol=1e-4)

(0.17730992497288517, 2.7755575615628914e-17)

If ‘t’ is known, then this works every time. Gamma in Julia seems to be a problem. What am I doing wrong?

Can’t really tell what the error is you’re describing since you’ve not shown any of the details, but I think you are wanting to do `using SpecialFunctions`

to get the gamma function.

Hi and welcome to the Julia discourse.

Could you maybe provide code that is not working? As Daniel wrote, you might have (just) added a package (installed it on hard drive) but not loaded it (`using`

).

Also – which package you did add would be good to know (see also Please read: make it easier to help you for more details).

Two formatting tips: You can put code in backticks ```

to have inline code (or three of them to have a code block) – and you can also put math in `$...$`

to have it rendered like `$\alpha$`

renders nicely as \alpha.

I am not an expert on gamma functions, but it seems that your formulation is not correct.

First, the integration in your formula is over z whereas according to Gamma function - Wikipedia the integration is over t. Moreover, you are integrating between 0 and 1 and again the formula I know integrates between 0 and \infty.

For your original question, as other have already pointed out, this should work:

```
using SpecialFunctions
res = gamma(1) # = 1
res = gamma(0.5) # = 1.77
```

Apart from the issues already highlighted by others, to me it seems you want `gamma`

to be a function, so that you could write e.g. `gamma(1)`

. But then you’d need

```
gamma = t -> first(quadgk(z -> t^(z - 1) * ..., ...))
```

(well actually, `gamma = z -> first(quadgk(t -> ..., ...))`

as pointed out by Rudi79).

In your current definition `gamma`

is just a float which can only be evaluated if your `t`

was defined prior, as you point out.

Thank you for the answers. You are correct about choosing z, but it did not work for some reason. I will try it again.

gamma=quadgk(t-> ((t^(z-1))*exp(-t)),0,10,rtol=1e-4)

(0.9999546000702376, 6.425888090522136e-7)

This time, I found another error in the integral. Using the limits of integration as t = 0 to 100 for z=1.

gamma=quadgk(t-> ((t^(z-1))*exp(-t)),0,100,rtol=1e-4)

(1.000000000000002, 6.472503355493802e-6)

I will try using special functions again. Thank you! Beware! I might return.