title: Targeted Simplify in Mathematica
body: <p>I generate very long and complex analytic expressions of the general form:</p>
  
  <pre><code>(...something not so complex...)(...ditto...)(...ditto...)...lots...
  </code></pre>
  
  <p>When I try to use <a href="http://documents.wolfram.com/mathematica/functions/Simplify" rel="nofollow noreferrer"><code>Simplify</code></a>, Mathematica grinds to a halt, I am assuming due to the fact that it tries to expand the brackets and or simplify across different brackets. The brackets, while containing long expressions, are easily simplified by Mathematica on their own. Is there some way I can limit the scope of <a href="http://documents.wolfram.com/mathematica/functions/Simplify" rel="nofollow noreferrer"><code>Simplify</code></a> to a single bracket at a time?</p>
  
  <p><strong>Edit:</strong> Some additional info and progress.</p>
  
  <p>So using the advice from you guys I have now started using something in the vein of</p>
  
  <pre><code>In[1]:= trouble = Log[(x + I y) (x - I y) + Sqrt[(a + I b) (a - I b)]];
  
  In[2]:= Replace[trouble, form_ /; (Head[form] == Times) :&gt; Simplify[form],{3}]
  
  Out[2]= Log[Sqrt[a^2 + b^2] + (x - I y) (x + I y)]
  </code></pre>
  
  <p>Changing <code>Times</code> to an appropriate head like <code>Plus</code> or <code>Power</code> makes it possible to target the simplification quite accurately. The problem / question that remains, though, is the following: <a href="http://documents.wolfram.com/mathematica/functions/Simplify" rel="nofollow noreferrer"><code>Simplify</code></a> will still descend deeper than the level specified to <a href="http://documents.wolfram.com/mathematica/functions/Replace" rel="nofollow noreferrer"><code>Replace</code></a>, e.g.</p>
  
  <pre><code>In[3]:= Replace[trouble, form_ /; (Head[form] == Plus) :&gt; Simplify[form], {1}]
  
  Out[3]= Log[Sqrt[a^2 + b^2] + x^2 + y^2]
  </code></pre>
  
  <p>simplifies the square root as well.</p>
  
  <p>My plan was to iteratively use <a href="http://documents.wolfram.com/mathematica/functions/Replace" rel="nofollow noreferrer"><code>Replace</code></a> from the bottom up one level at a time, but this clearly will result in vast amount of repeated work by <a href="http://documents.wolfram.com/mathematica/functions/Simplify" rel="nofollow noreferrer"><code>Simplify</code></a> and ultimately result in the exact same bogging down of Mathematica I experienced in the outset. Is there a way to restrict <a href="http://documents.wolfram.com/mathematica/functions/Simplify" rel="nofollow noreferrer"><code>Simplify</code></a> to a certain level(s)?</p>
  
  <p>I realize that this sort of restriction may not produce optimal results, but the idea here is getting something that is "good enough".</p>