There's a symbolic matrix as the following. Why does the integration of the symbolic matrix slow down after compilation? How to eliminate the error information in red? Thanks.
Note: The sample matrix has been simplified for the convenience of expression, in practice, it's very complex.
Figure:
Codes:
m1[z_] := {{1, z}, {2*z, z^2}};
Integrate[m1[z], {z, 0, 1}] // AbsoluteTiming
(Out[21]= {0.0001278, {{1, 1/2}, {1, 1/3}}})
m2 = Compile[{{z, _Real}}, Evaluate@m1[z]];
Integrate[m2[z], {z, 0, 1}] // AbsoluteTiming
(During evaluation of In[22]:= CompiledFunction::cfsa: Argument z at position 1 should be a machine-size real number.)
(Out[23]= {0.0011614, {{1, 1/2}, {1, 1/3}}})

m2[z]is evaluated, it can't use the compiled version, sincezis not a number. As for your other question: Can you give a bit more details on the task you are trying to accomplish? For this specific function, I see no reason why you would want to ever integrate the compiled function, since you can trivially get an analytic solution, which you can then evaluate more quickly than the numeric integration could ever be. – Lukas Lang Jun 17 '21 at 15:21f2[x_?NumericQ,…]:=…definition prevents the compiled function from seeing the symbolic arguments. And in the second one, it is in fact included in the code output in the question. – Lukas Lang Jun 18 '21 at 08:25