# Why is C-compiled (but not WVM-compiled) code so slow in Manipulate?

Here is a small section of code from this SE question which computes the real part of the dilogarithm (the upper limit of the sum is increased for demonstration purposes):

realRegion1 = Compile[{{x, _Real}}, Sum[x^k/k^2, {k, 1., 1000}]];


Here is the performance when compiled to the Wolfram Virtual Machine (WVM):

(* to WVM *)
Timing[Table[realRegion1[x], {x, -.9, .9, .001}];]


{0.260303, Null}

and the performance when compiled to C (which I get by running $CompilationTarget = "C" before running the realRegion1 code): (*to C*) Timing[Table[realRegion1[x], {x, -.9, .9, .001}];]  {0.096413, Null} Now I run into a big problem when I pass the compiled function realRegion1[x] to Manipulate. As an example, try Manipulate[Plot[realRegion1[a x], {x, -1, 1}, PlotRange -> {-1, 2.0}], {{a, 1}, .1, 1}]  If the function was complied to WVM, the controls are as slick as butter. But, if the function was compiled to C, they are very unresponsive. I am upset. How do I understand/alleviate this sluggishness when compiled to C? I am using Mathematica 9.0.1 on Mac OSX. • Very likely because you're passing symbolic arguments to the function (a x). Try Evaluated -> False in Plot. – Szabolcs Dec 17 '14 at 22:57 • Quite interesting. The reason is exactly your special setting $CompilationTarget = "C", and the problem won't appear if CompilationTarget -> "C" is used! Don't why though……BTW, the solution from @Szabolcs also works. – xzczd Dec 18 '14 at 6:02
• @Szabolcs Setting the option Evaluated->False does make it more responsive. I'm trying to find more info on this option, but the documentation doesn't seem to exist. Do you know where I can find more information? – QuantumDot Dec 18 '14 at 15:06

realRegion1a[x_Real] := realRegion1[x]

And the try your Manipulate using that new function. It will behave as expected.