# Mathematica cannot compile complex-valued interpolated PDE coefficients? (NDSolve, Finite Elements)

Bug introduced in 11.1 or earlier, fixed in 11.3 or earlier.

The following PDE

pde = I Cos[x y] D[u[x, y], x] + Laplacian[u[x, y], {x, y}] == 0;


Is happily solved by

NDSolve[{pde,
DirichletCondition[u[x, y] == Cos[x y], True]}, u, {x, 0, 1}, {y, 0,
1}]


However, if I set up the advection coefficient using interpolation, things go askew:

Needs["NDSolveFEM"]
R = ImplicitRegion[0 <= x <= 1 && 0 <= y <= 1, {x, y}];
mesh = ToElementMesh[R];
coords = mesh["Coordinates"];
CosA = ElementMeshInterpolation[{mesh},
Table[{xi, yi} = coords[[i]];
Cos[xi yi], {i, 1, Length[coords]}]];
pde = I CosA[x, y] D[u[x, y], x] + Laplacian[u[x, y], {x, y}] == 0;
NDSolve[{pde,
DirichletCondition[u[x, y] == Cos[x y], True]}, u, {x, 0, 1}, {y, 0,
1}]


Mathematica issues the complaint CompiledFunction::cfex --

CompiledFunction: Could not complete external evaluation at instruction 10; proceeding with uncompiled evaluation.

Though the answer is ultimately obtained, the behavior is curious to me. (Also, I need the speedup that comes with compiling.)

Note that the problem is not due to interpolation alone, e.g. one can drop the I,

pde = CosA[x, y] D[u[x, y], x] + Laplacian[u[x, y], {x, y}] == 0;


and compilation works. The issue, as far as I can tell, involves the special imaginary-interpolated combination. Two questions:

1. Why this behavior?
2. Is there a workaround?
• I cannot reproduce the error with Mathematica version 12.0. Please restart you kernel. Maybe there was some definition lingering around in some symbol. Jun 12 '19 at 12:01
• What version are you using? This works fine in 11.3 and 12.0. Jun 12 '19 at 12:13
• @user21 and Henrick Shumacher, I'm using 11.1.1.0. I'll upgrade and report back. Jun 12 '19 at 13:38
• @HenrikSchumacher thanks for the code edit. Jun 12 '19 at 13:43
• Did you get a chance to test this? Jun 14 '19 at 5:21