Please look at following picture. Why when I call f[0,0], values of variables x and y were not replaced by 0 and 0??? Still x, y in there
Try
f = Function[{x, y}, Evaluate[fpp]];
Hi,
please try to provide the code rather than an image of it next time. You might want to try this code:
nmax = 10;
mmax = 10;
k = 0;
pts = List[];
pt = List[];
For[i = 1, j <= nmax, i++,
For[j = 1, j <= mmax, j++,
AppendTo[pt, i - nmax/2];
AppendTo[pt, j - nmax/2];
AppendTo[pt, N[i^2 + j^2 - 5*i*j]];
k = k + 1;
AppendTo[pts, pt];
pt = List[];
]
];
f1 := Sum[Subscript[a, i]*x^i, {i, nmax}];
f2 := Sum[Subscript[b, i]*y^i, {i, nmax}];
fpp = Expand[f1*f2];
fout[x_, y_] := Evaluate[fpp]
If you then evaluate
fout[0,0]
that results in 0.
M.
Sorry for the double posting. I was seconds late…
M.
Once created I cannot make this box go away
In[1]:= Clear[a, b];
nmax = 10;
mmax = 15;
pts = Flatten[Table[{i - mmax/2, j - mmax/2, N[i^2 + j^2 - 5*i*j]}, {i, mmax}, {j, mmax}], 1];
f1 = Sum[a[i]*x^i, {i, nmax}];
f2 = Sum[b[i]*y^i, {i, nmax}];
fpp = Expand[f1*f2];
f = Function[{x, y}, Evaluate[fpp]];
EE = Expand[Sum[Sqrt[1/mmax^2*(f[pts[[i,1]], pts[[i,2]]] - pts[[i,3]])^2], {i, mmax*mmax}]];
v = Join[Table[a[i], {i, nmax}], Table[b[i], {i, nmax}]];
w = v /. NMinimize[EE, v][[2]];
MapThread[Set, {v, w}];
In[13]:= a[1]
Out[13]= -0.024081
In[14]:= b[10]
Out[14]= 0.042064
Ok, thanks. I got it!

