title: How to replace implicit subexpressions in Mathematica?
body: <p>I have this expression in Mathematica:</p>
  
  <pre><code>(a^2 (alpha + beta)^2)/(b^2 + c^2) + (a (alpha + beta))/(b^2 + c^2) + 1  
  </code></pre>
  
  <p>As you can see, the expression has a couple of subexpressions that repeat throughout it.</p>
  
  <p>I want to be able to replace <code>a/(b^2+c^2)</code> with <code>d</code> and <code>alpha+beta</code> with <code>gamma</code>.</p>
  
  <p>The final expression should then be:</p>
  
  <pre><code>1+d*gamma+a*d*gamma^2
  </code></pre>
  
  <p>I have much more complicated expressions where being able to do this would greatly simplify my work.</p>
  
  <p>I have tried Googling this question, and I only find answers that use FactorTerms and ReplaceRepeated, but do not work consistently and for a more complicated expression like this one. I am hoping that someone here has the answer. </p>