4
$\begingroup$

I have defined two symbolic matrices and I am performing several operations.

$Assumptions = (Nf | k) ∈ Integers && 0 < k < Nf && (Hp | Hq) ∈ Matrices[{Nb, Ub}]
Hk = Hp + (k/Nf) (Hq - Hp) 
Rk = ConjugateTranspose[Hk].Hk

My questions are:

  1. How can I get $(A+B)^H = A^H + B^H$? My Hk is a sum of two matrices, in Rk, there is a Hermitian operation.
  2. How can I get $(A_1+B_1).(A_2+B_2)=A_1 \, A_2 + A_1 \, B_2 + B_1 \, A_2 + B_1\,B_2$? My Rk is a multiplication of two expressions.

Thank you

$\endgroup$
4
$\begingroup$

I think TensorExpand is the tool for this job. For your second example:

TensorExpand[(A1 + B1) . (A2 + B2)]

A1.A2 + A1.B2 + B1.A2 + B1.B2

On the other hand, for your first example:

TensorExpand[ConjugateTranspose[A+B]]

ConjugateTranspose[A + B, {2, 1}]

it doesn't work. I think it's worth reporting this to support. One possible workaround is:

Options[ctExpand] = Options[TensorExpand];

ctExpand[e_, opts:OptionsPattern[]] := TensorExpand[
    Conjugate @ TensorExpand[
        Conjugate @ e,
        opts
    ],
    opts
]

Then:

ctExpand @ ConjugateTranspose[A + B]

ConjugateTranspose[A, {2, 1}] + ConjugateTranspose[B, {2, 1}]

For your more complicated example:

ctExpand[Rk]

ConjugateTranspose[Hp, {2, 1}].Hp - ( k ConjugateTranspose[Hp, {2, 1}].Hp)/Nf - ( Conjugate[k] ConjugateTranspose[Hp, {2, 1}].Hp)/Conjugate[Nf] + ( k Conjugate[k] ConjugateTranspose[Hp, {2, 1}].Hp)/(Nf Conjugate[Nf]) + ( k ConjugateTranspose[Hp, {2, 1}].Hq)/Nf - ( k Conjugate[k] ConjugateTranspose[Hp, {2, 1}].Hq)/(Nf Conjugate[Nf]) + ( Conjugate[k] ConjugateTranspose[Hq, {2, 1}].Hp)/Conjugate[Nf] - ( k Conjugate[k] ConjugateTranspose[Hq, {2, 1}].Hp)/(Nf Conjugate[Nf]) + ( k Conjugate[k] ConjugateTranspose[Hq, {2, 1}].Hq)/(Nf Conjugate[Nf])

The above is a bit difficult to read, so here is a more readable version:

(res /. ConjugateTranspose[a_, {2, 1}] -> ConjugateTranspose[a]) //TeXForm

$-\frac{k k^* \operatorname{Hp}^{\dagger }.\operatorname{Hq}}{\operatorname{Nf} \operatorname{Nf}^*}-\frac{k k^* \operatorname{Hq}^{\dagger }.\operatorname{Hp}}{\operatorname{Nf} \operatorname{Nf}^*}+\frac{k^* \operatorname{Hq}^{\dagger }.\operatorname{Hp}}{\operatorname{Nf}^*}+\frac{k k^* \operatorname{Hp}^{\dagger }.\operatorname{Hp}}{\operatorname{Nf} \operatorname{Nf}^*}-\frac{k^* \operatorname{Hp}^{\dagger }.\operatorname{Hp}}{\operatorname{Nf}^*}+\frac{k k^* \operatorname{Hq}^{\dagger }.\operatorname{Hq}}{\operatorname{Nf} \operatorname{Nf}^*}+\frac{k \operatorname{Hp}^{\dagger }.\operatorname{Hq}}{\operatorname{Nf}}-\frac{k \operatorname{Hp}^{\dagger }.\operatorname{Hp}}{\operatorname{Nf}}+\operatorname{Hp}^{\dagger }.\operatorname{Hp}$

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.