# Numerical integration given a derivative of a function of two dependent variables

I want to solve the following equation of an integral valued function:

$Q = \int_{0}^{x_p}f(t_p,x)dx$

for some particular $x_p$ at a fixed time $t_p$, given some known $Q$ and an initial $f(0,x)$. Furthermore, I know the derivative of $f$ with respect to $t$, which is a function of $f$ itself; that is, $\frac{\partial{f}}{\partial{t}} = f(t,x)*g(t,x)$.

How would I go about doing this numerically? I understand that it requires evolving $f$ from time 0 to time $t_p$ and then using a numerical integration technique to solve the equation; what are some specific numerical techniques I could use for both steps?

-

## 2 Answers

Well you can actually solve for $f(x,t)$ as you're ODE is actually a separable differential equation. Since the $x's$ don't appear as derivatives anywhere, think of them as suppressed parameters. In which case you have

$$f'(t) = f(t)g(t) \quad \Rightarrow f(x,t) = f(x,0) \exp\left(\int_0^{t}g(t',x)\,dt'\right)$$

Now, I'm not sure what you actually want to solve for here. Basically, you'll get some 2-dimensional curve in your parameter space consisting of $(x_p,t_p,Q)$. One variable being a function of the others. Could you be a little bit more specific?

-
Reading you're above comment, this shouldn't be too bad to do. You're basically trying to solve for the roots of $F(x_p) = 0$. Code up the analytical evaluation of $f(x,t)$ as a mapping, accepting $x,t$ as inputs and returning $f(x,t)$. Then code up $G(y) = \int_0^{y} f(t_p,x)\,dx$ as a separate mapping using $y$ as an input and returning $G(y)$. Then all that remains is finding the roots of the equation $G(y) - Q = 0$ – Wil. May 26 '12 at 4:58
Thanks! This is very helpful. However, is there a better way to solve the integral valued equation? Putting the question into a greater context, I need to solve this problem for a very large range of possible $y$ values, so this would require a lot of numerical integrals, one for every $y$ value at every time $t_p$. I guess what I'm asking is, is there a faster numerical method for solving an integral valued equation? – Kurt May 26 '12 at 18:27

You said you know the derivative of f? But it kinda looks like the Leibniz derivative of an integral (I would have to double check, as I'm probably wrong). What SPECIFICALLY do you want to compute? Do you want Q? Are you given Q and want its derivative? Do you want the derivative of f with respect to t? Sorry, I'm just not 100% sure what you want/have. Cool?

-
Sorry, I should try to be more clear! I'm trying to solve the integral valued function "Q = integral above" for x_p. I know: Q, t_p and f(0,x), which specifically is in the form of a vector (x1,x2,x3). I also know the derivative of f with respect to t, which is some function of t and x, and coincidentally also recovers f. I don't know if this is important, since I'm trying to solve it numerically might as well just call the product of f and g as some function g(t,x). So: I need some numerical method to evolve f(t,x) from f(0,x) to find f(t_p,x), and then I need to solve the "Q eq" for x_p. – Kurt May 26 '12 at 4:46