I am trying to create matrix, where every element is generated from For Loop. Just for simplicity,let's consider the following mathematical problem: Find maximum value of the function $x^2+y^2$ over the domains: $[0,.01],[0,.02],..,[0,1]$. In other words it is needed to create the following matrix: \begin{bmatrix}max:x^2+y^2 over [0,0.01] & max:x^2+y^2 over [0,0.02] & .. & max:x^2+y^2 over [0,0.1] \\max:x^2+y^2 over [0,0.11] & max:x^2+y^2 over [0,0.12] & .. & max:x^2+y^2 over [0,0.2]\\ max:x^2+y^2 over [0,0.91] & max:x^2+y^2 over [0,0.92] & .. & max:x^2+y^2 over [0,1]\end{bmatrix} So to automatically generate the matrix consisting from the extreme values of the function over different domains I use the following code:
m=Table[1^i*1^j*For[k=.01,k<=1,k+=.01, For[z=.01,z<=1,z+=.01, Print[Maximize[{x^2+y^2,0<=x<=k,0<=y<=z,{x,y}],{i,10},{j,10}]]] It turns out that it doesn't work! How can I fix this problem. $$P.S.$$ Mathematically this problem is straightforward, I am interested to model this problem in Wolfram Mathematica.
iorj, so even if you fix the other mistakes, your matrix elements will all be the same. I suggest you first attempt a functionf[i_,j_]:=...that computes a single matrix element. Don'tPrint, that puts it on your screen and discards it. Then tabulatefto make your matrix. $\endgroup$