I got Mathematica code from my friend:
n = 100
l = 0
gw = GaussianQuadratureWeights[n, 0, 2]
(*the result of gw maybe like this {{0.000286273, 0.000734634}, {0.00150805, 0.00170939}, {0.00370487, 0.00268393},...}}*)
J = Array[SphericalBesselJ[l, gw[[#, 1]]] &, n]
The first, I'm not sure with syntax because i'm not a Mathematica user.
But in my understand this code just try to create Spherical Bessel array by using 2 parameters such as
l just a constant. its value is 1
qw this is two dimensional array
On Mathematica code up there for gw[[#, 1]]
i think they just tried to call {{0.000286273, 0.00150805, 0.00370487, ...}} and put them one by one to second parameters of SphericalBesselJ . And finally, we will get a one dimensional J
array
If write it as pseudo code from my understanding it might be like this:
l = 1
n = 100
gw = gaussiannode(100) //generate 100 gaussian nodes
for (i==1, i<=n, i++):
J[i] = SphericalBesselJ(l, gw[1][i])
My question is "Is it the Mathematica code up there equivalent to my pseudo code?"
My point is just want to know Array
can work as Loop
or not? if not please correct Mathematica code up there to the right way by using loop.
J=SphericalBesselJ[l, gw[[;; NN, 1]]]
... Also, try not to use uppercase letters/initials for symbols, you might clash with built-ins. – rasher Jun 25 at 10:08Array
asLoop
. – terces907 Jun 25 at 10:14