Effacer les filtres
Effacer les filtres

simplifying mathematics of symbolic expression

2 vues (au cours des 30 derniers jours)
Suma
Suma le 15 Mar 2014
Commenté : Suma le 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

Réponses (1)

Star Strider
Star Strider le 15 Mar 2014
Modifié(e) : Star Strider le 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 commentaires
Walter Roberson
Walter Roberson le 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
Suma
Suma le 19 Mar 2014
ok thanks

Connectez-vous pour commenter.

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by