# Introduction to Symbolic Computation

## 1 The MATLAB environment

MATLAB is a software program that allows you to compute interactively with matrices. If you want to know
for instance the product of a matrix a with a matrix b, then you just type in a * b and the result appears
immediately on screen. MATLAB has a wide range of functions to compute the determinant, inverse, LU-
decomposition, eigenvalues, etc.

While working with MATLAB you get on your screen always a prompt. This is >>. This means that
MATLAB is ready to accept commands. If you press the enter key, the command gets executed.

Unless you finish your command with a semicolon (`;'), MATLAB displays the result on screen. To copy
the output also to a file, you can invoke the command diary. For example,

>> diary('h : \nsession:txt') enter

will cause MATLAB to copy all user input and output to the file h:\nsession.txt. The diary o® command
suspends the output to the file, whereas diary on turns it back on.

The command who displays the list all variables currently in use. With clear you deallocate memory
space for those variables . If you want to use some or all of the variables with their values in a later MATLAB
session you can save the workspace variables with the command save('h:\ nmyvars') which creates the binary
MAT-file named myvars.mat. With load('h:\ nmyvars'), the workspace variables are loaded from the file
myvars.mat.

Make sure you understand the difference between the file produced by diary and the file made by save!
With diary we create a human readable text file, with save we make a binary mat-file.

MATLAB records the commands you typed in. You can scroll through the list of executed commands
with the arrow keys ↑ and ↓. The arrows ← and → enable to go to the location in the command where
edits are necessary. This is convenient to correct type errors in a command, or if you need to execute lots of
slightly different versions of the same instruction.

MATLAB has online help facilities. The command help displays information in the current window,
helpwin opens a new window, helpdesk launches your internet browser.

## 2 A short introduction to MATLAB

MATLAB follows a C like syntax . For example, the equality symbol `=' is used for assignment while `=='
must be used to test equality. The matrix is the fundamental data structure in MATLAB.

2.1 Entering variables
NUMBERS
< name-of-the-variable > = < value >
e.g.:

>> x = 0.65 enter

makes that MATLAB assigns the value 0:65 to the variable x.
MATLAB confirms :
x =

0.6500

>>

MATRICES These are defined row-wise. A square bracket [ means to MATLAB that you wish to enter a
matrix. The input of a matrix is terminated by a ]. You can enter a matrix in two ways.
For instance, you want then you either type

>> a = [ 0 1 2 ; 3 4 5 ; 6 7 8 ] enter

or

>> a = [ 0 1 2 enter 3 4 5 enter 6 7 8 ] enter

In both cases, MATLAB answers :

a =

0 1 2
3 4 5
6 7 8

2.2 The output

The content of a variable can be gotten just by typing in the name of the variable, followed by pressing the
enter
key.
e.g.:

>> x enter

x =

0.6500

This is the standard output format of MATLAB. To obtain the scientific notation, you switch formats as
follows

>> format short e enter

After typing

>> x enter

x = If you replace in the format-commands short by long, you see more decimal places .
To return back to the standard output format, you type

>> format short enter

2.3 Selecting en transposing

You can select elements from a matrix :

a(i, j) returns the element on the i-th row and j-th column.

a(i, :) returns the entire i-th row of a.

a(:, j) returns the entire j-th column of a.

a(i : j, k : l) returns the matrix a(i… j; k … l).

e.g.: >> m = a(1 : 2, 2 : 3) enter
returns To transpose a matrix, you type an accent after the matrix.
e.g.: >> b = a' enter
returns

b =

0 3 6
1 4 7
2 5 8

 Prev Next
{"ft_lang_label":"__label__en","ft_lang_prob":0.7523592,"math_prob":0.7639387,"size":3859,"snap":"2020-34-2020-40","text_gpt3_token_len":1024,"char_repetition_ratio":0.13022049,"word_repetition_ratio":0.01369863,"special_character_ratio":0.26250324,"punctuation_ratio":0.13228156,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9825765,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12],"im_url_duplicate_count":[null,null,null,1,null,1,null,1,null,1,null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-09-30T23:10:41Z\",\"WARC-Record-ID\":\"<urn:uuid:35ce2a48-162c-4cdc-b69f-a154897585b2>\",\"Content-Length\":\"37235\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:433cecbf-ceaf-4fc8-a54b-7f158d7e13f3>\",\"WARC-Concurrent-To\":\"<urn:uuid:fdd2a5ed-f99e-4d1e-bbde-a4bb3766c65e>\",\"WARC-IP-Address\":\"52.43.142.96\",\"WARC-Target-URI\":\"https://www.softmath.com/tutorials-3/algebra-formulas/introduction-to-symbolic.html\",\"WARC-Payload-Digest\":\"sha1:V5SKBQMM2SSE4YXSTLF7TQNZB2P6YTVL\",\"WARC-Block-Digest\":\"sha1:IZWTUQHAJLOCTTH7WTAXATMJAJ72SM22\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-40/CC-MAIN-2020-40_segments_1600402128649.98_warc_CC-MAIN-20200930204041-20200930234041-00354.warc.gz\"}"}