# Why won't the Rule work? And how to apply it to a combination of variables?

I want to convert SI to Gaussian units given vectors:

Subscript[Ε, si] = {Ex, Ey, Ez};
Subscript[B, si] = {Bx, By, Bz};
Subscript[S, si] = 1/Subscript[μ, 0] (Subscript[Ε, si]/[Cross]Subscript[B, si])
Subscript[S, si] /. {Subscript[B, si] -> Subscript[B, si]/c}


why doesn't the change apply?

Also, I have this horrible vector I'm trying to simplify in a similar manner (and apply certain conditions to it such as $B_z E_x = B_x E_z$):

Subscript[Ey, g] = γ (Ey + v/c Bz);
Subscript[Ez, g] = γ (Ez - v/c By);
Subscript[By, g] = γ (By - v/c Ez);
Subscript[Bz, g] = γ (Bz + v/c Ey);

Subscript[S, p] = c/(4 π) (Subscript[Ε, si]\[Cross]Subscript[B, si]) /. {Ey -> Subscript[Ey, g], Ez -> Subscript[Ez, g],
By -> Subscript[By, g], Bz -> Subscript[Bz, g]};
Subscript[S, p] /. {v -> c Tanh[ζ], Bz Ex -> Bx Ez,
Tanh[ζ]/Sqrt[Sech[ζ]^2] ->
Sinh[ζ]} // FullSimplify


I see that Rule doesn't work on combinations of variables, at least not in this expression for some reason. I tried inputting Bz Ex - Bx Ez /.Bz Ex -> Bx Ez on a separate line and it returned 0, like it should. Is there some trick to it? Why is it being finicky? As far as trig functions, I tried TrigReduce, but it didn't do anything. The square root of a square thing always bugs me. I also tried using assumptions with $\zeta>0$ and $\text{sech}(\zeta)>0$, but again to no avail. Is there a way to reduce that as well? And is there a general way to change certain chunks of expressions like that?

• I don't have a solution, but something to be aware of when using ReplaceAll is that the expression is evaluated before replacing, so after evaluation MMA can't find any instances of what you're trying to replace Commented Apr 24, 2015 at 6:21

Everything is as it should be. In the first instance, you want a separate rule for each element of the list. For that, you can use Thread:

Subscript[Ε, si] = {Ex, Ey, Ez};
Subscript[B, si] = {Bx, By, Bz};

Subscript[S, si] =
1/Subscript[μ, 0] (Subscript[Ε, si]*
Subscript[B, si]);

Subscript[S, si] /. Thread[Subscript[B, si] -> Subscript[B, si]/c]


$$\left\{\frac{\text{Bx} \text{Ex}}{c \mu _0},\frac{\text{By} \text{Ey}}{c \mu _0},\frac{\text{Bz} \text{Ez}}{c \mu _0}\right\}$$

For the second issue, you probably shouldn't be using rules but Assumptions passed to FullSimplify. You can also try Eliminate. But that depends on what you actually want to achieve with the "certain conditions" you speak of - i.e., which variables you want to eliminate.

Replacement rules are based on patterns, and if the pattern as written doesn't appear, the rule doesn't apply. So the rule for $B_z E_x$ is probably not what you want. Here is how to rewrite it so it gets used:

FullSimplify[
Subscript[S, p] /. {v -> c Tanh[ζ], Bz -> Bx Ez/ Ex}]


$$\left\{\frac{c \gamma ^2 \left(\frac{(\text{Bx} \text{Ez}+\text{Ex} \text{Ey} \tanh (\zeta )) (\text{Bx} \text{Ez} \tanh (\zeta )+\text{Ex} \text{Ey})}{\text{Ex}^2}+(\text{ By} \tanh (\zeta )-\text{Ez}) (\text{By}-\text{Ez} \tanh (\zeta ))\right)}{4 \pi },\right.\\ -\frac{c \gamma \tanh (\zeta ) (\text{Bx} \text{By}+\text{Ex} \text{Ey})}{4 \pi },\\\left.\frac{c \left(\gamma \text{Ex} (\text{By}-\text{Ez} \tanh (\zeta ))-\text{Bx} \gamma \left(\frac{\text{Bx} \text{Ez} \tanh (\zeta )}{\text{Ex}}+\text{Ey}\right)\right)}{4 \pi }\right\}$$