xzczd
Reputation
Next privilege 10,000 Rep.
Access moderator tools
 Apr9 comment How can i subtract a surface from another 那啥，同学，我姑且确认一下，你知道上面那条Standard Welcome里的 accept the answer 指的是啥吗？ Apr8 comment Compile, “global variables” and recursion But this still calls MainEvaluate…… Apr5 comment How to speed up auxilary DoolittleDecomposite function? Well, I'm not that familiar with the internal mechanism, either, but the CompileGetElement trick does work, at least on my machine. Apr4 comment How to speed up auxilary DoolittleDecomposite function? For the reason why CompileGetElement is fast, it's mentioned here that it turns off the bound check. Apr4 comment How to speed up auxilary DoolittleDecomposite function? Maybe it's due to the compiler? I use TDM-GCC 4.8.1, with "CompileOptions"->"-Ofast", and this is my implementation: doolittleDecomposition2 = With[{g = CompileGetElement}, Compile[{{a, _Real, 2}}, With[{n = Length[a]}, Module[{t = a}, Do[Do[Do[ t[[i, j]] -= g[t, i, k] g[t, k, j];, {k, 1, i - 1}];, {j, i, n}]; Do[Do[t[[j, i]] -= g[t, j, k] g[t, k, i];, {k, 1, i - 1}]; t[[j, i]] /= g[t, i, i];, {j, i + 1, n}];, {i, 1, n}]; t]], RuntimeOptions -> "Speed", CompilationTarget -> "C"]]. Apr4 comment How to speed up auxilary DoolittleDecomposite function? You can use CompileGetElement to speed up doolittleDecomposition by a factor of 2. (See here for an example. ) Apr3 comment Backslide of Limit @MichaelE2 Yeah, I know, I just feel obligated to remind all the people who take part in the discussion for the correctness of v8 :) Apr3 comment Backslide of Limit @MichaelE2 I added a step-by-step proof, have a look. Apr3 comment Backslide of Limit I'm sorry but the answer given by v8 is undoubtedly correct. See my edit for the step-by step proof. @blochwave Apr3 comment Poisson PDE over a irregular region with FDM @wlkyr It's just because I didn't use the original coordinate. Map it back if you like. Apr2 comment NIntegrate over a list of functions I think it'll be better if you can add some screenshots etc. to illustrate the speed difference. Apr2 comment Backslide of Limit BTW the Hold-ReleaseHold approach also works in v8.0.4, I feel it really surprising: In this case Limit[Hold[Sum[Sin[Pi*k/n]/(n + 1/k), {k, 1, n}]], n -> Infinity] returns Hold[2/π] i.e. Hold doesn't hold the expression! Quite unusual! Apr2 comment Backslide of Limit @2012rcampion V8 can handle the finite summation: i.stack.imgur.com/urNrR.png Apr1 comment Compile, “global variables” and recursion Quite interesting! BTW, the code can be simplified to LevelsNeeded = Compile[{{b, _Integer}, {M, _Integer}, {x, _Integer}}, If[M <= (x*b + Quotient[x (x - 1), 2]), x, LevelsNeeded[b, M, x + 1]], {{_LevelsNeeded, _Integer}}, CompilationOptions -> {"InlineExternalDefinitions" -> True}, CompilationTarget -> C];. Apr1 comment Compile, “global variables” and recursion As far as I know, so far it's not possible to define a recursive compiled function. (This question is slightly related.) I hope I'm wrong. Apr1 comment 4th-order Runge-Kutta method to solve a system of coupled ODEs @Prasanta If I correctly understood those material I found, RK4 i.e. classical RK doesn't have an error estimator. Notice the document also gives a example for a fourth order RK called Fehlberg method, which owns an error estimator and can find the singularity at 0.9576. Apr1 comment Poisson PDE in a rectangular domain "I would like it for any geometry" - 如果这就是你的终级目标的话，那么，我在你的第一个问题里给出的代码本来就是适用于任何二维直角坐标系下的泊松方程的，你只需要把开头用于指定区域的部分稍微改改就行——‌​‌​‌​你要是看不懂我的答案那你完全可以在下面追问。Translation: If this is your ultimate goal, then the code in my answer for your first question is completely suited for the task, you just need to modify the part defining the region i.e. rulei and ruleo. If you have any difficulty in understanding, feel free to continue to ask in the comment under my answer. Mar29 comment 4th-order Runge-Kutta method to solve a system of coupled ODEs @Prasanta NDSolve does stop at 0.9576, but have you noticed that it begins from 1 because your initial condition is given at η = 1? BTW, what's your first language? Mar29 comment 4th-order Runge-Kutta method to solve a system of coupled ODEs @Prasanta Since I'm the author of this post, you don't need to add "@xzczd" to remind me. In my view the most vital part of your problem is, you haven't even find a way to solve your nonlinear ODE. It's easy to create nonlinear ODE, but solving it can be really hard. I suggest you to first make sure if your equations are correct (incorrect translation for the real problem isn't rare!), and consider carefully if you really need your equations to be so complicated. Simplify your model if possible. Diving into the hell of looking for proper combination of options of NDSolve is the last choice. Mar28 comment 4th-order Runge-Kutta method to solve a system of coupled ODEs If RunnyKine doesn't appear in the comment under this question, then the "@" won't work. And why are you still adding whitespace between "@" and the name?