disruptive
disruptive

Reputation: 5946

Symbolic simplification in Octave seems very basic

I'm attempting some symbolic computations in Octave using the symbolic package but I seem to be running aground with issues when it comes to simplification (why I want to use it). For example it works for simple expressions but for more complex matrix operations, it seems to be fail. What is going wrong here:

pkg load symbolic
syms a b d t
A = cos(t/2)*exp(i*(a - b/2 - d/2))
B = -sin(t/2)*exp(i*(a-b/2+d/2))
C = sin(t/2)*exp(i*(a + b/2 - d/2))
D = cos(t/2)*exp(i*(a+b/2+d/2))
U = [A, B; C, D]
simplify(expand(conj(U.')*U))

I have tried using just simplify without expand. However I should be getting the itentity matrix but instead get an expression - correct but not simplified. Is there a way I can make this work?

Upvotes: 3

Views: 2979

Answers (1)

horchler
horchler

Reputation: 18484

At least in Matlab, symbolic variables are assumed to be complex by default. It looks like you may require that a, b, d, and t be real. If so, you need to define them as such so your expressions can be simplified as you expect:

syms a b d t real

Then the result (at least in Matlab R2017a) from simplify will be a symbolic identity matrix.

See the documentation for syms and/or sym for more. You may also wish to read more about assumptions for symbolic variables: sym/assumptions and sym/assume.

Upvotes: 2

Related Questions