# Simplifying expressions with square roots

I would like Mathematica to simplify this expression:

$4 \left(16 \sqrt{\left(-1+2 c^2\right)^2}-32 c^2 \sqrt{\left(-1+2 c^2\right)^2}+\sqrt{\left(1-8 c^2+8 c^4\right)^2}\right)^2$

expression = 4*( 16*Sqrt[(-1 + 2*c^2)^2] - 32*c^2*Sqrt[(-1 + 2*c^2)^2]
+ Sqrt[(1 - 8*c^2 + 8*c^4)^2])^2;


I have tried

PowerExpand[expression]

FullSimplify[expression]


but they did not simplify expression.

-
are you assuming that c is Real and did you tell Mathematica that? –  bobthechemist Jul 28 '13 at 2:07

We should exploit the second argument in Simplify or FullSimplify being an assumption on possible variables or symbols in a given axpression. For more complete discussion of simplification methods see the answers to this question What is the difference between a few simplification techniques?.

One should have consider a few cases since we could use various assumptions. Let's start with plotting graphs of polynomial functions apprearing in the expression. We'd like to distinguish cases where 1 - 8 c^2 + 8 c^4 and 1 - 2 c^2 are non-negative.

Plot[{ 1 - 8 c^2 + 8 c^4, 1 - 2 c^2}, {c, -4/3, 4/3},
PlotLegends -> "Expressions", PlotStyle -> Thick]


There are two independent terms which can be simplified in different ways with respect to assumptions given, e.g.

Simplify[ Sqrt[(-1 + 2 c^2)^2], #]& /@ {-(1/Sqrt[2]) < c < 1/Sqrt[2], 1/Sqrt[2] < c} //
Column

 1 - 2 c^2
-1 + 2 c^2


We shouldn't impose accidental assumptions since expressions couldn't be simplified to the simplest form (appropriate assumptions for the first term, in general will not be adequate for the other one), e.g.

Simplify[ expression, #] & /@ {-(1/Sqrt[2]) < c < 1/Sqrt[2], 1/Sqrt[2] < c} // Column

4 ( 16 (1 - 2 c^2)^2 + Abs[1 - 8 c^2 + 8 c^4])^2
4 (-16 (1 - 2 c^2)^2 + Abs[1 - 8 c^2 + 8 c^4])^2


Here Sqrt[(1 - 8 c^2 + 8 c^4)^2] could be simplified only to Abs[1 - 8 c^2 + 8 c^4] since it is the most general (and the simplest) form satisfying imposed assumptions.

Now, in order to complete simplification we need to deal with Reduce for writing down different assumptions:

Grid[(cs = Table[ Reduce[ g[1 - 8 c^2 + 8 c^4, 0] && h[1 - 2 c^2, 0], c],
{g, {GreaterEqual, Less}}, {h, {GreaterEqual, Less}}]),


and the simplifications are respectively:

Grid[ Map[ Simplify[ 4(16Sqrt[(-1 + 2c^2)^2] - 32c^2 Sqrt[(-1 + 2 c^2)^2] +
Sqrt[(1 - 8c^2 + 8c^4)^2])^2, #] &, cs, {2}],


In general for more involved expressions one should deal with FullSimplify, nevertheless we get in our case the same expressions with Simplify.

-
Very useful stuff. I need you in my corner if I ever return to Project Euler problems. :-) –  Mr.Wizard Jul 29 '13 at 14:57

The simplification that I think you are looking for only works if you tell Mathematica to assume c is real. Try

Simplify[4*(16*Sqrt[(-1 + 2*c^2)^2] -
32*c^2*Sqrt[(-1 + 2*c^2)^2] +
Sqrt[(1 - 8*c^2 + 8*c^4)^2])^2,
c ∈ Reals]


4 ((16 - 32 c^2) Abs[1 - 2 c^2] + Abs[1 - 8 c^2 + 8 c^4])^2

-

What result do you want to achieve?

Input #1:

Expand[4*(16*Abs[A] - 32*c^2*Abs[A] + Abs[B])^2]


Output #1:

1024 Abs[A]^2 - 4096 c^2 Abs[A]^2 + 4096 c^4 Abs[A]^2 +
128 Abs[A] Abs[B] - 256 c^2 Abs[A] Abs[B] + 4 Abs[B]^2


Input #2:

% /. {A -> (-1 + 2*c^2), B -> (1 - 8*c^2 + 8*c^4)}


Output #2:

1024 Abs[-1 + 2 c^2]^2 - 4096 c^2 Abs[-1 + 2 c^2]^2 +
4096 c^4 Abs[-1 + 2 c^2]^2 +
128 Abs[-1 + 2 c^2] Abs[1 - 8 c^2 + 8 c^4] -
256 c^2 Abs[-1 + 2 c^2] Abs[1 - 8 c^2 + 8 c^4] +
4 Abs[1 - 8 c^2 + 8 c^4]^2

-
Please, refer to the help center for good formatting practices: link –  Sektor Jul 28 '13 at 11:01
@NikolaDimitrov - even members with less rep can format posts. Edits need to be approved if you have less than 2000 rep, but everyone can pitch in. –  Verbeia Jul 28 '13 at 13:54
@Verbeia Wha ? I was just suggesting that he needs to format his code/posts. –  Sektor Jul 28 '13 at 14:06
@Nikola Dimitrov,Thanks to your guide.I come from China,English is not my mother tongue.So I must learn gradually. –  tangshutao Jul 28 '13 at 15:29
@NikolaDimitrov Verbeia was referring to the flag you sent. Only the moderators see the flags, so the OP/others are unaware of it :) If it needs formatting, you needn't let us know. You can just submit an edit and we will review and approve it. You can certainly let the OP know (as you've done), and it's good to educate them as well. Btw, thanks for all the editing you've been doing recently! We appreciate it. –  rm -rf Jul 28 '13 at 16:02
show 1 more comment