0
$\begingroup$

Sometime Solve and DSolve give a finial form of the solution, which is fine in may applications. However, in some cases, one may want the solutions in a clearer expression, which can often be achieved by substitution or by substitution of substitution(s). Please see the following example:

Solve[\[Sigma]^3 + 3 r \[Sigma] + s == 0, \[Sigma]]

gives a real root $\sigma_r$ and two complex roots $\sigma_{c,1}$ and $\sigma_{c,2}$, not shown here due to complicated expression. I want to simplify these roots as follows:

$\sigma_r=\alpha$, and $\sigma_c=-\frac{1}{2}\alpha\pm(i \sqrt{3}/2)\beta$, where $\alpha=(J_+)^{1/3}+(J_-)^{1/3}$, $\beta=(J_+)^{1/3}-(J_-)^{1/3}$ with $J_{\pm}$ defined as $J_{\pm}=\frac{1}{2}(s\pm\sqrt{s^2+4r^3})$.

I have tried the following:

Jminus = 1/2*(s - Sqrt[s^2 + 4 r^3]);
Jplus = 1/2*(s + Sqrt[s^2 + 4 r^3]);

(*roots given by Solve as above*)/. {1/2*(s - Sqrt[4 r^3 + s^2]) -> Jminus, 1/2*(s + Sqrt[4 r^3 + s^2])-> Jplus} // FullSimplify

But the output remains unchanged. Please give me some suggestion. Thanks!

$\endgroup$

3 Answers 3

1
$\begingroup$

Not sure this goes all the way, but a start:

S = Solve[σ^3 + 3 r σ + s == 0, σ];

Use FullSimplify with specific transformation rules:

Clear[Jplus, Jminus];  (* delete your definitions *)

FullSimplify[S, 
  TransformationFunctions -> {Automatic, 
    Function[X, X /. Sqrt[4 r^3 + s^2] -> s - 2 Jminus], 
    Function[X, X /. Sqrt[4 r^3 + s^2] -> -s + 2 Jplus], 
    Function[X, X /. Jplus -> s - Jminus], 
    Function[X, X /. Jminus -> s - Jplus]}]

$$ \left\{\left\{\sigma \to \frac{J_- r}{(-J_-)^{4/3}}+(-J_-)^{1/3}\right\},\left\{\sigma \to \frac{i \left(\sqrt{3}+i\right) (-J_-)^{2/3}+i \sqrt{3} r+r}{2 (-J_-)^{1/3}}\right\},\left\{\sigma \to \frac{\left(-1-i \sqrt{3}\right) (-J_-)^{2/3}-i \sqrt{3} r+r}{2 (-J_-)^{1/3}}\right\}\right\} $$

Notice that I did the substitutions on the square roots, not on the entire $J_{\pm}$ expressions, for the reason @Bill mentions: pattern-matching is brittle and must be aided with such tricks.

Do you have any assumptions on the signs of $r$, $s$, $J_+$, and $J_-$? These could help to simplify further, for example:

S /. Sqrt[4 r^3 + s^2] -> s - 2 Jminus /. 1/(-Jminus)^(1/3) -> Jplus^(1/3)/r

$$ \left\{\left\{\sigma \to (-J_-)^{1/3}-(J_+)^{1/3}\right\},\left\{\sigma \to \frac{1}{2} \left(1+i \sqrt{3}\right) (J_+)^{1/3}-\frac{1}{2} \left(1-i \sqrt{3}\right) (-J_-)^{1/3}\right\},\left\{\sigma \to \frac{1}{2} \left(1-i \sqrt{3}\right) (J_+)^{1/3}-\frac{1}{2} \left(1+i \sqrt{3}\right) (-J_-)^{1/3}\right\}\right\} $$

$\endgroup$
3
  • $\begingroup$ thanks for the answer. I found the documentation on TransformationFunctions is so insufficient only one example involving Reduce. What role does the Automatic play in TransformationFunctions? $\endgroup$
    – Enter
    Commented Jun 11, 2019 at 3:54
  • $\begingroup$ can I say: in TransformationFunctions we must use pure functions to specify all the parts that need to be substituted, like Function[X, X /.replacement] whose body is a replacement rule? $\endgroup$
    – Enter
    Commented Jun 11, 2019 at 4:07
  • $\begingroup$ @Enter yes the documentation on TransformationFunctions is very sparse. Automatic means to include the built-in transformations as well. The additional functions are, as you say, pure functions that do something with the expression. $\endgroup$
    – Roman
    Commented Jun 11, 2019 at 11:15
1
$\begingroup$

Mathematica's pattern replacement is relatively brute force. Some call that "structural pattern matching" which means that if the expression that you want to replace is even slightly different in any small or large way from the pattern you show, no matter how obvious it is to you that the expression is equivalent to what you want to replace, then it will not match and it won't replace anything.

Here is a strategy that I use which seems more often successful. Use InputForm or sometimes even FullForm on the expression to see all the details. For example this:

Solve[\[Sigma]^3+3 r \[Sigma]+s==0,\[Sigma]]//InputForm

shows me this

{{\[Sigma] -> -((2^(1/3)*r)/(-s + Sqrt[4*r^3 + s^2])^(1/3)) + 
   (-s + Sqrt[4*r^3 + s^2])^(1/3)/2^(1/3)}, 
 {\[Sigma] -> ((1 + I*Sqrt[3])*r)/(2^(2/3)*(-s + Sqrt[4*r^3 + s^2])^(1/3)) - 
   ((1 - I*Sqrt[3])*(-s + Sqrt[4*r^3 + s^2])^(1/3))/(2*2^(1/3))}, 
 {\[Sigma] -> ((1 - I*Sqrt[3])*r)/(2^(2/3)*(-s + Sqrt[4*r^3 + s^2])^(1/3)) - 
   ((1 + I*Sqrt[3])*(-s + Sqrt[4*r^3 + s^2])^(1/3))/(2*2^(1/3))}}

and when I look in that for literally exactly 1/2*(s - Sqrt[s^2 + 4 r^3]) to replace with Jminus I don't see it.

But I do see (-s + Sqrt[4*r^3 + s^2])^(1/3)/2^(1/3) in there and if I do a bit of algebraic manipulation in my head I think I imagine that might be (-Jminus)^(1/3) in your notation. So I scrape-n-paste the literal pattern from the InputForm or FullForm that I want to match into the replacement process and then this

Solve[\[Sigma]^3+3 r \[Sigma]+s==0,\[Sigma]]/.(-s+Sqrt[4*r^3+s^2])^(1/3)/2^(1/3)->(-Jminus)^(1/3)

shows me this

{{\[Sigma] -> (-Jminus)^(1/3) - (2^(1/3)*r)/(-s + Sqrt[4*r^3 + s^2])^(1/3)}, 
 {\[Sigma] -> -((1 - I*Sqrt[3])*(-Jminus)^(1/3))/2 + ((1 + I*Sqrt[3])*r)/
   (2^(2/3)*(-s + Sqrt[4*r^3 + s^2])^(1/3))}, 
 {\[Sigma] -> -((1 + I*Sqrt[3])*(-Jminus)^(1/3))/2 + ((1 - I*Sqrt[3])*r)/
   (2^(2/3)*(-s + Sqrt[4*r^3 + s^2])^(1/3))}}

which did make three substitutions in the result.

Notice that there are still three (2^(1/3)*r)/(-s + Sqrt[4*r^3 + s^2])^(1/3) in that result which were not replaced. That is because they were in a slightly different form than the replacement pattern I used and thus they were ignored.

See if you can use this technique to successfully make the two substitutions that you desire in your result.

$\endgroup$
0
$\begingroup$

Maybe it is not a good suggestion. This link provides a excellent function TermErsetzung.

Take the third solutions as example

sol = Solve[\[Sigma]^3 + 3 r \[Sigma] + s == 0, \[Sigma]];

sol[[3, 1, 2]] // TermErsetzung[Jplus == 1/2*(s + Sqrt[s^2 + 4 r^3]), s]

(*((1 - I Sqrt[3]) r)/(2 (Jplus - s)^(1/3)) - 1/2 (1 + I Sqrt[3]) (Jplus - s)^(1/3)*)

Noticed that there is still s and r, and both Jminus and Jplus is respect to r,s. So we can use Eliminate to eliminate the variable r,s respectively and substitute it into the expression.

Eliminate[{Jminus == 1/2*(s - Sqrt[s^2 + 4 r^3]), Jplus == 1/2*(s + Sqrt[s^2 + 4 r^3])}, r]

(*-Jminus + s == Jplus*)

sol2=((1 - I Sqrt[3]) r)/(2 (Jplus - s)^(1/3)) - 1/2 (1 + I Sqrt[3]) (Jplus - s)^(1/3) // TermErsetzung[-Jminus + s == Jplus, s]

(*-(1/2) (1 + I Sqrt[3]) (-Jminus)^(1/3) + ((1 - I Sqrt[3]) r)/(2 (-Jminus)^(1/3))*)

Noticed there is r remained,

Eliminate[{Jminus == 1/2*(s - Sqrt[s^2 + 4 r^3]), Jplus == 1/2*(s + Sqrt[s^2 + 4 r^3])}, s]
(*-r^3 == Jminus Jplus*)

sol2 /. r -> (-Jminus Jplus)^(1/3)

(*-(1/2) (1 + I Sqrt[3]) (-Jminus)^(1/3) + ((1 - I Sqrt[3]) (-Jminus Jplus)^(1/3))/(2 (-Jminus)^(1/3))*)
$\endgroup$

Your Answer

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

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