title: Java - Computation of Derivations with Apache Commons Mathematic Library
body: <p>I have a problem in using the apache commons math library.<br>
  I just want to create functions like f(x) = 4x^2 + 2x and I want to compute the derivative of this function <br> --> f'(x) = 8x + 2 <br></p>
  
  <p>I read the article about Differentiation (<a href="http://commons.apache.org/proper/commons-math/userguide/analysis.html" rel="nofollow">http://commons.apache.org/proper/commons-math/userguide/analysis.html</a>, section 4.7). <br>
  There is an example which I don't understand:</p>
  
  <pre><code>int params = 1;
  int order = 3;
  double xRealValue = 2.5;
  DerivativeStructure x = new DerivativeStructure(params, order, 0, xRealValue);
  DerivativeStructure y = f(x);                    //COMPILE ERROR
  System.out.println("y    = " + y.getValue();
  System.out.println("y'   = " + y.getPartialDerivative(1);
  System.out.println("y''  = " + y.getPartialDerivative(2);
  System.out.println("y''' = " + y.getPartialDerivative(3);
  </code></pre>
  
  <p>In Line 5 a compile error occurs of course. The function <code>f(x)</code> is called and not defined. What I am getting wrong? <br>
  Has anyone any experience with the differentiation/derivation with the apache commons math library or does anyone know another library/framework which can help me?</p>
  
  <p>Thanks</p>