5,034 reputation
2954
bio website
location China
age
visits member for 2 years, 5 months
seen yesterday

Feel free to correct the grammar mistakes in my posts.


Dec
11
comment Compilation of a function that needs to call Subsets
BTW, what creates the unpacked array is actually Outer, so I'm afraid unpacked array is also unavoidable.
Dec
11
comment Compilation of a function that needs to call Subsets
Subsets isn't in this list, so Compile isn't likely to speed up your code. In fact, according to my personal experience, though usually not slowing down, even those compilable list-manipulating functions won't benefit from Compile, the reason might be that as an important part of Mathematica core language, most list-manipulating functions have been highly optimized that they can hardly benefit from Compilation. (Join and Complement is compilable, you can try to Compile them and see if the code speeds up.)
Dec
11
comment How to use a C compiler without having SystemModeler
Personally I recommend TDM-GCC, which is free and small and easy to install, you may need to set it manually though. (It's said that Visual Studio can be automatically detected. ) The way to set it is included in the link given by @Lou.
Dec
11
comment Order of evaluation when using Solve and Minimize
You'd better include a concrete code sample, with its currently form it's hard to give advice.
Dec
11
comment How to use slots and patterns to reduce repetitive calculation?
Well, you'd better give a concrete example, or it'll be hard to give advice.
Dec
11
comment What does f_[whoCalled]^:=f really mean?
The only thing I know is that the attribute isn't the reason, try Attributes@plus = Attributes@Plus; plus@whoCalled. BTW, this special upvalue is really interesting, it even breaks UpValues and Unset and Break!
Dec
11
comment Poisson PDE using FDM in Mathematica
@unlikely Glad it help. As mentioned, this post is my first trial for FDM on irregular region, and in fact all the references in my hand has been linked in this post, maybe you can consider asking a separate question for your specific equation?
Dec
8
comment Boundary value problem: complicated functionals
Shooting method usually need a "StartingInitialConditions", but I failed to, and I'm afraid it won't be easy to, find a proper one for your equation. See here for an example.
Nov
28
comment Mathematica won't plot the a function that is solved from NDSolve
Maybe you can go a little deeper on this issue so we will be able to mark those subsequent similar question as a duplicate of this confidently?
Nov
27
comment Mathematica won't plot the a function that is solved from NDSolve
OK, after a second thought I retracted my closing vote, it's indeed a good example for pattern-matching. (I do suspect that the issue must have been raised before but can't find one.) It's a little painful for me to explain this issue systematically, let's wait for a moment first to see if any pattern-matching master will come to give an answer.
Nov
27
comment Mathematica won't plot the a function that is solved from NDSolve
Simply because Subscript[\[Theta], 2][t] doesn't match Derivative[1][Subscript[\[Theta], 2]][t], Change the variables in sol into Head /@ variables will fix the problem.
Nov
27
comment Lens profile in a grid
You need to add @gpap in your comment or gpap won't get a reminder. BTW, I think your model is still wrong: you are actually using 1D FDTD code to simulate a 2D case. 2D Maxwell equation doesn't mean a bunch of 1D Maxwell equation. I still suggest you to learn the corresponding background knowledge before coding.
Nov
21
comment NDSolve and strange “nonlinear coefficients problem”
As to the last question, have a look at this and this.
Nov
20
comment NDSolve and strange “nonlinear coefficients problem”
Using Method -> {"MethodOfLines", "SpatialDiscretization" -> {"TensorProductGrid", "MaxPoints" -> 151, "MinPoints" -> 151, "DifferenceOrder" -> "Pseudospectral"}} in SIM1 also leads to the u[x, t] = x solution.
Nov
20
comment Maxwell propagator problem 2D
I've also used 1D/2D FDTD code as example in many of my questions, for example this, you can have a look.
Nov
20
comment Maxwell propagator problem 2D
And you have mistakenly used Dot as Times, moreover, how can you "implemented only the first equation for Hy"? FDTD is a leap-frog finite difference scheme! You need to first understand what FDTD is before programming. To learn FDTD, you can read this book.
Nov
20
comment How to get a more compact form of this probability calculation?
@hengxin It's OK to wait 24 hours or even longer before accepting so your question may attract better answers :) . I added a ErlangDistribution approach, have a look.
Nov
17
comment How to get a more compact form of this probability calculation?
Network is a bit slow today. See my answer.
Nov
17
comment How to get a more compact form of this probability calculation?
I think your program is wrong. In your program, a3 and a4, s4 and s5 are independent, but actually they're not, a3 is part of a4, s4 is part of s5!
Nov
17
comment How to solve this probability symbolically or numerically?
@hengxin You can use FindSequenceFunction: FindSequenceFunction[Table[(μ^m (2 λ + μ))/(2^(m + 1) (λ + μ)^(m + 1)), {m, 5}], m]