Problem when solving symbolically an equality between 2 matrices : issue when forcing symmetric matrices

1 vue (au cours des 30 derniers jours)
I try to solve an equality between 2 matrices 3x3. There are, among all the parameters, 10 unknowns to find.
1) Here is the script where you can see how I build the 2 matrices (one filling directly with 3x3 and the other initialy of size 5x5 marginalized to 3x3) :
clear;
clc;
format long;
% 2 Matrices symbolic : FISH_GCsp_SYM, FISH_XC_SYM - 2 cosmo params + 1 common bias
% Force symmetric
FISH_GCsp_SYM = sym('sp_', [3 3], 'real');
FISH_GCsp_SYM = tril(FISH_GCsp_SYM.') + triu(FISH_GCsp_SYM,1)
FISH_XC_SYM = sym('xc_', [3,3], 'real');
FISH_XC_SYM = tril(FISH_XC_SYM.') + triu(FISH_XC_SYM,1)
% 2 Matrices symbolic : FISH_GCsp_SYM, FISH_XC_SYM - 2 cosmo params + 2 bias + 1 new observable
% Force symmetric
FISH_GCsp_SYM2 = sym('sp2_', [5 5], 'real');
FISH_GCsp_SYM2 = tril(FISH_GCsp_SYM2.') + triu(FISH_GCsp_SYM2,1)
FISH_XC_SYM2 = sym('xc2_', [5 5], 'real');
FISH_XC_SYM2 = tril(FISH_XC_SYM2.') + triu(FISH_XC_SYM2,1)
FISH_GCsp_SYM2_SAVE = sym('sp2_', [5 5], 'real');
FISH_GCsp_SYM2_SAVE = tril(FISH_GCsp_SYM2_SAVE.') + triu(FISH_GCsp_SYM2_SAVE,1)
FISH_XC_SYM2_SAVE = sym('xc2_', [5 5], 'real');
FISH_XC_SYM2_SAVE = tril(FISH_XC_SYM2_SAVE.') + triu(FISH_XC_SYM2_SAVE,1)
% Link between 2 colomns of bias into 5x5 and sum of bias into 3x3 common bias
FISH_GCsp_SYM(3,1:2) = FISH_XC_SYM2(3:4,1) + FISH_XC_SYM2(3:4,2)
FISH_GCsp_SYM(1:2,3) = FISH_XC_SYM2(1,3:4) + FISH_XC_SYM2(2,3:4)
FISH_GCsp_SYM(3,3) = FISH_XC_SYM2(3,3) + FISH_XC_SYM2(4,4)
% Sum for Fisher matrices;
FISH_GCsp_XC_SYM(1:2,1:2) = FISH_GCsp_SYM(1:2,1:2) + FISH_XC_SYM(1:2,1:2);
FISH_GCsp_XC_SYM(3,1:2) = FISH_XC_SYM2(3:4,1) + FISH_XC_SYM2(3:4,2);
FISH_GCsp_XC_SYM(1:2,3) = FISH_XC_SYM2(1,3:4) + FISH_XC_SYM2(2,3:4);
FISH_GCsp_XC_SYM(3,3) = FISH_XC_SYM2(3,3) + FISH_XC_SYM2(4,4);
FISH_GCsp_XC_SYM
% Marginalise on 1 common bias
COV_GCsp_XC_SYM_common = inv(FISH_GCsp_XC_SYM);
COV_GCsp_XC_SYM_common([3],:) = [];
COV_GCsp_XC_SYM_common(:,[3]) = [];
FISH_GCsp_XC_SYM = inv(COV_GCsp_XC_SYM_common)
% Classical equivalent of big fisher matrix + 1 row/column of new observable
% Marginalise on 3 last rows/columns
COV_GCsp_SYM2 = inv(FISH_GCsp_SYM2);
COV_XC_SYM2 = inv(FISH_XC_SYM2);
COV_GCsp_SYM2([3 4 5],:) = [];
COV_GCsp_SYM2(:,[3 4 5]) = [];
COV_XC_SYM2([3 4 5],:) = [];
COV_XC_SYM2(:,[3 4 5]) = [];
FISH_GCsp_SYM2 = inv(COV_GCsp_SYM2);
FISH_XC_SYM2 = inv(COV_XC_SYM2);
% Summing the cosmo parameters
FISH_GCsp_XC_SYM2 = FISH_GCsp_SYM2 + FISH_XC_SYM2
% Matricial equation to solve
eqn = FISH_GCsp_XC_SYM == FISH_GCsp_XC_SYM2;
% Solving : matrix1 equal to matrix2
sol = solve(eqn, [FISH_GCsp_SYM2_SAVE(:,5) FISH_XC_SYM2_SAVE(:,5)])
I don't understand what solve fails to find a solution. I have the following error message :
Warning: Unable to solve symbolically. Returning a numeric solution using <a href="matlab:web(fullfile(docroot,
'symbolic/vpasolve.html'))">vpasolve</a>.
> In solve (line 304)
In building_observable_to_find_FOR_STACK (line 61)
sol =
struct with fields:
sp2_1_5: [1x1 sym]
sp2_2_5: [1x1 sym]
sp2_3_5: [1x1 sym]
sp2_4_5: [1x1 sym]
sp2_5_5: [1x1 sym]
xc2_1_5: [1x1 sym]
xc2_2_5: [1x1 sym]
xc2_3_5: [1x1 sym]
xc2_4_5: [1x1 sym]
xc2_5_5: [1x1 sym]
>>
Even with replacing `solve` by `vpasolve`, this doesn't find non-zeros numerical values.
But I want firstly to find symbolic form of the 10 following unknowns :
sp2_1_5, sp2_2_5, sp2_3_5, sp2_4_5, sp2_5_5, xc2_1_5, xc2_2_5, xc2_3_5, xc2_4_5, xc2_5_5
2) Could anyone try to execute the script to do what's wrong ?
What's the stranger is that if I don't force symmetry with this trick above, I get non-empty symbolic solutions for the 10 unknowns :
Warning: Solutions are valid under the following conditions: xc2_3_3 + xc2_4_4 ~= 0 & sp2_3_3*sp2_5_4 ~= sp2_3_4*sp2_5_3 &
xc2_4_3*xc2_5_4 ~= xc2_4_4*xc2_5_3. To include parameters and conditions in the solution, specify the 'ReturnConditions'
value as 'true'.
> In solve>warnIfParams (line 482)
In solve (line 357)
In building_observable_to_find_FOR_STACK_NOT_FORCE_SYMMETRIC (line 65)
sol =
struct with fields:
sp2_1_5: [1x1 sym]
sp2_2_5: [1x1 sym]
sp2_3_5: [1x1 sym]
sp2_4_5: [1x1 sym]
sp2_5_5: [1x1 sym]
xc2_1_5: [1x1 sym]
xc2_2_5: [1x1 sym]
xc2_3_5: [1x1 sym]
xc2_4_5: [1x1 sym]
xc2_5_5: [1x1 sym]
3) I don't understand, the fact that I work with symmetric should simplify the solving but if I use this symmetric characteristic for FISH_GCsp and FISH_XC matrices, Matlab can't find solutions whereas if I don't force it, there are solutions (not sure yet they are correct).
RECALL : Given the fact the 2 matrices are Fisher matrices, they have to be symmetric. I did that by the trick for example on `FISG_GCsp_SYM` matrix :
FISH_GCsp_SYM = sym('sp_', [3 3], 'real');
FISH_GCsp_SYM = tril(FISH_GCsp_SYM.') + triu(FISH_GCsp_SYM,1)

Réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by