Math, asked by dpadmaja4123, 1 year ago

Matlab script for solving linear algebra equations

Answers

Answered by abhikumar12
1

How can I write a script to solve the system of a linear equation using Cramer's rule?

As another mentioned, it is more efficient to solve most systems of linear equations using something like Gauss-Jordan elimination, and using Cramer’s rule is more of a learning exercise.

A comment from another numerical computing researcher:

In Numerical Methods That Work (Usually), in the section What not to compute, F. S. Acton remarks "...perhaps we should be glad he didn't resort to Cramer's rule (still taught as the practical method in some high schools) and solve his equations as the ratios of determinants - a process that requires labor proportional to N! if done in the schoolboy manner. The contrast with N^3 can be startling!" And further on, "Having hinted darkly at my computational fundamentalism, it is probably time to commit to a public heresy by denouncing recursive calculations. I have never seen a numerical problem arising from the physical world that was best calculated by a recursive subroutine..."

Here is Cramer’s rule implemented to solve a 3 x 3 system of linear equations in many different programming languages, including many scripting languages.

Rosetta Code is helpful for examining how numerous common algorithms are implemented in different programming languages.

Many of the scripting language examples are calling a pre-programmed, imported function to compute determinants. Some of the examples, however, explicitly show how determinants are calculated.

Here is a Python example in which the determinant function is explicitly provided:

Hope this helps and does not mislead or confuse you.

308 Views · · Answer requested by

First understand Cramer’s rule. Solve a few problems by hand and set them aside as test cases.

Identify the cases where your code will crash. Develop a logic to catch these special cased.

Select a language of choice, say C or Python and learn basic operations like conditional-statements, looping etc.

Write and Debug your script

Verify that your script spits out the answers same as what you had worked out as part of step-1

If you are satisfied with step-5, great job! you are done. If not - follow step-4 (to debug) through step-6.

All the best!

Similar questions