mirror of
https://github.com/Brandon-Rozek/website.git
synced 2024-11-09 10:40:34 -05:00
1.9 KiB
1.9 KiB
id | title | date | author | aliases | permalink | medium_post | mf2_syndicate-to | mf2_cite | mf2_syndication | format | |||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2115 | Simplifying Expressions with Octave | 2017-03-09T02:09:58+00:00 | Brandon Rozek |
|
/2017/03/simplifying-expressions-octave/ |
|
|
|
|
aside |
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 🙂
Update: Octave's symbolic is based on SymPy. If you're confortable with Python, I recommend checking it out.