I think it might be helpful to evaluate the arguments on their own and see what happens.
The first argument
r^# & /@ Range[0, n]
outputs (for a specific choice of n
)
With[{n = 3}, r^# & /@ Range[0, n]]
(* {1, r, r^2, r^3} *)
which generates a list that you could also get by the following
Table[r^i, {i, 0, n}]
The FullForm
of the first argument would be something like
Map[Function[{x}, r^x], Range[0, n]]
note that f /@ list
is a shorthand for Map[f, list]
and, for the sake of a simple unrelated example, f /@ {1, 2, 3}
gives {f[1], f[2], f[3]}
.
Now back to the problem at hand: The syntax r^# &
generates a pure (anonymous) function; you can check that r^# & [exponent] == r^exponent
where on the left-hand side the function r^# &
is called with the argument exponent
.
Note that the ampersand &
simply tells Mathematica when the pure function definition is complete.
The second argument of Orthogonalize
is the inner product with respect to which the vectors should be orthogonalized. It is a (pure) function that takes two arguments. When you have more than one argument in a pure function, the slots are numbered and denoted as #1
, #2
, etc. A silly example
`Sqrt[#1 + #2] &[a, b] == Sqrt[a + b]`
Now the second argument is written as
`Integrate[g*#1*#2, {r, -∞, ∞}] &`
If you like you can define the function explicitly
myInnerProd[v1_, v2_] := Integrate[g*v1*v2, {r, -∞, ∞}]
and then define
f[n_] := Orthogonalize[Table[r^i, {i,0, n}], myInnerProd]
If you want to understand better the syntax of pure functions read the documentation entry tutorial/FunctionalOperations#17469
.
r^# & /@ Range[0, n]
=r^Range[0, n]
. In this case, you can replaceg*#1*#2
byg * ##
, but my guess is that it is not more familiar (to you). $\endgroup$