First of all, this is quite related to this question here, however the solution given there does not apply to my issue.
I am generating a huge symbolic matrix, which has many (on the order of 50-100) indexed parameters originating in various sums. All of my symbols and indexed variables are real, so I would like to make use of that when I for instance perform a Conjugate
operation on the matrix.
See below minimal working example:
test = Exp[I*k[1]];
# + Conjugate[#] &@test
(* E^(-I Conjugate[k[1]]) + E^(I k[1]) *)
Refine[%, Assumptions -> k \[Element] Reals]
(* E^(-I Conjugate[k[1]]) + E^(I k[1]) *)
Refine[%, Assumptions -> k[1] \[Element] Reals]
(* E^(-I k[1]) + E^(I k[1])1 *)
An approach like Refine[...,Assumptions->_Symbol ∈ Reals]
will also not work, since Head[k[1]]
is k
, not Symbol
. The list of all indexed variables is not known in advance and changes as soon as I play with certain parameters, so I cannot just retrieve them once in order to get a full list and use this in Assumptions
.
Is there a way to tell mathematica that all Symbol
s and indexed variables are Reals
? Presumably it can be done using Symbolize
from the Notation
package, but I don't know how (I have seen it for Subscripts
but really want to avoid using them). How to deal with symbols is clear from the linked question, but achieving it for indexed variables is a myth for me right now.
ComplexExpand
? $\endgroup$ComplexExpand
might take too long in those cases. I was thinking about using a rule likeComplex[a_,b_]:>Complex[a,-b]
instead ofConjugate
but I have a feeling that this is not safe. $\endgroup$Assumptions -> _k ∈ Reals
, orAssumptions -> (s_Symbol /; Context@s =!= "System`")[_Integer? Positive] ∈ Reals
? $\endgroup$