TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Octave

Solve Linear Algebraic Equations using Octave

Overview

In this tutorial, we will learn how to solve linear algebraic equations using Octave software. We will use the Gaussian elimination to solve the system of equations.

Example

Let’s solve the following system of three linear equations. The unknowns are x, y, and z.

4x + 3y + 2z = 44

3x + 7y + 4z = 60

8x + 9y + 5z = 101

We will define three matrices so that we can represent the equations in matrix form:

Ax = b

where A, x, and b are matrices.

To solve the unknowns, we need to solve for x. Let’s write the linear equations in the form:

x = A\b

Octave Code

>> % Define A
>> A = [4 3 2;3 7 4;8 9 5];
>> % Define b
>> b = [44; 60; 101];
>> x = A\b
x =

6
2
7

>>

 

Linear Algebraic Equations Octave

It is clear that the solution is
x = 6
y = 2
z = 7

Alternatively, we can use the inverse matrix of A using the inv() function.

x = inv(A)*b

Note that the inv() function is slow and inaccurate for a large set of equations.

We can verify the solution by computing the

A*x – b

The result should be close to zero.

>> format bank
>> A*x -b
ans =

0.00
0.00
0.00

—

Octave Tutorials

Octave Tutorial on this website can be found at:
https://www.testingdocs.com/octave-tutorial/

More information on Octave can be found on the official website:
https://www.gnu.org/software/octave/index

Related Posts

Octave Package List

Octave /

Install Octave Packages on Linux

Octave /

Octave User defined Function Example

octave command line linux

Octave /

Octave Command line on Ubuntu

Hello World in Octave

Octave /

Hello World in Octave

Octave /

Octave plot example of function y=x^2

‹ Octave Trigonometric Functions› Octave format command

Recent Posts

  • Update draw.io on Windows
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com