1
$\begingroup$

Manifold $W$ is divided into 9 points. The value of the parameter $P$ at each point in manifold is represented by a certain number, and the partition itself is represented as a matrix:

P = {{1, 2, 3}, {-1, 0, 1}, {-3, -2, -1}}

There is also a matrix $J$ that depends on the value from the matrix $P$ at the selected point and on the variables $x,y$

J = {{x^2, 1, P[[i, j]]}, {0, x, -1}, {1, 2, y^4}}

I need help solving an optimization problem:

1 Take each point from matrix $P$.

2 Substitute it into the matrix $J$ and use the matrix norm $||J||$ formula at the given point.

3 After that, I need to sum the squares of all the norms obtained at each point and divide by the number of partitions, i.e. use the formula:

$G=\frac{1}{n} q^Tq $,

where $q=\begin{bmatrix} ||J(x,y,P(1,1))|| & ||J(x,y,P(1,2))|| & ||J(x,y,P(1,3))|| & \cdots & ||J(x,y,P(3,3))|| \end{bmatrix}$

4 Find a combination of parameters $x,y$ that minimizes $G$, i.e.:

$\min_{x,y}G$

On the one hand, here is a ready-made algorithm. On the other hand, I have heard a lot about the possibilities of Mathematica in the field of optimization (and solving least-squares problems). Teach me how to use these possibilities.

I will be happy and grateful!

$\endgroup$
2
  • 1
    $\begingroup$ Since you already know that you have a sum-of-squares to optimize, you should be using the "LevenbergMarquardt" method in FindMinimum[]. $\endgroup$ Commented Jul 26, 2022 at 17:22
  • $\begingroup$ @J.M. I need block, that contains code for step 1-3 in algorithm $\endgroup$
    – ayr
    Commented Jul 26, 2022 at 17:39

1 Answer 1

4
$\begingroup$

If I understand you description correctly, then there is no need to consider P as a matrix, a vector will do. (note I am using lower case names):

P = {1, 2, 3, -1, 0, 1, -3, -2, -1};
J = {{x^2, 1, #}, {0, x, -1}, {1, 2, y^4}} & /@ P

enter image description here

Unfortunately you did not specify which matrix norm you use. I will use the Frobenius norm,: sqrt of the sum of the squares of the matrix elements. For this we need the squares of the elements:

j^2

enter image description here

Our target function we want to minimize is then:

target = Total[Total[Flatten[#]^2] & /@ J]
(* 93 + 9 x^2 + 9 x^4 + 9 y^8 *)

It is now obvious, as only even powers of x and y appear, that the minimum is achieved for:

{x->0,y->0}
$\endgroup$
2
  • $\begingroup$ Thanks for the answer! I'll make a couple of points that I think are important: 1.$P$ - tabular data. It can be introduced into Mathematica, and vectorized. P = {{1, 2, 3}, {-1, 0, 1}, {-3, -2, -1}}; pP = Transpose[{Flatten[Transpose[P]]}] 2.Line J = {{x^2, 1, #}, {0, x, -1}, {1, 2, y^4}} & /@ P nice, but why does it form a set of vectors and not matrices? 3.We can use Frobenius, but I would like to get a matrix $nJ$, with the elements, that is norm of the $J$ is taken with the corresponding number at this point from $P$. 4.Then also vectorize $nJ$, get $G$ and than minimize. $\endgroup$
    – ayr
    Commented Jul 27, 2022 at 4:36
  • $\begingroup$ We can work with $P$ in step 2 and use the norm at the same time. Then we get a vector of norms $nJ$, for example. And then either form $G$, or do Reshape. $\endgroup$
    – ayr
    Commented Jul 28, 2022 at 4:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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