title: Mathematica, simplify equation with subsitutions
body: <p>There is the following formula:</p>
  
  <pre><code>s = R*(lat - lat0)
  rho = R/Tan[lat]
  f = (x^2 + (rho + s - y)^2 - rho^2)*(Sin[lat])^2
  </code></pre>
  
  <p>and its derivative</p>
  
  <pre><code>fd = D[f, lat]
  </code></pre>
  
  <p>where</p>
  
  <pre><code>Output[1] = 2 Cos[lat] (x^2 - R^2 Cot[lat]^2 + ((lat - lat0) R - y + R Cot[lat])^2) Sin[lat] + 
  (2 R^2 Cot[lat] Csc[lat]^2 + 2 ((lat - lat0) R - y + R Cot[lat]) (R - R Csc[lat]^2)) Sin[lat]^2
  </code></pre>
  
  <p>I would like to express fd using the substitutions of s, rho</p>
  
  <pre><code>FullSimplify[fd, TransformationFunctions -&gt; {Automatic, # /. R (lat - lat0) -&gt; s &amp;, # /. R/Tan[lat] -&gt; rho &amp;}]
  </code></pre>
  
  <p>However, only the simplified formula without any substitution appears:</p>
  
  <pre><code>Output[2] = 2 Cos[lat] ((1 + (lat - lat0)^2) R^2 + x^2 + 2 (-lat + lat0) R y +   y^2 + R (lat R - lat0 R - y) Cot[lat]) Sin[lat]
  </code></pre>
  
  <p>Thanks for your help.</p>