Tag Info

Hot answers tagged

8

The explanation is interesting here. I tried the same in C++, and worked a bit extra to make sure the compiler won't optimize away the divisions (looking at the assembly output, it may optimize it away if you're not careful). Indeed, I get 2 with C++. And here's why: C++ does the equivalent of IntegerPart@Divide[x, Divide[x, 2]] (* ==> 2 *) while ...


7

Put independent events in List when you need a few of them. Then to separate while Sow/Reap - use tags in Sow - for example for 4 different events. I'll show all of them on a single plot to compare. Just use Manipulate or Animate or ListAnimate for your goal. data = Block[{δ = 0.15, γ = 0.3}, Reap[NDSolve[{x''[t] + δ x'[t] - x[t] + x[t]^3 == γ ...


7

Another possible path is to extend Vitaliy's function FindCrossings2D to 3D In its current form, it is inefficient and somewhat buggy. Identify all 3D extrema Start with a Gaussian random field u = GaussianRandomField[16, 3, Function[k, k^-1]] // Chop // GaussianFilter[#, 6] &; Build its gradient fu = u // ListInterpolation[#, Method ...


4

Let me start and answer my own question (with what I have so far) since it might trigger some interest before the bounty expires. The motivation is to find rapidly 3D maxima of the field. Posible idea The idea is to define 3D maxima, as the intersection of the union of 2D maxima (using 'MaxDetect') sliced in two different directions. Starting with a ...


3

A general remark to start with - speed is in the eye of the beholder. Having said that, there are a couple of things not quite right with your code. First of all, NDSolve isn't doing what you think it does - it returns unevaluated because you didn't give an initial condition and you gave the wrong independent variable - you want to solve for f, not for ...


3

You can reformulate this as a objective function minimisation problem, where you minimise the sum of the squares of the left hand sides of your equations. Here is how to do this with NMinimize, trying all of the optimisation methods that are mentioned in the documentation: {#, NMinimize[(a^10 E^-a - b^10 E^-b)^2 + ((362880. + a (362880. + ...


2

E.G. (f is an interpolation function): Plot[f[x], {x, 0, 30}, PlotRange -> All, AxesLabel -> {"Seconds", "Value"}] Plot[f[x/1000], {x, 0, 2000}, AxesLabel -> {"Milliseconds", "Value"}]


2

The error message arises because there are three possible values for f'[1] that satisfy your DE: Solve[(f'[r]^2 - 1) f'[r] r == 62/10 (f'[1])^2/1000 /. r -> 1, f'[1]] % // N (* {{Derivative[1][f][1] -> 0}, {Derivative[1][f][1] -> (31 - Sqrt[100000961])/10000}, {Derivative[1][f][1] -> (31 + Sqrt[100000961])/10000}} ...


1

tl;dr There is another solution besides @StephenLuttrell's: $(10,10)$. Well, to be more exact, $(10,9.99997819382)$. Walkthrough This answer has been updated in light of some glaring errors in my original post—namely in taking the sum of the logs of the squares instead of the log of the sum of the squares, and also in suggesting that zeroes would only ...


1

OK, I think I can give you some tips about performance here. There are a couple things you do that really tend to slow you down, and which I would describe as Mathematica "anti-patterns". In particular, building arrays by repeatedly calling AppendTo is likely to be really slow (the time taken will grow quadratically in the length of the list), and accessing ...


1

An extended comment. I'm not sure if this has been realized, please correct me if it has. The result of the Divide[a,b] operation is not the same as the first 3 which are identical. {a, b} = List @@ RandomReal[{-50, 50}, {2, 1*^7}]; x1 = a/b; x2 = a b^-1; x3 = a/b; x4 = Divide[a, b]; Now... Tally[x1 - x2] Tally[x2 - x3] Both give 10^7 zeros. ...


1

Here is an other image processing alternative. The main idea is as a pre-processing step using Gradient Filter. (I think most of them may work in 3D as well.) img = Import["http://i.stack.imgur.com/g7TFl.png"]; imgG = ColorConvert[img, "Grayscale"]; imgA= ColorNegate@GradientFilter[imgG, 3] // ImageAdjust imgB= ImageMultiply[MeanShiftFilter[imgG, 2, 0.3, ...



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