2
$\begingroup$

How do I use maximise with an arbitrary sized symbolic matrix?

e.g for a small matrix it is fine to write it out,

ymatrix = {{y11, y12, y13}, {y21, y22, y23}, {y31, y32, y33}}

NMaximize[-2*(Total[Total[ymatrix]])^2 - 3 Total[Total[ymatrix]] + 5, {y11, y12, y13, y21, y22, y23, y31, y32, y33}]

But how would I do this if ymatrix bigger, for example is of dimensions {100,3}

$\endgroup$
3
$\begingroup$
ymat = Array[y, {10, 3}];
NMaximize[-2*(Total[Total[ymat]])^2 - 3 Total[Total[ymat]] + 5, Flatten @ ymat]

{6.125, {y[1, 1] -> -0.0607683, y[1, 2] -> 0.0892679, y[1, 3] -> -0.0936603, y[2, 1] -> -0.150047, y[2, 2] -> -0.0840205, y[2, 3] -> 0.0476687, y[3, 1] -> -0.21559, y[3, 2] -> 0.200936, y[3, 3] -> -0.000880204, y[4, 1] -> -0.0163985, y[4, 2] -> 0.026977, y[4, 3] -> -0.151111, y[5, 1] -> 0.0385733, y[5, 2] -> 0.139781, y[5, 3] -> 0.105765, y[6, 1] -> -0.0226961, y[6, 2] -> 0.0591995, y[6, 3] -> -0.0220974, y[7, 1] -> -0.00234965, y[7, 2] -> 0.0675695, y[7, 3] -> 0.0510284, y[8, 1] -> -0.301971, y[8, 2] -> -0.0280714, y[8, 3] -> 0.0161941, y[9, 1] -> -0.254097, y[9, 2] -> -0.13867, y[9, 3] -> -0.147411, y[10, 1] -> 0.0898733, y[10, 2] -> 0.0788414, y[10, 3] -> -0.0718359}}

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.