12
$\begingroup$

Consider the following statement:

Max[0, Sqrt[1 - Cos[4 \[Theta]]]]

You'll find that Mathematica won't evaluate this, because it doesn't know the range of $\theta$. Okay, that makes sense, so change it to:

Simplify[Max[0, Sqrt[1 - Cos[4 \[Theta]]]], {0 <= \[Theta] <= 2 \[Pi]}]

This evaluates happily. As it should. But then consider this not-impactful adjustment:

Simplify[Max[0, Sqrt[1 - Cos[4 \[Theta]]]/
  Sqrt[2]], {0 <= \[Theta] <= 2 \[Pi]}]

This doesn't evaluate. I don't know why; because it seems quite obvious that it should be exactly the same as the previous case, right? (The constant factor of 1/Sqrt[2] can't change the fact that it is still $\geq 0$). Any thoughts on how to fix this? Of course, in my case I want to actually keep the Max ..., but I don't know the exact form of the other side, so I can't just arbitrarily remove constants ...

$\endgroup$
4
  • 1
    $\begingroup$ Simplify[Max[0, Simplify[Sqrt[1 - Cos[4 \[Theta]]]/Sqrt[2]]], {0 <= \[Theta] <= 2 \[Pi]}] seems to work. $\endgroup$
    – Yves Klett
    Sep 26 '12 at 7:11
  • $\begingroup$ ...and what happens if you use FullSimplify[] instead? $\endgroup$
    – J. M.'s torpor
    Sep 26 '12 at 7:14
  • $\begingroup$ Thanks for the Accept, but I encourage all users to wait 24 hours before Accepting as answer so that other users have a chance to read and answer the question before it appears concluded. Quick Accepts may prevent the posting of other, potentially better answers. $\endgroup$
    – Mr.Wizard
    Sep 26 '12 at 7:20
  • $\begingroup$ Thanks @Mr.Wizard; I did try and un-accept yesterday, but for some reason actions on this site occasionally don't work (like voting and commenting.) $\endgroup$
    – Noon Silk
    Sep 26 '12 at 22:15
11
$\begingroup$

There are many potential simplifications that Simplify and FullSimplify do not make, presumably because they are deemed too costly to attempt.

In this case it appears that parts are at too deep a level for the required simplifications to be made:

expr = Max[0, Sqrt[1 - Cos[4 t]]/Sqrt[2]];
simp = FullSimplify[#, {0 <= t <= 2 Pi}] &;

simp @ expr
Max[0, 1/Sqrt[Csc[2 t]^2]]

If you apply the simplification function to all the subexpressions further transformations are made:

simp //@ expr
Abs[Sin[2 t]]
$\endgroup$
9
  • $\begingroup$ Nice, a very rare occurrence of MapAll! $\endgroup$ Sep 26 '12 at 7:16
  • $\begingroup$ Indeed, MapAll[] is always a good idea when simplifying tricky things. $\endgroup$
    – J. M.'s torpor
    Sep 26 '12 at 7:18
  • 1
    $\begingroup$ Funny enough, your solution does not work with Simplify, but the less specific (and inferior) Simplify[Max[0, Simplify[Sqrt[1 - Cos[4 \[Theta]]]/Sqrt[2]]], {0 <= \[Theta] <= 2 \[Pi]}] does? $\endgroup$
    – Yves Klett
    Sep 26 '12 at 7:22
  • 1
    $\begingroup$ @Yves I am not surprised; there is a large element of chance involved in this and I certainly do not mean to imply that //@ is a panacea -- far from it in fact. It only so happens that it produces the needed string of transformations in this case. Search MathGroup for VOISimplify for a good illustration of the order dependence of Simplify that often manifests as apparent capriciousness. $\endgroup$
    – Mr.Wizard
    Sep 26 '12 at 7:36
  • 4
    $\begingroup$ An insightful statement by Andrzej Kozlowski in that thread: ... there are just too many different groupings and rearrangements that would have to be tried to get to a simpler form. Moreover, Mathematica will only apply a transformation if it immediately leads to a decrease in complexity. Sometimes the only way to transform an expression to a simpler form is by first transforming it to a more complex one ... $\endgroup$
    – Mr.Wizard
    Sep 26 '12 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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