Solve matrix equation with eigen - math

I want to solve the equation A*B=C for A, with Eigen. A is a (3x3) matrix, B and C are (3x25) matrices.
Currently I would compute the pseudoinverse of B and multiply it from right to C. Is there a better way?

If found an easy solution myself: just transpose the whole equation (B^T*A^T=C^T) and solve it with an ordinary linear solver!
edit: it actually does not perfectly do the job, see this link

Related

How can I write this line of code in MATLAB (currently R)?

How can I write this line of code in MATLAB (currently R)?
vcov_beta_hat <- c(sigma2_hat) * solve(t(X) %*% X)
My attempt is,
vcov_beta_hat = [sigma2_hat.*((X'*X))];
However I am struggling on what the 'c' is doing in the r code?
Whilst the above answer addresses that the solve is the something missing in your matlab code, solve can mean a number of different things in R,
If there is no comma in the equation its not solving anything and is actually taking the inverse,
Inverse of A, MATLAB: inv(A) R: solve(A)
Therefore, vcov_beta_hat = [sigma2_hat.*inv((X'*X))];
The c(a,b,c) denote a vector in R. In Matlab, you would write
vec = [a b c];
Also, you need to find the equivalent of the R-solve() function. So far, your matlab code just mutliplies X' with X and does not solve the system of equations.
linsolve should be a good starting point.

Solve Underdetermined System of Equations for Sparse Solution

A, C are m x n rectangular matrix.
B is a n x n square matrix.
B is not symmetric.
B, C are known
AB = C.
B is singular.
I could use the moore-penrose inverse of B to get A = CB+.
But that seems to make A have many non-zero elements.
If I want an A (among all possible solutions) that is quite sparse, what solvers can I try?
Should I use BDCSVD, as in here?
Thanks.
Under-determined systems usually have infinite number of solutions. Unless you impose some additional conditions (restrictions), in form of additional equation(s), you won't obtain a single numerical solution.

How do I find the matrix of the linear transformation?

Going through the text on Linear Algebra by A. O. Morris (2nd edition) I am trying to understand something on linear transformations.
There is a problem where the R-bases of U and V are given as
{u1, u2} and {v1,v2,v3} respectively and the linear transformation from U to V is given by
Tu1=v1+2v2-v3
Tu2=v1-v2
The problem is to
a) find the matrix of T relative to these bases,
b) the matrix relative to the R-bases
{-u1+u2,2u1-u2} and {v1,v1+v2,v1+v2+v3},
and c) the relationship between the two matrices.
From the very good treatment of the subject here https://math.stackexchange.com/questions/12383/determine-the-matrix-relative-to-a-given-basis I figured out that the first matrix T has columns
(1,2,-1),(1,-1,0).
then for part b) I figure out Matrix A which I take to be the transform of ordered basis of U to standard basis of U as
((-1,2),(2,1)}
Matrix B which I take to be the transform of ordered basis of V to standard basis of V as
{(1,1,1),(0,1,1),(0,0,1)}
I then find inverse of B and form the product
[B]inv.C.A as the answer to part c).
Somehow I do not seem to get it. I am completely at sea. I would appreciate help to understand this.
My sincere apologies for not being able to use Latex.

Quadratic Objective with Quadratic Constraints in R: Rsolnp?

I am trying to minimize a quadratic objective with quadratic constraints, is Rolnp the way to go? I have been reading the documentation and it seems like all the examples use equations instead of vector manipulation. All of my parameters are vectors and matrices and they can be quite large. Here is my problem:
X<-([Cf]+[H])%*%[A]
Y<-([Cf]+[H]-[R])%*%[B]
I want to find H that minimizes Y%*%Dmat%*%t(Y) for a given value of X%*%Dmat%*%t(X)
Cf, R, A, Dmat and B are matrices of constants.
The values for H sohould be between 0 and 1.
Is it possible to use Rsolnp to find the vector H even though the input functions will all return other vectors?
I ended up using AUGLAG and COBYLA to solve this problem.

Solving an equation using Matlab

S=solve(strcat('a*gamma(1+(1/b))=',int2str(m)),strcat('a*a*gamma(1+(2/b))=',int2str(c)));
Values of variables m and c are known. How can one solve for a and b?
I guess a and b are arbitrary constants. You can assign it as syms. If you really need to solve for a and b, use two equations two unknowns or the solve() function in matlab.
Try the optimization toolkit if you have it:
f = #(a,b) (a(1)*gamma(1+(1/a(2))) - b(1))^2 + (a(1)^2*gamma(1+(2/a(2)))-b(2))^2;
X = fminsearch(#(a) f(a,b),[1;1])

Resources