title: integrating a function with multiple variables
body: <p>I am new to R and need some help using integration.
  I have a function defined as:  </p>
  
  <pre><code>a &lt;- function(t) { exp(-r1*t) }
  </code></pre>
  
  <p>I have another function which uses this function and is defined as:</p>
  
  <pre><code>b &lt;- function(t,x) { a(t-x)* exp(-(1-exp(-r2*x))) }
  </code></pre>
  
  <p>where, <code>r1</code> and <code>r2</code> are constants.</p>
  
  <p>Now, I need to integrate the function <code>b(t,x)</code> for values of <code>x</code> that range from <code>0</code> to <code>t</code>; given that <code>x &lt;= t</code>.</p>
  
  <p>I am not sure how to proceed with this. I tried the following, but I am not sure how to tell R to integrate over 'x' and not 't'.  </p>
  
  <pre><code>c &lt;- integrate(b, lower=0, upper=10)
  </code></pre>
  
  <p>When i run this, I get an error saying:  </p>
  
  <blockquote>
    <p>Error in a(t -x) : argument "t" is missing, with no default</p>
  </blockquote>
  
  <p>Thanks in advance,<br>
  -S</p>