0% found this document useful (0 votes)
49 views10 pages

Matrix Syntax: Least Squares Solution - in Other Words, A Solution That Minimizes The Length of The Vector Ax - B

Here are 4 practice problems for geometric and arithmetic progressions: 1) Find the 5th term of the geometric progression 64, 32, 16, 8,... - a = 64, r = 1/2 - t5 = ar4 = 64(1/2)4 = 64(1/16) = 4 2) Find the 10th term of the arithmetic progression 5, 8, 11, 14,... - a = 5, d = 8 - 5 = 3 - t10 = a + (10-1)d = 5 + 9*3 = 5 + 27 = 32 3) Find the common ratio of the geometric progression 9, 6, 4, ... - a

Uploaded by

Imee Ramos
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views10 pages

Matrix Syntax: Least Squares Solution - in Other Words, A Solution That Minimizes The Length of The Vector Ax - B

Here are 4 practice problems for geometric and arithmetic progressions: 1) Find the 5th term of the geometric progression 64, 32, 16, 8,... - a = 64, r = 1/2 - t5 = ar4 = 64(1/2)4 = 64(1/16) = 4 2) Find the 10th term of the arithmetic progression 5, 8, 11, 14,... - a = 5, d = 8 - 5 = 3 - t10 = a + (10-1)d = 5 + 9*3 = 5 + 27 = 32 3) Find the common ratio of the geometric progression 9, 6, 4, ... - a

Uploaded by

Imee Ramos
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

MATRIX

Syntax

mldivide(A,B) A\B
mrdivide(B,A) B/A

Description

mldivide(A,B) and the equivalent A\B perform matrix left division (back slash). A and B must
be matrices that have the same number of rows, unless A is a scalar, in which case A\B performs
element-wise division — that is, A\B = A.\B.

If A is a square matrix, A\B is roughly the same as inv(A)*B, except it is computed in a different
way. If A is an n-by-n matrix and B is a column vector with n elements, or a matrix with several
such columns, then X = A\B is the solution to the equation AX = B. A warning message is
displayed if A is badly scaled or nearly singular.

If A is an m-by-n matrix with m ~= n and B is a column vector with m components, or a matrix


with several such columns, then X = A\B is the solution in the least squares sense to the under-
or overdetermined system of equations AX = B. In other words, X minimizes norm(A*X - B), the
length of the vector AX - B. The rank k of A is determined from the QR decomposition with
column pivoting. The computed solution X has at most k nonzero elements per column. If k < n,
this is usually not the same solution as x = pinv(A)*B, which returns a least squares solution.

mrdivide(B,A) and the equivalent B/A perform matrix right division (forward slash). B and A
must have the same number of columns.

If A is a square matrix, B/A is roughly the same as B*inv(A). If A is an n-by-n matrix and B is a
row vector with n elements, or a matrix with several such rows, then X = B/A is the solution to
the equation XA = B computed by Gaussian elimination with partial pivoting. A warning
message is displayed if A is badly scaled or nearly singular.

If B is an m-by-n matrix with m ~= n and A is a column vector with m components, or a matrix


with several such columns, then X = B/A is the solution in the least squares sense to the under-
or overdetermined system of equations XA = B.

Note   Matrix right division and matrix left division are related by the equation
B/A = (A'\B')'.

Least Squares Solutions

If the equation Ax = b does not have a solution (and A is not a square matrix), x = A\b returns a
least squares solution — in other words, a solution that minimizes the length of the vector Ax - b,
which is equal to norm(A*x - b). See Example 3 for an example of this.
Examples

Example 1

Suppose that A and b are the following.

A = magic(3)

A=

8 1 6
3 5 7
4 9 2

b = [1;2;3]

b=

1
2
3

To solve the matrix equation Ax = b, enter

x=A\b

x=

0.0500
0.3000
0.0500

You can verify that x is the solution to the equation as follows.

A*x

ans =

1.0000
2.0000
3.0000

Example 2 — A Singular

If A is singular, A\b returns the following warning.


Warning: Matrix is singular to working precision.

In this case, Ax = b might not have a solution. For example,

A = magic(5);
A(:,1) = zeros(1,5); % Set column 1 of A to zeros
b = [1;2;5;7;7];
x = A\b
Warning: Matrix is singular to working precision.

ans =

NaN
NaN
NaN
NaN
NaN

If you get this warning, you can still attempt to solve Ax = b using the pseudoinverse function
pinv.

x = pinv(A)*b

x=

0
0.0209
0.2717
0.0808
-0.0321

The result x is least squares solution to Ax = b. To determine whether x is a exact solution — that
is, a solution for which Ax - b = 0 — simply compute

A*x-b

ans =

-0.0603
0.6246
-0.4320
0.0141
0.0415

The answer is not the zero vector, so x is not an exact solution.


Pseudoinverses, in the online MATLAB Mathematics documentation, provides more examples
of solving linear systems using pinv.

Example 3

Suppose that

A = [1 0 0;1 0 0];
b = [1; 2];

Note that Ax = b cannot have a solution, because A*x has equal entries for any x. Entering

x = A\b

returns the least squares solution

x=

1.5000
0
0

along with a warning that A is rank deficient. Note that x is not an exact solution:

A*x-b

ans =

0.5000
-0.5000

Class Support

When computing X = A\B or X = A/B, the matrices A and B can have data type double or single.
The following rules determine the data type of the result:

 If both A and B have type double, X has type double.


 If either A or B has type single, X has type single.

Matrix inverse solver - Introduction:

              In algebra, the determinant is a particular number related with some square matrix. The
essential geometric significance of a determinant is a scale factor for compute when the matrix is
considered as a linear transformation. Thus a 3 xx 3 matrix with determinant 3 when useful to a
place of points with fixed area will convert those points into a place with double the area.
Determinants are significant together in calculus, where they go into the replacement rule for
various variables, and in multi linear algebra.

then A has an inverse, Denoted

Matrix Inverse Solver - Examples:

Matrix inverse solver - Example 1:

Find the inverse of the following matrix.

Solution:

Initially, write down the entrance the matrix B, other than write in a double-wide matrix:
In the added partially of the double-wide, write down the identity matrix:

          At this moment we will perform matrix row operations to exchange the LHS of the
double-wide to the identity. (As constantly with row operations, here no one "correct" way to do
this pursue are just the steps that occur to me. Our estimate can be simply looking moderately
different.

          At this moment that the LHS of the double-wide include the identity, the RHS include the
inverse. That is, the inverse matrix is the following:

Matrix Inverse Solver - more Examples:

Matrix inverse solver - Example 1:

Find the X values of the following matrix equation?


Solution:

Initially, write down the entrance the matrix B, other than write in a double-wide matrix:

         

In the added partially of the double-wide, write down the identity matrix:

          At this moment we will perform matrix row operations to exchange the LHS of the
double-wide to the identity. (As constantly with row operations, here no one "correct" way to do
this pursue are just the steps that occur to me. Our estimate can be simply looking moderately
different.)

          At this moment that the LHS of the double-wide include the identity, the RHS include the
inverse. That is, the inverse matrix is the following:

PERMUTATION AND COMBINATION


A teacher is making a multiple choice quiz.  She wants to give each student the same questions,
but have each student's questions appear in a different order.  If there are twenty-seven students
in the class, what is the least number of questions the quiz must contain?
ANSWER:
 If there were two questions on the quiz, we could prepare two quizzes with the questions in
different order -- 2•1 = 2.
If  there were three questions, we could get 3•2•1 = 6 different orders.
If there were four questions, we could get 4•3•2•1 = 24 different orders -- not quite enough for
the class of 27 students.
If there were five questions, we could get 5•4•3•2•1 = 120 different orders.  The teacher will
need at least 5 questions on the quiz.
             
2. A coach must choose five starters from a team of 12 players.  How many different ways can
the coach choose the starters?
ANS:

3. In how many ways can 3 different vases be arranged on a tray?

Ans:
     Basic counting principle:
      3! = 3•2•1 = 6 ways

4. There are fourteen juniors and twenty-three seniors in the Service Club.  The club is to send
four representatives to the State Conference.

a.)  How many different ways are there to select a group of four students to attend the
conference?

b.)  If the members of the club decide to send two juniors and two seniors, how many different
groupings are possible?

Ans:
 14 juniors, 23 seniors
        37 students total
  a.)  Choose  4 students from the total number of students.  Order is not important.
                 

b.)  Choose 2 juniors and 2 seniors.


      

Geometric Progression:

The general form of geometric progression is:


                                     a, ar, ar2, ar3, ar4, ..

Formula:

                                       tn = arn-1

                              where a, the first term

                                         r, the common ratio

Example:

Find the 6th term of the Geometric sequence 64, 16, 4....

Solution:                      a = 64, r = 16 / 64

                                                      r =  1/4

                                                   tn  = ar6–1

                                                   t6  = ar6–1  

                                                         = ar5

                                                  t6  = 64(1/4)5

                                                        = 64(1/1024)

                                                    t6 =  1/16

              Hence the 6th  term of Geometric sequence is 1/16

Arithmetic Progression:

The General form of Arithmetic progression is

                               a , a+d, a+2d, a+3d…..

Formula:

                                       tn  = a + (n–1) d

                              where a, the first term

                                        d, the common difference


Example:

Find the  11th term of an Arithmetic progression 12, 16, 20, 24…...

Solution: 

                                  Here, a = 12, d = 16 – 12 = 4, n = 11

                                  By formula, tn = a + (n–1) d

                                                      t12 = 12 + (11 – 1) (4)

                                                            = 12 + 10 (4)

                                                            = 12 + 40

                                                    t11   =52

                                     Hence, the 11th term is 52.

Practice Problems for Geometric and Arithmetic Progression:

1) Find the 11th term of an Arithmetic progressions sequence 5, 9, 13, 17…...

        Solution: t 11 = 45

2) Find the 8th term of the Geometric progressions sequence 343, 49, 7...

         Solution: t8 = 1/2401.

3) Find the 6th term of arithmetic sequence, 7, 12,17,22,27…

        Solution: t6 = 32.

4) Find the 7th term of the Geometric sequence 64, 16, 4....

         Solution: t7 = 1/64

You might also like