simplifying mathematics of symbolic expression

2 次查看(过去 30 天)
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

回答(1 个)

Star Strider
Star Strider 2014-3-15
编辑:Star Strider 2014-3-15
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 个评论
Walter Roberson
Walter Roberson 2014-3-17
Try with x = 2 + 3*i and you will see that cos(conj(x))*cos(x) is not the same as (cos(x))^2

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by