0
$\begingroup$

I have a matrix element $k_x$ and I want to substitute it as $-i\kappa$, I tried

Simplify[
  Subscript[H, s], 
  {B == 0, Subscript[k, x] == -I κ, Subscript[k, y] == κ}] // MatrixForm

However, the result shows $k_x$ in some elements in the matrix and $-i\kappa$ some place. How do I substitute all of them? I did a quick test but found the result just gives $k_x$.

Simplify[
  Subscript[k, x], 
  {B == 0, Subscript[k, x] == -I κ, Subscript[k, y] == κ}] // MatrixForm

I have played with ReplaceAll at the very beginning, but I actually want to do something in this way, is there any flexible way I can do a replacement?

Subscript[H, 01] = 
  FullSimplify[
    ArrayFlatten[({
      {Simplify[Subscript[H, S], {Subscript[k, x] == 0, Subscript[k, y] == 0}], 
       Simplify[
         Subscript[H, S], 
         {B == 0, Subscript[k, x] == -I κ, Subscript[k, y] == κ}]},
      {Simplify[
         ConjugateTranspose[Subscript[H, S]], 
         {B == 0, Subscript[k, x] == I κ, Subscript[k, y] == κ}],
       Simplify[
         Subscript[H, S], 
         {Subscript[k, x] == 0, Subscript[k, y] == 0}] + ℏ ω IdentityMatrix[4]}
      })], 
    {α, β, γ, κ, ζ, Subscript[k, x], Subscript[k, y]} ∈ Reals];
$\endgroup$

closed as off-topic by MarcoB, m_goldberg, ilian, Bob Hanlon, Öskå Aug 17 '15 at 18:04

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, m_goldberg, ilian, Bob Hanlon, Öskå
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Michael E2 Aug 17 '15 at 2:57
  • $\begingroup$ You can format inline code and code blocks by selecting the code and clicking the {} button above the edit window. The edit window help button ? is also useful for learning how to format your questions and answers. You may also find this this meta Q&A helpful $\endgroup$ – Michael E2 Aug 17 '15 at 2:57
  • 2
    $\begingroup$ Look up ReplaceAll. Also read this answer, mathematica.stackexchange.com/questions/18393/…, and pay attention to what it says about subscripts and MatrixForm, in case that is an issue. If you include an example for Subscript[H, s], folks will better be able to say what the precise issue is. $\endgroup$ – Michael E2 Aug 17 '15 at 3:03
  • $\begingroup$ Good, thanks. I find out ReplaceAll [Subscript[H, s],k_x->-i [kappa]] work better than Simplify $\endgroup$ – Dhwister Aug 17 '15 at 8:48
1
$\begingroup$

Try this:

rule = Subscript[k, x] -> I*κ

Then any expression you may treat as follows: expression/.rule. For example:

expression = Subscript[k, x]^2 + Subscript[k, x]
expression /. rule

returns:

(*   Subscript[k, x] + \!\(\*SubsuperscriptBox[\(k\), \(x\), \(2\)]\)  *)

(*  I κ - κ^2 *)

Have fun!

$\endgroup$

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