Assignment 5
Assignment 5
Linear Algebra
Chaeyeon Ahn
[email protected]
1. Linear Algebra
We are going to learn how to solve linear algebra problems using a Python program.
Before we begin, as we learned last week, we need to import a library for utilizing complex mathematical functions
in Python.
For this week, we will be using the 'sympy' library, which is a Python library designed for symbolic mathematics.
2. What is list in Python?
List
Lists are used to store multiple items in a single variable. Lists are one of 4 built-in data types in Python use
d to store collections of data, and lists are created using square brackets.
An array
An array is a data structure that lets us hold multiple values of the same data type.
An array is used to store more than one value at a time. It can hold multiple values in a single variable, and
helps
you reduce the overall size of the code.
Here are the key distinctions between an Array and a List:
1. Uniform Data Type: All elements must be of the same data type.
Python does not provide its own array data types. Therefore, another library must be imported. The standard package forusing
arrays in Python is NumPy.
It is also called as ‘one – dimensional array’ If there are different types of data, it converts it into characters
3. How to make a multi-dimension array?
A multidimensional array refers to an array with two or more dimensions, where each dimension is
essentially an array itself.
In a matrix, the horizontal elements are referred to as rows, and the vertical elements are referred to as
columns.
To create a two-dimensional array, you can use a list of lists, where the inner lists represent the rows of the
matrix.
The length of each inner list corresponds to the number of columns in the matrix, and the length of
the outer list
indicates the number of rows in the matrix.
3. How to make a multi-dimension array?
However, instead of using array function, we will be using the Matrix function to create
muti-dimensional array under Sympy library.
3. How to make a multi-dimension array?
Matrix and array functions serve similar purposes, but the key difference lies in their coding syntax.
The use of matrix functions is often favored because they provide a more visually intuitive
representation for working with multidimensional data, especially in mathematical and linear
algebra contexts.
Step 1.
For any equation with characters, declare
the symbols
Step 2.
Create the matrix using the Matrix
function
Step 3.
Flip the matrix (horizontal vertical) using
the transpose() function
4. How to make a matrix?
Step 1.
Declare the 2x2 matrices A and B
5. How is a matrix calculated?
5. How is a matrix calculated?
Example
Try the examples using variables
1 3 9 8
A= 5 7 ,B= 6 7
* If you use click the code button, you can create your own code.
-> There should be 4 codes to complete the assignment