Search code examples
octavematrix-multiplicationsymbolic-math

How to deduce left-hand side matrix from vector?


Suppose I have the following script, which constructs a symbolic array, A_known, and a symbolic vector x, and performs a matrix multiplication.

clc; clearvars
try
    pkg load symbolic
catch
    error('Symbolic package not available!');
end

syms V_l k s0 s_mean
N = 3;

% Generate left-hand-side square matrix
A_known = sym(zeros(N));
for hI = 1:N
    A_known(hI, 1:hI) = exp(-(hI:-1:1)*k);
end
A_known = A_known./V_l;

% Generate x vector
x = sym('x', [N 1]);
x(1) = x(1) + s0*V_l;
% Matrix multiplication to give b vector
b = A_known*x

Suppose A_known was actually unknown. Is there a way to deduce it from b and x? If so, how?

Til now, I only had the case where x was unknown, which normally can be solved via x = b \ A.


Solution

  • Mathematically, it is possible to get a solution, but it actually has infinite solutions.

    Example

    A = magic(5);
    x = (1:5)';
    b = A*x;
    A_sol = b*pinv(x);
    

    which has

    >> A
    A =
    
       17   24    1    8   15
       23    5    7   14   16
        4    6   13   20   22
       10   12   19   21    3
       11   18   25    2    9
    

    but solves A as A_sol like

    >> A_sol
    A_sol =
    
        3.1818    6.3636    9.5455   12.7273   15.9091
        3.4545    6.9091   10.3636   13.8182   17.2727
        4.4545    8.9091   13.3636   17.8182   22.2727
        3.4545    6.9091   10.3636   13.8182   17.2727
        3.1818    6.3636    9.5455   12.7273   15.9091