FUN WITH LINUX

First steps with GNU Octave (2) - Solving Equations

8 February 2015

Solving Simple Linear Equations

We can solve linear equations using vectors:

3x - 1y = 3
1x + 1y = 5

x = 2
y = 3


octave:4> ###################################
octave:4> # solving linear equations
octave:4> # 3x - 1y = 3
octave:4> # 1x + 1y = 5
octave:4> A=[3 -1; 1 1];
octave:5> b=[3;5];
octave:6> A\b
ans =

   2
   3

Solving Polynomial Equations

4x2 - 12y - 40 = 0
x1 = 5
x2 = -2



octave:1> # finding the roots of a polynomial
octave:1> k = [4, -12, -40]
k =

    4 -12 -40

octave:2>#  
octave:2> # output:
octave:2> polyout(k,'x')
4*x^2 - 12*x^1 - 40
octave:3>
octave:3> # solving:
octave:3> roots(k)
ans =

   5
  -2
[ Mathematics  Octave  ]
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution 3.0 Unported License.

Copyright 2015-present Hoti