CPT3701 LU Introduction
CPT3701 LU Introduction
Techniques: Octave
Dr Mandla Mahlobo
21 August 2024
Assessment Dates
1. Minor Test 1 - Assessment 1
• Feedback out
2. Major Test 1: Re-write – Assessment 2
• 10 September 2024 – Date confirmed!
3. Minor Test 2 - Assessment 3
• Due - 25 August 2024
4. Major Test 2 - Assessment 4
• New date to be generated!
5. Re-Test – Assessment 5
• 30 October 2024?? - New date to be generated!
Unit 1: Learning Outcomes
𝑓 𝑥 =𝑥+3
Analytical method?
𝑓 𝑥 =0
Thus:
𝑥+3=0
𝑥 = −3
Now, consider:
https://www.acs.psu.edu/drussell/Demos/Pendulum/Pendulum.html
GNU Octave
Let’s Recall!
Mathematical Expressions in Octave
Octave fully understands Mathematical language, this includes:
▪ Octave will therefore execute mathematical equations expressed by common mathematical
symbols.
Mathematical Expressions in Octave (Cont.)
What about Scientific Notation? Off course!
Predefined Constants and Complex Numbers
The following well known constants are predefined in the Octave software:
▪ 𝜋 (𝑝𝑖)
▪ Euler’s number (𝑒)
▪ Imaginary numbers (𝑖 and 𝑗)
▪ Infinity (𝑖𝑛𝑓)
▪ Not a Number (𝑁𝑎𝑁), e.g., 𝑖𝑛𝑓/𝑖𝑛𝑓,
Mathematical Functions
What other common mathematical symbols and/or functions does Octave understand:
▪ Absolute value: 𝑎𝑏𝑠( ),
▪ Logarithm: log , log(10),
▪ Trigonometric functions: sin , cos , tan( ), in radians,
▪ Inverse trigonometric functions: asin , acos( ) , atan( ),
▪ Square root: 𝑠𝑞𝑟𝑡 ( ),
▪ Exponential: exp ( ),
Mathematical Functions (Cont.)
Exercises:
Mathematical Functions (Cont.)
Can you personalize your own constants of functions in Octave? Yup!!
Arrays and Matrices
What is an Array?
▪ Octave also recognizes a set of organized multiple variables, known as an Array,
▪ Can exist in the form of integers, floating point numbers, complex numbers, etc.
What is a Matrix?
▪ An array of numbers enclosed in square brackets, i.e., [ ],
Matrix dimensions:
▪ Rows are separated by semi-colons (;),
▪ In a single row, each entry is separated by a comma (,) or space (bar),
We then define:
▪ Row vector = 1 × 𝑛 ,
▪ Column vector = 𝑛 × 1,
▪ From the above definitions, we can get the size of the matrix.
Vector and Matrix Creation