# An error disappears?

I needed to define a table of functions. And I did it like this:

density =
Table[((# - 0.6*chordlength[[j]]/100)^2 + 0.1) &, {j, 1,
Length[force[[All, 1]]], 1}];
Table[Plot[density[[j]][x], {x, 0, chordlength[[j]]/10^2}], {j, 1,
Length[force[[All, 1]]], 1}]


The Plot[] works really fine and all the functions look just as they should. And of you might need this

chordlength={295.21, 295.21, 294.755, 293.27, 291.085, 288.395, 284.575, 279.89, 275.225, 269.995, 263.84, 256.695, 247.85, 238.06, 228.83, 219.175, 208.08, 196.945, 184.89, 170.95, 155.815, 138.73, 118.755, 97.805, 78.055}


With that done I have to normalize those function like this

 norm = Table[
NSolve[a*NIntegrate[density[[j]][x], {x, 0, chordlength[[j]]}] ==
force[[j, 2]], a][[1, 1, 2]], {j, 1, Length[force[[All, 1]]],
1}];


where

force[[All,2]]={67.25, 44.15, 35.65, 53.27, 34.73, 39.4, 60.45, 37.45, 33.2, 48.45, 30.99, 32.92, 53.44, 33.4, 28.34, 40.55, 25.86, 23.91, 33.7, 22.25, 14.61, 23.45, 15.27, 4.73, 4.73}


Now the problem. All those inputs are returned without any errors. But if one tries to get the value of (for example) density[[1]][0.5] I get an error saying: The expression j cannot be used as a part specification.

And now I am confused. The normalization with the same expression density[[j]][x] for arbitrary j and x returns no error, bit finding the exact value of j-th function at given x returns error.

Two questions. Is the normalization even correctly calculated or is it wrong? And how can I than get a numerical value of density[[1]][0.5]?

• Please post some test data and make sure your functions run. Currently they do not. Aug 4 '15 at 9:24
• I edited the OP. Aug 4 '15 at 9:31
• The problem is that in this expression Table[((# - 0.6*chordlength[[j]]/100)^2 + 0.1) &, {j, 1, Length[force[[All, 1]]], 1}] the j in your function is not evaluated; its not 1,2,3 etc its j. Aug 4 '15 at 9:36
• @Ymareth Ok, but why does the Plot[] work than? Aug 4 '15 at 9:38
• I would guess that by chance the local value of j there is a number as you're inside another Table. However when you're not and you evaluate density[[1]] you get a function returned (#1-0.6*chordlength[[j]]/100)^2&. Aug 4 '15 at 9:41

The local i does not evaluate in the first table of functions; e.g.

Table[# f[i] &, {i, 1, 10}]


gives...

{#1 f[i] &, #1 f[i] &, #1 f[i] &, #1 f[i] &, #1 f[i] &, #1 f[i] &, #1 f[i] &, #1 f[i] &, #1 f[i] &, #1 f[i] &}


Use With to force the evaluation of i...

Table[With[{i = i}, # f[i] &], {i, 1, 10}]


to give...

{#1 f[1] &, #1 f[2] &, #1 f[3] &, #1 f[4] &, #1 f[5] &, #1 f[6] &, #1 f[7] &, #1 f[8] &, #1 f[9] &, #1 f[10] &}

• Here I'm calling some function f but its the same if you're indexing some list f[[i]]. Aug 4 '15 at 9:46