Time for action - doing left and right division
1. We need to instantiate the coefficient matrix A and vector y first:
octave:93> A=[2 1 -3; 4 -2 -2; -1 0.5 -0.5]; y = [1; 3; 1.5];
2. The solution to the linear equation system, Equation (2.6), is then found directly via the command:
octave:94> A\y ans = -1.6250 -2.5000 -2.2500
Easy!
What just happened?
It should be clear what happened. In Command 93, we instantiated the matrix A
and the vector y
that define the linear equation system in Equation (2.6). We then solve this system using the left division operator. Later in Chapter 6, we will investigate how the left division operator performs for very large systems.
Let us try the right division operator, even though we know that it will cause problems:
octave:95> A/y error: operator /: nonconformant arguments (op1 is 3x3, op2 is 3x1)
We see the expected error message. The right division operator will, however, work in the following command:
octave:96> A/A ans = 1.0000 -0.0000 -0.0000...