Clear Filters
Clear Filters

simplifying mathematics of symbolic expression

2 views (last 30 days)
Suma
Suma on 15 Mar 2014
Commented: Suma on 19 Mar 2014
I have a symbolic matrix
[ cos(conj(x))*cos(x), cos(conj(x))*exp(a*i)*sin(x)]
[ sin(conj(x))*exp(-conj(a)*i)*cos(x), sin(conj(x))*exp(a*i)*exp(-conj(a)*i)*sin(x)]
It looks so difficult and ugly. I am looking for simplified expression for the above something like the one below-
[ (cos(x))^2 cos(x)*exp(a*i)*sin(x)]
[sin(x)*exp(-conj(a)*i)*cos(x) (sin(x))^2 ]
since x is angle it does not have conjugate so I would like to have cos(conj(x)) as cos(x) and therefore cos(conj(x))*cos(x) as (cos(x))^2 or even better cos2x where 2 is in superscript as we normally have while writing.
Also exp(a*i)*exp(-conj(a)*i) would normally have cancelled out to give 1 but the resulted expression doesn't simplify to it
Can anybody help me here
thanks very much

Answers (1)

Star Strider
Star Strider on 15 Mar 2014
Edited: Star Strider on 15 Mar 2014
You are not telling the Symbolic Toolbox everything you know about your system. See if this code does something similar to what you want:
syms x a
assume(a, 'real')
assumeAlso(x, 'real')
f = [ [ cos(conj(x))*cos(x), cos(conj(x))*exp(a*i)*sin(x)]; [ sin(conj(x))*exp(-conj(a)*i)*cos(x), sin(conj(x))*exp(a*i)*exp(-conj(a)*i)*sin(x)] ]
fs = simplify(collect(f))
Note that when it knows that x is real, it eliminates conj(x).
‘Also exp(a*i)*exp(-conj(a)*i) would normally have cancelled out to give 1 but the resulted expression doesn't simplify to it’
It does now that it knows what you know about a:
g = exp(a*i)*exp(-conj(a)*i)
Experiment with it and the various functions in the Symbolic Toolbox to get the result in the form you want.
If you want it as a function you can execute as regular MATLAB code (outside of the Symbolic Math Toolbox), see matlabFunction.
  11 Comments
Walter Roberson
Walter Roberson on 17 Mar 2014
Try with x = 2 + 3*i and you will see that cos(conj(x))*cos(x) is not the same as (cos(x))^2

Sign in to comment.

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!