I am new to Mathematica and trying to create a list that I can use within the InterpolatingPolynomial
function. e.g. {{-1, 0},{ 0, 0},{1, 1}}
.
I extended the "linearMesh" function from here: https://mathematica.stackexchange.com/a/32721 to insert n
array elements
linearmesh[a_, b_, n_Integer] := Array[# &, n, {a, b}]
became:
linearmesh[a_, b_, n_Integer] :=
Array[# &,
n, {{a, KroneckerDelta[i, j]}, {b, KroneckerDelta[i, j]}}];
My aim is to produce, e.g. for a==-1
and b==1
and 3
elements:
{{-1, KroneckerDelta[i, j]}, {0, KroneckerDelta[i, j]}, {1,
KroneckerDelta[i, j]}}
where each of the KroneckerDelta
s is calculated with respect to a variable i
, and j
is the index of the array element. How can I get the index, since the array is being defined at the same time?
What I tried:
linearmesh[a_, b_, n_Integer] :=
Array[# &,
n, {{a, KroneckerDelta[i, #1]}, {b, KroneckerDelta[i, #1]}}];
and then linearmesh[-1,1,3]
gives me results:
{{-1, KroneckerDelta[i, #1]}, {0, KroneckerDelta[i, #1]}, {1, KroneckerDelta[i, #1]}}
rather than substituting the values of each of the # indices and obtaining
{{-1, KroneckerDelta[i, 1]}, {0, KroneckerDelta[i, 2]}, {1, KroneckerDelta[i, 3]}}
I also considered using Part
s, but I can't do that since the array doesn't exist yet while linearmesh
is being defined.
Thanks!