Brandon Rozek

Thoughts on Web Development, Statistics, and Linux

Simplifying Expressions with Octave

Octave is a high level programming language intended for numerical computations. One of the cool features of this is that with symbolic expressions, you can then simplify mathematical expressions.

Setup

First install Octave and the symbolic package using the website or your package manager of choice.

Then in octave type in the following code


pkg load symbolic

Usage

For every variable not defined earlier in your expression, make sure to declare it as a symbolic data type

syms x y

Then make an expression


expr = y + sin(x)^2 + cos(x)^2

You can then ask Octave to simplify the expression for you


simp_expr = simplify(expr)

Displaying it shows it as

(sym) y + 1

Which is indeed a simplification using a trig identity 🙂