TransWikia.com

Show numeric unstability of Cramer's rule

Mathematics Asked on December 15, 2021

I need to find a matrix $A$, which holds $dim(A)=2$ and a vector $b$ for each holds:
There is a solution for the equation $Ax=b$, but the use of Cramer’s rule with 3 digits after the dot accuracy gives an inaccurate solution, which is very far from the solution x.

I need to show also the calculation, manually either by some python or matlab code.

Tried to engineer something, but couldn’t do it.

One Answer

This numerical instability is almost certainly caused by the calculation of $|A|$, which requires taking the difference of the products of the diagonals. If those quantities are close in magnitude (because one of $A$'s eigenvalues is a lot larger than the other), this will result in catastrophic precision loss. For example, if one diagonal's product is $101.5$ and the other's is $101.3$, you seem to have 4 digits of precision. However, their difference is $0.2$, which has only 1 digit of precision, and to make it worse Cramer's rule then has you divide by this highly imprecise small number, putting massive error bars on the result.

Generally you're better off implementing Gauss-Jordan elimination with pivoting. For the $2times2$ case, pivoting just means making sure the upper left element is larger than the lower left element before starting the elimination by swapping rows if necessary.

Answered by eyeballfrog on December 15, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP