4,337 reputation
2947
bio website
location China
age
visits member for 2 years, 3 months
seen 2 days ago

Feel free to correct the grammar mistakes in my posts.


2d
comment Aligning the axeslabel in a 3D list plot ($x,y,z$) (edited)?
@AlexeyPopkov Oh, I didn't know this function! Added.
Oct
28
comment Division by zero is slow
The trick will fail when c and d are using different masks. (Block won't help because the FullForm of the output of ComplexInfinity generated by 1/0 etc. is DirectedInfinity[].) Anyway, it's the fastest method for OP's specific example so far.
Oct
28
comment Second order differential equation with boundary conditions solving repeatedly
If you simply want to make the code elegant, have a look at Do, While, Nest, NestWhile etc. Nevertheless, I'm afraid it's hard to speed up the code if you want dd[x] to be analytic. BTW, shouldn't the phi[x] phi[t] be phi[x]^2?
Oct
28
comment Solving Differential Algebraic Equations as BVP
@VenkatKV You can also consider using RootSearch. BTW, you can click the checkmark sign to accept it if satisfied with an answer.
Oct
25
comment Solving Differential Algebraic Equations as BVP
@VenkatKV No, it's just the StandardForm of ==. (Notice its length. ) Which version of Mathematica are you using? What's your platform? I'm using v9.0.1, vista 32bit. You can try narrowing down the scope of FindRoot, for example {slope, 0.1, 0.3} etc.
Oct
24
comment Solving Differential Algebraic Equations as BVP
@VenkatKV Of course: i.stack.imgur.com/wPNna.jpg What do you mean by "ot able to get the result"? The result is wrong, or it doesn't give any result, or something else? BTW, ParametricNDSolve is a v9 function.
Oct
23
comment Solving Differential Algebraic Equations as BVP
I think you may be interested in this site :)
Oct
20
comment C compiler options passed by Mathematica
Have you considered reinstalling the compiler in a directory without white spaces?
Oct
17
comment Numerical solution to two non-linear coupled differential equations
OK, after wasting some time searching in WolframAlpha, I'm pretty sure your equations are simply wrong. What you're modeling is something traveling among Jupiter, earth and sun, 6.67384*10^-11 is the Universal Gravitational Constant, 1.89813*10^27, 5.9722*10^24, 1.98844*10^30 the mass of them, 5.20336, 1 the semimajor axis, 5.19273, 0.99986 the semiminor, Unit: au = 1.496 10^11 m, which is forgotten by you. (I failed to figure out how the 4200 comes from. ) If you had added all these information your post, others will notice the problem much easier.
Oct
16
comment How to Use Mathematica as a C/C++ compiler
Do you mean you want to use Mathematica as a C compiler or an IDE? If you're unclear about this concepts, have a look at this. BTW, Mathematica can't be used as a C compiler, it can be used as an IDE for C, but it won't be convenient. If what you want is just to save disk spaces, you can consider lightweight text editor like notepad++ etc.
Oct
16
comment Using NDSolve to solve a system of coupled PDEs
@RobertMoerman You mean the current plot doesn't match the physical prediction and the plot should be two traveling waves from the origin? If so, My tools at hand can't solve this problem. I just noticed that, strictly speaking, the i.c. and b.c. aren't consistent, can this be a reason for the undesired behavior? BTW, you don't need to accept an answer so fast, it'll be better to wait for 24 hours or more so others may give better answers. And, I just checked the wiki of Gross-Neveu model but got nothing valid, maybe you can talk about this a little more in your question.
Oct
16
comment Numerical solution to two non-linear coupled differential equations
You can add "@xzczd" in your post so I'll get a reminder. You don't need to substitute those values before posting your code here, just see what that OP did in the Edit of his question, that'll make your post look better.
Oct
16
comment Numerical solution to two non-linear coupled differential equations
What causes this error is the incorrect square bracket usage in the definition of xdp and ydp : Square rackets are only used to enclose the arguments of functions, correcting this only cause new problem though. But what I really want to say is, Your equation is about planetary orbit, right? If you give those parameters proper names and add some background information of your problem, your post will be much cleaner and draw more attention. (This is a relatively good example. )
Oct
16
comment Using NDSolve to solve a system of coupled PDEs
Hello, welcome to Mathematica.SE! Then please show us the complete code sample, without the definition of V, L, etc. we can't reproduce your problem. BTW, InterpolatingFunction can't be transferred with a simple copy&paste even inside Mathematica. And you may want to have a look at this tool for your code formatting.
Oct
15
comment Smooth Peter de Jong attractor
I'd like to mention that, the "CompileOptions" set in $CCompiler will significantly influence the speed of the code in this case. For GCC, Mathematica uses "CompileOptions"->"-O2" by default, but when I changed it to "CompileOptions"->"-Ofast", I got a 2X speed-up! BTW, with my dual core old machine, your C++ code is even a little slower than the Mathematica code with -Ofast.
Oct
14
comment Has this implementation of FDM touched the speed limit of Mathematica?
@RunnyKine More likely to be a defect of TDM-GCC, I think. Today I learned the basic syntax of C++ for several hours and rewrited the piece of code with it in order to find out if 12s touches the limit of my hardware. The result is, with optimization flag -O3 or -Ofast, the C++ version only costs about 8s in my computer: that's a 1.5X speedup just as you got. So the compiler failed to dig out all the potential of the code.
Oct
11
comment Has this implementation of FDM touched the speed limit of Mathematica?
@AlexeyBobrick No, it won't. ParallelDo isn't in the list, the result of CompilePrint also shows it's indeed not compiled.
Oct
11
comment Has this implementation of FDM touched the speed limit of Mathematica?
@RunnyKine With TDM-GCC 4.8.1, Vista 32bit, ez[[j]] = Compile`GetElement[ez, j]…… even makes the code a bit slower. The Compile`GetElement trick is really amazing, now the code only takes about 13s for steps = 10^7 in my computer, as fast as the Julia version (with the @inbounds macro added). And if I set "CompileOptions"->"-Ofast" when loading the compiler, the timing will reduce to about 12.3s!
Oct
10
comment C compiler options passed by Mathematica
Can it be an issue of compiler installation? Maybe quotation isn't used in some places when the compiler is installed, and it doesn't cause any problem when called from command line but does when called from Mathematica?
Oct
10
comment Bad performance of LengthWhile?
Response from Wolfram company: ……Thank you for your message and the link of the post. I have filed a report on this performance issue of LengthWhile and thank you for bringing it to our attention.……