title: derivative of a function
body: <p>I am using D to get derivatives of a function. However, R does not simplify the expression when returning the derivative. I need to figure out if a function has a derivative that can be expressed generically. Is there some way in R to simplify the expression?</p>
  
  <pre><code>&gt; D(expression(sqrt(1 - x^2)), 'x')
  -(0.5 * (2 * x * (1 - x^2)^-0.5))
  &gt; D(D(expression(sqrt(1 - x^2)), 'x'), 'x')
  -(0.5 * (2 * (1 - x^2)^-0.5 - 2 * x * (-0.5 * (2 * x * (1 - x^2)^-1.5))))
  </code></pre>
  
  <p>Secondly, is there a way in R to do numerical integration?</p>