8
$\begingroup$

I have the following massive expression

A = ((8 - 2 Sqrt[(8 - 7 q) q] + q (-6 + 3 Sqrt[(8 - 7 q) q] + q (-17 + 12 q - 4 Sqrt[(8 - 7 q) q])))/Sqrt[(8 - 7 q) q] + (Sqrt[2] (24 + 2 Sqrt[(8 - 7 q) q] + q (-5 (10 + 3 Sqrt[(8 - 7 q) q]) + q (-95 + 7 Sqrt[(8 - 7 q) q] + q (323 - 196 q + 12 Sqrt[(8 - 7 q) q])))))/Sqrt[-q (-8 + 7 q) (2 + 2 Sqrt[(8 - 7 q) q] + q (-10 + 21 q - 7 Sqrt[(8 - 7 q) q]))])/(8 (-1 + q) (-1 + 2 q))

I have reason to believe that this is simply equal to

B =(4 - 16 q^2)/(3 q - 4 Sqrt[8 - 7 q] q^(3/2) + Sqrt[(8 - 7 q) q])

for $0 < q < 1/2$. Numerically, they agree to 100 digits and their plots look identical. My question is: how can I use FullSimplify (or the like) on the first expression to get something of the same complexity as the second expression? In other words, I'm more interested in simplifying the first expression than I am actually checking that it's equal to the second. I've tried modifying the complexity function to Composition[StringLength, ToString] but it doesn't really get there.

$\endgroup$
6
  • 2
    $\begingroup$ You mean how would we simplify if we didn't already know the simpler expression? $\endgroup$
    – Szabolcs
    Commented Sep 11, 2018 at 17:33
  • 2
    $\begingroup$ @Szabolcs Yes, exactly. I'm hoping to apply the simplification method to other expressions I have, where I don't have a good guess for the simpler form. $\endgroup$
    – Mr. G
    Commented Sep 11, 2018 at 17:36
  • 4
    $\begingroup$ Sometimes it's more productive to look at how the expression was derived, go back to the starting point, and try to write the starting point in a simpler form. E.g., identify common subexpressions such as Sqrt[(8-7q)q], and use a more compact notation (single letter) for them during the derivation. I find that manual derivations often give more insight than automated ones precisely because we tend to keep track of "meaningful subexpressions". $\endgroup$
    – Szabolcs
    Commented Sep 11, 2018 at 17:44
  • 1
    $\begingroup$ For what it's worth, FullSimplify[A == B, 0 < q < 1/2] returns True in seconds. $\endgroup$
    – bbgodfrey
    Commented Oct 2, 2018 at 4:52
  • 1
    $\begingroup$ ComplexityFunction -> cf, with cf[e_] := LeafCount[e] + 100 Count[e, Power[__, z_] /; z != -1, Infinity] does not help either. $\endgroup$
    – bbgodfrey
    Commented Oct 2, 2018 at 22:19

2 Answers 2

0
$\begingroup$

Use substitution of variables and let a = Sqrt[(8-7q)q]

Then there is an intermediate step of:

((8 - 2 a + q (-6 + 3 a + q (-17 + 12 q - 4 a)))/a + 
  (Sqrt[2] 
     (24 + 2 a + q (-5 (10 + 3 a) + q (-95 + 7 a + q (323 - 196 q + 12 a))))) / 
     Sqrt[-q (-8 + 7 q) (2 + 2 a + q (-10 + 21 q - 7 a))])/(8 (-1 + q) (-1 + 2 q))

You can then do more algebra.

Perhaps on your domain Sqrt[-q (-8 + 7 q)] will be related directly to a.

The remaining algebra can be done by those interested.

$\endgroup$
3
  • 1
    $\begingroup$ Did you mean to add something more to this post? $\endgroup$ Commented Sep 11, 2018 at 19:27
  • $\begingroup$ I edited the post to clarify. I think there are a number of further simplifications that can be made, but I just don't have time to do that right now. $\endgroup$ Commented Sep 11, 2018 at 19:31
  • 1
    $\begingroup$ This turned out to be essentially the solution; identify terms that show up often and replace them with something simpler. $\endgroup$
    – Mr. G
    Commented Jun 7, 2019 at 17:22
2
$\begingroup$

THIS IS AN EXTENDED COMMENT RATHER THAN AN ANSWER

A = ((8 - 2 Sqrt[(8 - 7 q) q] + 
        q (-6 + 3 Sqrt[(8 - 7 q) q] + q (-17 + 12 q - 4 Sqrt[(8 - 7 q) q])))/
      Sqrt[(8 - 7 q) q] + (Sqrt[
         2] (24 + 2 Sqrt[(8 - 7 q) q] + 
          q (-5 (10 + 3 Sqrt[(8 - 7 q) q]) + 
             q (-95 + 7 Sqrt[(8 - 7 q) q] + 
                q (323 - 196 q + 12 Sqrt[(8 - 7 q) q])))))/
      Sqrt[-q (-8 + 7 q) (2 + 2 Sqrt[(8 - 7 q) q] + 
          q (-10 + 21 q - 7 Sqrt[(8 - 7 q) q]))])/(8 (-1 + q) (-1 + 2 q));

B = (4 - 16 q^2)/(3 q - 4 Sqrt[8 - 7 q] q^(3/2) + Sqrt[(8 - 7 q) q]);

Both A and B have almost the same domain, differing only at q == 8/7

FunctionDomain[#, q] & /@ {A, B}

(* {0 < q < 1/2 || 1/2 < q < 1 || 1 < q < 8/7, 
    0 < q < 1/2 || 1/2 < q < 1 || 1 < q <= 8/7} *)

Plot[{A, B}, {q, 0, 8/7},
 Exclusions -> {0, 1/2, 1, 8/7},
 PlotStyle -> {Thick, Dashed},
 PlotPoints -> 200,
 PlotLegends -> Placed[{"A", "B"}, {.25, .2}]]

enter image description here

As seen in the plot above, A and B are equal in the restricted domain 0 < q < 1/2

A == B // FullSimplify[#, 0 < q < 1/2] &

(* True *)
$\endgroup$
2
  • 1
    $\begingroup$ I do not think that RootReduce does anything in this case. A === A2 yields True. Moreover, the Out forms of both look the same, even though the In forms doe not.. $\endgroup$
    – bbgodfrey
    Commented Oct 2, 2018 at 12:57
  • 1
    $\begingroup$ @bbgodfrey - Thanks. My mistake -- up too late last night. $\endgroup$
    – Bob Hanlon
    Commented Oct 2, 2018 at 14:45

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.