When simplify() in octave's symbolic package seems to not work.

octave symbolic-computation

Suppose you are setting up some heinous expression and you want Octave to simplify it, and that doesn’t happen. Why?

The reason may be that there is not a number set (programming: type) specified for the symbolic variables. Here, syms is used to declare the symbolic variables a1, a2, a3, but there’s no number set. We can look at the assumptions for the variables in the workspace with assumptions:

>> pkg load symbolic
>> syms a1 a2 a3
>> assumptions
ans = {}(0x0)

Okay, so assumptions is empty; no number set type is specified for these variables.

We can see the list of all possible assumptions but adding the argument ‘possible’ to assumptions:

>> assumptions('possible')
ans =
{
  [1,1] = real
  [1,2] = even
  [1,3] = irrational
  [1,4] = antihermitian
  [1,5] = nonpositive
  [1,6] = composite
  [1,7] = negative
  [1,8] = algebraic
  [1,9] = hermitian
  [1,10] = infinite
  [1,11] = integer
  [1,12] = imaginary
  [1,13] = odd
  [1,14] = nonzero
  [1,15] = polar
  [1,16] = commutative
  [1,17] = positive
  [1,18] = noninteger
  [1,19] = zero
  [1,20] = nonnegative
  [1,21] = prime
  [1,22] = complex
  [1,23] = rational
  [1,24] = finite
  [1,25] = transcendental
}
>>

Wow, those are all the possible number sets! There’s a lot of them!

Ok, now to specify the number set type, after the variables list in syms, add the type. I’m using real.

>> syms b1 b2 b3 real
>> assumptions
ans =
{
  [1,1] = b1: real
  [1,2] = b2: real
  [1,3] = b3: real
}

And then assumptions returns that a number set is associated with these variables.

© Amy Tabb 2018 - 2023. All rights reserved. The contents of this site reflect my personal perspectives and not those of any other entity.