# Solving PDE numerically with variable coefficient term

The following PDE yields two different numerical solutions (e.g. Matlab) although I have just divided by the (variable) coefficient term on the lhs:

(1) $\alpha \cdot \beta \cdot a^{\beta - 1} \frac{\partial a}{\partial t} = D \cdot \frac{\partial a^{2}}{\partial^{2} x}$

(2) $\frac{\partial a}{\partial t} = \frac{D}{\alpha \cdot \beta \cdot a^{\beta - 1}} \cdot \frac{\partial a^{2}}{\partial^{2} x}$

I solve this with Matlabs pdepe (m=2) by defining the inner function in two ways, res:

 function [c,f,s] = pdefun(z,t,u,dudz)
c = alpha*beta*(a^(beta-1));
f = D*dudz;
s = 0;
end

function [c,f,s] = pdefun(z,t,u,dudz)
c = 1;
f = D/(alpha*beta*(a^(beta-1)))*dudz;
s = 0;
end


The rest of the code in the pdepe remains unchanged, including the initial- and boundary conditions. As mentioned, the above produced two different numerical solutions but I would think it is legit to divide by a coefficient term, but maybe it is because it contains the variable a itself? If so, why?

Regards, Peter

• Depends on the methods used, which you haven't specified. Note that the first one is in "implicit form" while the second is in "explicit form" (since your so-called "coefficient" in fact depends on $a$) so technically you shouldn't be able to feed them to the same solvers in the first place. – Ian Apr 1 '17 at 11:47
• It is difficult to answer your question if we don't have the code. – MrYouMath Apr 1 '17 at 11:51
• Thanks for the reply, Ian. Can you elaborate your two points, e.g. the difference between the solution when using implicit- and explicit form? Also, I have edited my post to make it more clear how i solve it in matlab using pdepe. – Peter Alexander Apr 1 '17 at 14:08
• The f term expected in pdepe does not work like you think it does. You have (with m=0) $\frac{\partial}{\partial x} \left (f \left (x,t,u,\frac{\partial u}{\partial x} \right ) \right )$. That is, $f$ itself will be differentiated with respect to $x$ again, which in the second version will produce undesirable cross terms. – Ian Apr 2 '17 at 5:38
• Also, in view of how that works, you should be using m=0, not m=2, for your DE. – Ian Apr 2 '17 at 19:31