# Setting the parameters in a defined function vs replacement rule in the formula

I have the following definition in my Mathematica notebook.

scalar[\[Rho]_, n_, l_, L_] := ((\[Rho]^l)/((\[Rho]^2 + L^2)^(
n + l + 1)) )
Hypergeometric2F1[-(n + l + 1), -n, l + 2, -(\[Rho]^2/L^2)]


This is what is making it too weird.

This gives as a result Indeterminate.

scalar[0, 0, 0, 1]


But, the following

scalar[\[Rho], 0, 0, 1] /. \[Rho] -> 0


gives one.

Also, the following gives Indeterminate

\[Rho]^l/((\[Rho]^2 + L^2)^(n + l + 1))
Hypergeometric2F1[-(n + l + 1), -n,
l + 2, -(\[Rho]^2/L^2)] /. \[Rho] -> 0 /. L -> 1 /. n -> 0 /.
l -> 0


While this

\[Rho]^l/((\[Rho]^2 + L^2)^(n + l + 1))
Hypergeometric2F1[-(n + l + 1), -n, l + 2, -(\[Rho]^2/L^2)] /.
L -> 1 /. n -> 0 /. l -> 0 /. \[Rho] -> 0


gives 1.

In this case, I know what the correct result is. It is the 1, not the zero.

I am trying to understand how Mathematica is working.

It seems that in the first case it is putting the function at $\rho=0$ while in the second it seems that is approaching the zero; behaving like a limit. However this is particularly weird, because if I am not mistaken I am just implementing a replacement rule.

To support this statement, the following limit gives 1.

Limit[scalar[\[Rho], 0, 0, 1], \[Rho] -> 0]


What is even more puzzling for me is what happens when I take the form of the defined function and I use only replacement rules. If I don't put the replacement rule of the $\rho$ in the end I get an invalid answer.

It seems like I am answering my own question, but I am actually not. This was done by trial and error and it had to a lot with the fact that I knew the result a priori. I am able to resolve the problem and learn what is the correct way to implement the values and rules, but I would appreciate a lot a more thorough explanation if possible.

Notice that if you try

scalar[ρ, a, b, c] /. {ρ -> 0, a -> 0, b -> 0, c -> 1}


you will get indeterminate. When you are instead doing

scalar[ρ, 0, 0, 1] /. ρ -> 0


it replaces for ρ in scalar[ρ, 0, 0, 1], which is 1/(1 + ρ^2). Thus, you get 1.

• Thanks @MarcoB. – Himalaya Senapati May 11 '18 at 15:15