Matrix numeric inversion, very bad conditioned

15 views (last 30 days)
Martin
Martin on 10 Oct 2023
Commented: Martin on 11 Oct 2023
I have a matrix
A= [-1.14420182157714e-05 3.97106112979063e-09 1.71528761347565e-09 3304.87922280846 -6.43946234919730;
3.97106112979063e-09 -7.42484390057452e-13 -5.95484638418163e-13 -0.618994914206821 5.75841022133480e-05;
1.71528761347565e-09 -5.95484638418163e-13 -2.57140914558130e-13 -0.495586332063353 0.000965957682109416;
3304.87922280846 -0.618994914206821 -0.495586332063353 -516040787150.579 51574737.9623166;
-6.43946234919730 5.75841022133480e-05 0.000965957682109416 51574737.9623166 3814318.88267676];
and i want to calculate the inverse matrix. This matrix is very bad contitioned.
Normal inv oder pinv function doesnt give a stable solution. Which functions can use?
Thank you!

Answers (2)

Bhanu Prakash
Bhanu Prakash on 10 Oct 2023
Hi Martin,
I understand that you want to calculate the inverse of the matrix ‘A’.
For a square matrix to be invertible, it should be a full row rank that means the rank of the matrix is equal to the size of the matrix.
But the rank of the given matrix ‘A’ is 2, which is not equal to its size (8).
>> rank(A)
ans =
2
To get the inverse of the matrix, which corresponds to a manual calculation, you can use the ‘vpa’ function from the Symbolic Math Toolbox.
For more information on the above-mentioned functions, kindly refer to the following documentation:
For ‘vpa’ function:
For ‘rank’ function:
  3 Comments
Torsten
Torsten on 10 Oct 2023
I guess that your model parameters depend on each other.
In the simplest case, imagine you want to determine two parameters a and b to fit a function of the form
y = (a+b)*x
Now this is a model with two parameters, but you can fit only one, namely (a+b).
So the model can be reduced to
y = c*x
with only one parameter c to be determined.
If you compute the Jacobian of the "overdetermined" model in a and b, you will see that it is singular.

Sign in to comment.


Walter Roberson
Walter Roberson on 10 Oct 2023
Your array is sensitive enough that it matters that your text entries do not represent the full double precision values stored in the variables. When you use format long g to display a variable, it displays 15 significant digits, not the 16 (sometimes 17!) needed to fully resolve a decimal number to binary. For example the decimal value -0.495586332063353 (row 4 column 3) is displayed the same for -0.495586332063353 .* (1+(-4:4)*eps)
format long g
A= [-1.14420182157714e-05 3.97106112979063e-09 1.71528761347565e-09 3304.87922280846 -6.43946234919730;
3.97106112979063e-09 -7.42484390057452e-13 -5.95484638418163e-13 -0.618994914206821 5.75841022133480e-05;
1.71528761347565e-09 -5.95484638418163e-13 -2.57140914558130e-13 -0.495586332063353 0.000965957682109416;
3304.87922280846 -0.618994914206821 -0.495586332063353 -516040787150.579 51574737.9623166;
-6.43946234919730 5.75841022133480e-05 0.000965957682109416 51574737.9623166 3814318.88267676];
Ainv = inv(sym(A))
Ainv = 
Ainvd = double(Ainv)
Ainvd = 5×5
1.0e+00 * 1.33590335999762e+17 3.77238579649947e+19 8.9047199885406e+20 -44867666.7136091 61194294.0940845 3.77238579649947e+19 1.10246067006822e+22 2.51456285559039e+23 -13116744146.7408 17534675738.3868 8.9047199885406e+20 2.51456285559039e+23 5.93561184534913e+24 -299074847846.53 407902985402.706 -44867666.7136091 -13116744146.7408 -299074847846.53 0.0156059553946884 -0.0208584605760802 61194294.0940845 17534675738.3868 407902985402.706 -0.0208584605760802 0.0281524909870653
Ainv * A
ans = 
Ainvd * A
ans = 5×5
1.0e+00 * 1.00015413761139 2.33499122259673e-08 1.96378096006811e-08 -24301.5 37.96875 0.001556396484375 0.999996757716872 -1.00880861282349e-05 -4008704 -4328 0.34765625 3.042072057724e-05 1.00002479553223 82333696 134912 3.19189119579733e-15 6.62252709810775e-18 7.77237432400546e-18 1.00001826742664 -2.25118128582835e-08 4.73787675758786e-14 -4.00288712631069e-17 -1.96477762445108e-17 -1.6792444512248e-05 1.00000004631875

Categories

Find more on Particle & Nuclear Physics in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!