1
$\begingroup$

Is there any way to tell Mathematica to replace $\kappa^2 + k_z^2 \rightarrow k^2$ in an expression? I want to make a result more readable, e.g. something like this:

$$\frac{2 k_z^3 \sqrt{k_z^2 + \kappa^2} + 2 k_z \kappa^2 \sqrt{k_z^2 + \kappa^2} + k_z \sqrt{k_z^2 + \kappa^2} \mu^2}{2 (k_z^4 + 2 k_z^2 \kappa^2 + \kappa^4)}$$


(2 kz^3 Sqrt[kz^2 + κ^2] + 2 kz κ^2 Sqrt[kz^2 + κ^2] + kz Sqrt[kz^2 + κ^2] μ^2)/
 (2 (kz^4 + 2 kz^2 κ^2 + κ^4))

Which can be simplified to:

$$k_z \frac{ (2k^2 + \mu^2) }{2k^3}$$

But I can't get Mathematica to perform this substitution. I have made sure to use the proper assumptions for this to work:

$Assumptions={k>0};

Yet it seems to not see the (arguably trivial) patterns. Does anyone know how to trick Mathematica into doing what I want :-)?

$\endgroup$
3

4 Answers 4

1
$\begingroup$

Well, in exploring the physics of my result, I got an idea that helps to get What I Want™:

$Assumptions={k>0};
thing:=(2 kz^3 Sqrt[kz^2 + κ^2] + 2 kz κ^2 Sqrt[kz^2 + κ^2] + kz Sqrt[kz^2 + κ^2] μ^2)/(2 (kz^4 + 2 kz^2 κ^2 + κ^4));

thing /. kz->k Cos[α] /. κ->k Sin[α]//Simplify
% /. α->ArcCos[kz/k]

It's literally a workaround, but it does the trick quite nicely in this and probably similar cases.

$\endgroup$
1
$\begingroup$

This is your expression:

expr = (2 kz^3 Sqrt[kz^2 + \[Kappa]^2] + 
 2 kz \[Kappa]^2 Sqrt[kz^2 + \[Kappa]^2] + 
 kz Sqrt[kz^2 + \[Kappa]^2] \[Mu]^2)/(2 (kz^4 + 
   2 kz^2 \[Kappa]^2 + \[Kappa]^4));

This gives us the substitution:

    sl = Solve[kz^2 + \[Kappa]^2 == k^2, \[Kappa]][[2, 1]]

(*  \[Kappa] -> Sqrt[k^2 - kz^2]   *)

An here it acts on your expression yielding the desired result:

 Simplify[expr /. sl, {k > 0, \[Kappa] > 0}]

(*  (kz (2 k^2 + \[Mu]^2))/(2 k^3)   *)

It is basically almost the same as in the eldo's answer, but has the advantage that when one takes the replacement kz^2 + \[Kappa]^2 -> k^2Mma in some situations understands it, but may miss in some others. So, it may require some additional efforts. In contrast with the above substitution everything goes smooth.

$\endgroup$
0
$\begingroup$

The following will work, but it's probably not the best way

PowerExpand[FullSimplify[(2 kz^3 Sqrt[kz^2 + κ^2] + 2 kz κ^2 Sqrt[kz^2 + κ^2] + 
      kz Sqrt[kz^2 + κ^2] μ^2)/(2 (kz^4 + 2 kz^2 κ^2 + κ^4)) /. 
      kz^(2 a__) -> (k^2 - κ^2)^a] /. (kz^2 + κ^2) -> k^2]

Output

(kz (2 k^2 + μ^2))/(2 k^3)
$\endgroup$
0
$\begingroup$

no doubt covered in the above links, but since I worked it out:

 thing = (2 kz^3 Sqrt[kz^2 + kappa^2] + 
      2 kz kappa^2 Sqrt[kz^2 + kappa^2] + 
         kz Sqrt[kz^2 + kappa^2] mu^2)/(2 (kz^4 + 2 kz^2 kappa^2 + 
             kappa^4));
 f = # /. Table[ (kz^2)^n -> (K^2 - kappa^2)^n , {n, 1, 2}] &;
 cpx[e_] := 100 Count[e, kz, {0, Infinity}] + LeafCount[e] 
 Simplify[ thing , TransformationFunctions -> {Automatic, f}, 
                   ComplexityFunction -> cpx, Assumptions -> K > 0] 

(kz (2 K^2 + mu^2))/(2 K^3)

The ComplexityFunction is a not-so-obvious key here. The intermediate results of the transformation are evidently deemed more complex by the default and not applied.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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