Processing math: 14%

First time here? Check out the FAQ!

Ask Your Question
0

Optimizing a function of a given matrix

asked 6 years ago

Deepak Sarma gravatar image

Let us consider the 4×4 symmetric matrix Ax=(0111 102x2x 12x02x 12x2x0)

Here I need to find min where by ||M|| we mean the sum of all entries of the matrix M. I'm looking for a general sage program where my input will be a matrix with entries as functions of an inderminant (like the matrix A_x above) which will give me the unique x corresponding to my matrix. If no such real value exists, it should result as \infty Can anyone help me? Thank you in advance.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 6 years ago

slelievre gravatar image

updated 6 years ago

One could use Sage to explore the problem.

Define the matrix A:

sage: A = matrix(SR, 4, [0, 1, 1, 1, 1, 0, 2^x, 2^x, 1, 2^x, 0, 2^x, 1, 2^x, 2^x, 0])
sage: A
[  0   1   1   1]
[  1   0 2^x 2^x]
[  1 2^x   0 2^x]
[  1 2^x 2^x   0]

Compute its determinant:

sage: det(A)
-3*2^(2*x)

The sum of its entries:

sage: sum(A.list())
6*2^x + 6

Its inverse:

sage: ~A
[-2/3*2^x      1/3      1/3      1/3]
[     1/3 -2/3/2^x  1/3/2^x  1/3/2^x]
[     1/3  1/3/2^x -2/3/2^x  1/3/2^x]
[     1/3  1/3/2^x  1/3/2^x -2/3/2^x]

The sum of the entries of its inverse:

sage: sum((~A).list())
-2/3*2^x + 2

Now solve \det(A) = 0 and \lVert A^{-1} \rVert = 0, extract positive solutions, take the minimum, and compute a numerical approximation.

sage: S = solve(det(A) == 0, x); S
[]
sage: T = solve(sum((~A).list()) == 0, x); T
[x == (log(6) - log(2))/log(2)]
sage: min([e.rhs() for e in S + T if e.rhs() > 0]).n()
1.58496250072116

This can all be put in a function which, given a matrix A as above, returns this minimum positive solution.

Preview: (hide)
link

Comments

Actually, I was stuck at this step. I tried the code "solve" to solve the two systems, but I don't get numerical value from this. Again I tried "find_root" code with the interval but one of the systems (First one) does not have a solution, and so it gives a long list of errors. Therefore I cannot evaluate the minimum of all solutions (min() doesn't work). For this particular matrix, I can find it by direct calculation. But what I need a general method to get my required (numerical value) whenever I input a matrix as a function of x. I need something like this

X=det(A); Y=sum((~A).list()); S=solve([X,x>0],x); T=solve([Y,x>0],x); min(S+T)

This doesn't give me numerical value. Note the last step, I want sage to calculate the minimum value of the ...(more)

Deepak Sarma gravatar imageDeepak Sarma ( 6 years ago )

Edited question to add last step.

slelievre gravatar imageslelievre ( 6 years ago )

Thank you for your solution. It works with that particular matrix. But it doesn't work for all matrices.

For example consider A=\left(\begin{array}{rrrrr} 0 & 2^{x} & 1 & 1 & 1 \ 2^{x} & 0 & 1 & 1 & 1 \ 1 & 1 & 0 & 2^{x} & 2^{x} \ 1 & 1 & 2^{x} & 0 & 2^{x} \ 1 & 1 & 2^{x} & 2^{x} & 0 \end{array}\right)

or

A=\left(\begin{array}{rrrr} 0 & 1 & 2^{x} & 1 \ 1 & 0 & 1 & 2^{x} \ 2^{x} & 1 & 0 & 1 \ 1 & 2^{x} & 1 & 0 \end{array}\right)

Here I get an error "cannot evaluate symbolic expression numerically"

Note: For all my matrices, it is known that the solution is at most equal to 2. So if something like min(find_root(X,0,2)+find_root(Y,0,2)) could be used, that is also enough for me.

Deepak Sarma gravatar imageDeepak Sarma ( 6 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 6 years ago

Seen: 450 times

Last updated: Jul 25 '18