title: How do I create an abstract function that has a given derivative in Sage?
body: <p>I want to have abstract $f$ function that has a given derivative. But, when I try to substitute it to  D[0](f)(t), Sage says:</p>
  
  <pre><code>NameError: name 'D' is not defined
  
  
  
      R.&lt;t,u1,u2&gt; = PolynomialRing(RR,3,'t' 'u1' 'u2') 
      tmp1 = r1*k1*u1-(r1/k1)*k1^2*u1^2-r1*b12/k1*k1*u1*k2*u2
  
      f=function('f',t)
      a=diff(f)
      a.substitute_expression((D[0](f)(t))==tmp1)
  </code></pre>
  
  <p>tmp1.integral() won't do the job. I also can't substitute the integral, although it gives no warning.</p>
  
  <pre><code>%var u10, u20,r1,r2,k1,k2,b12,b21,t
  u1=function('u1',t)
  u2=function('u2',t)
  tmp1 = r1*k1*u1-(r1/k1)*k1^2*u1^2-r1*b12/k1*k1*u1*k2*u2
  tmp2 = r2*u2*k2-r2/k2*k2^2*u2^2-((r2*b21)/k2)*u1*u2*k1*k2    
  v1=integral(tmp1,t)
  v2=integral(tmp2,t)
  sep1=tmp1.substitute_expression(u1==v1,u2==v2)
  sep2=tmp2.substitute_expression(u1==v1,u2==v2)
  trial=diff(sep1,t)
  trial.substitute_expression((integrate(-b12*k2*r1*u1(t)*u2(t) - k1*r1*u1(t)^2 +    k1*r1*u1(t), t))==v1,  (integrate(-b12*k2*r1*u1(t)*u2(t) - k1*r1*u1(t)^2 + k1*r1*u1(t), t))==v2)
  </code></pre>
  
  <p>Now let's go back to original version:</p>
  
  <pre><code>d1=diff(tmp1,t)
  d1.substitute_function((D[0](u1)(t)),tmp1)
  
  
  
  Error in lines 13-13
  Traceback (most recent call last):
    File "/projects/b501d31c-1f5d-48aa-bee3-73a2dcb30a39/.sagemathcloud/sage_server.py", line 733, in execute
      exec compile(block+'\n', '', 'single') in namespace, locals
   File "", line 1, in &lt;module&gt;
  NameError: name 'D' is not defined
  </code></pre>