I want to solve the following non-linear system of equations.
Notes
- the
dot
betweena_k
andx
representsdot product
. - the
0
in the first equation represents0 vector
and0
in the second equation isscaler 0
- all the matrices are sparse if that matters.
Known
K
is ann x n
(positive definite) matrix- each
A_k
is a known (symmetric) matrix - each
a_k
is a known n x 1 vector N
is known (let's say N = 50). But I need a method where I can easily change N.
Unknown (trying to solve for)
x
is ann x 1
a vector.- each
alpha_k
for1 <= k <= N
a scaler
My thinking.
I am thinking of using scipy root to find x and each alpha_k. We essentially have n
equations from each row of the first equation and another N
equations from the constraint equations to solve for our n + N
variables. Therefore we have the required number of equations to have a solution.
I also have a reliable initial guess for x
and the alpha_k's
.
Toy example.
n = 4
N = 2
K = np.matrix([[0.5, 0, 0, 0], [0, 1, 0, 0],[0,0,1,0], [0,0,0,0.5]])
A_1 = np.matrix([[0.98,0,0.46,0.80],[0,0,0.56,0],[0.93,0.82,0,0.27],[0,0,0,0.23]])
A_2 = np.matrix([[0.23, 0,0,0],[0.03,0.01,0,0],[0,0.32,0,0],[0.62,0,0,0.45]])
a_1 = np.matrix(scipy.rand(4,1))
a_2 = np.matrix(scipy.rand(4,1))
We are trying to solve for
x = [x1, x2, x3, x4] and alpha_1, alpha_2
Questions:
- I can actually brute force this toy problem and feed it to the solver. But how do I do I solve this toy problem in such a way that I can extend it easily to the case when I have let's say
n=50
andN=50
- I will probably have to explicitly compute the Jacobian for larger matrices??.
Can anyone give me any pointers?