Tag Info

Hot answers tagged

19

I can't take much credit for this answer--I hadn't even got version 10.2 installed until J. M. commented to me that these functions could be written efficiently in terms of the Hamming weight function. But, it is understandable that he doesn't want to write an answer using a smartphone. The definition of the built-in ThueMorse is: ThueMorse[n_Integer] := ...


6

First, here's an image from the docs which we'll use for testing: img = Import["http://i.stack.imgur.com/bzkJM.png"] Going with the definition given in the IPP, here is a remapping method based on the use of ImageValue[]: Options[ImageRemap] = {Padding -> 0, Resampling -> "Bilinear"}; ImageRemap[img_Image, xm_?MatrixQ, ym_?MatrixQ, opts : ...


4

My keyboard is broken. So here is fast answer (on Mathematica 9); more later... Here is your input: dim = 3; g = RandomReal[{0, 1}, {dim, dim}]; F = RandomReal[{0, 1}, {dim, dim, dim, dim}]; Now multiply four g's and the F. Use TensorProduct[g, g, g, g, F] (don't run this yet--it's slow) to generate the rank 12 tensor (unrepeated indices). Now ...


4

Note that Piecewise functions are a special case in Integrate if the integral is in the form of an indefinite integral. (One can add a constant as needed to adjust for a different starting point, but in the OP's example, it is unnecessary.) This evaluates relatively quickly: foo = Piecewise[{(t - #[[1]])^2, #[[1]] <= t && t < #[[2]]} & /@ ...


3

First thing I would note is that you should Integrate the function analytically before plotting it. To do so you should add your assumptions like already commented by other users (note that it is important to use set (=) instead of set delayed(:=) to do the integration only once): f[t_] = Piecewise[{(t - #[[1]])^2, #[[1]] <= t && t < #[[2]]} ...


1

Here's a possible solution. It's working (really well) for 1 particle, but needs to be checked for two particles, I guess due to minor mistakes. Basically, I changed approach and turned to a matrix notation. Let's start from the one-particle system. We simply write the state as a vector, and the operators as matrices, being very careful about the indexing. ...


1

Essentially the same as Simon Woods's comment: SeedRandom[1] data = Partition[Sort[Join[{0}, RandomReal[{0, 10}, 20], {10}]], 2, 1]; You don't need the And with the inequality f[t_] = Piecewise[{(t - #[[1]])^2, #[[1]] <= t < #[[2]]} & /@ data]; You need to add an assumption to the Integrate for it to evaluate Plot[Evaluate@Assuming[x >= ...



Only top voted, non community-wiki answers of a minimum length are eligible