# Integrate on a grid of multiple variables

This is a numerical analysis problem that I should know the answer to, but for some reason, I am all over the shop...

I have a grid of $\rho$ and $T$ values, with $\rho > 0$ and $T \ge 0$. At each grid point I have values for the functions $e(\rho,T)$ and $p(\rho,T)$.

I need to calculate a third value $S(\rho,T)$ at every grid point, where $S$ satisfies:

$\text{d}e = T\text{d}S + \frac{p}{\rho^2}\text{d}\rho;\ \ \ S(\rho,0) = 0$

My approach so far has been:

$\int_A^B \text{d}S = \int_A^B \frac{1}{T} \text{d}e - \int_A^B \frac{p}{\rho^2T} \text{d}\rho$

and then computing this numerically, but it is not giving me sensible answers. Any thoughts?

EDIT: The equation is the second law of thermodynamics, where $e$ is internal energy, $T$ is temperature, $\rho$ is density, $p$ is pressure and $S$ is entropy.

-
$df = ydh + \frac{g}{x^2}dx$ is not a thing that makes any sense to me. –  Arkamis Nov 1 '12 at 16:07
I don't understand, what is $S$? –  gt6989b Nov 1 '12 at 16:08
@EdGorcenski The equation is the second law of thermodynamics. Updated variables to make this clear. –  BrT Nov 1 '12 at 16:22

$\int_A^B f(s)dS$ means that we integrate $f$ as $S$ ranges over the interval $[A,B]$. You cannot simply apply the same integration limits to the other independent variables; i.e., if $\int_A^B dS$ is valid, then $\int_A^B \frac{1}{T} de$ means that $e$ ranges from $S=A$ to $S=B$, which doesn't generally make sense.
You want to compute $S(\rho,T)$, but you cannot obtain that form explicitly. Instead, you need to employ the chain rule, and instead compute $S(p(\rho,T),e(\rho,T))$ via the Jacobian matrix $S'$.