Tag Info

New answers tagged

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 == γ ...


3

Clear[f, g, gg] g = FunctionInterpolation[-(x - a)^2, {x, 0, 2}, {a, 0, 2}]; gg[a_?NumericQ, b_?NumericQ] := g[a, b]; f = FunctionInterpolation[ArgMax[{gg[x, a], 0 <= x <= 2}, x], {a, 0, 2}] f'[1] (* InterpolatingFunction[{{0.,2.}},<>] 1. *)


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, ...


0

A third attempt would be to try the WatershedComponent Approach presented by bill s above, as in u = GaussianRandomField[128, 3, Function[k, k^-1]] // Chop //GaussianFilter[#, 15] &; so that the watershed is applied on each slice: WS = Map[WatershedComponents[Image[#], Method -> {"MinimumSaliency", .3}] &, u, 1]; Colorize[#] & /@ ...


6

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 ...


0

To obtain the derivative of the integral, just put the derivative of the integrand inside: y[t_, x_] = t^2 x^2; ydt[t_, x_] = D[y[t, x], t]; g[t_?NumericQ] := NIntegrate[ydt[t, x], {x, 1, 2}] NIntegrate[g[t]*t, {t, 1, 2}]


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"}]


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. ...


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. + ...


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 ...


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 ...


0

By Oleksandr R: "...what you're asking for (restriction to fixed precision numerical arithmetic only, localized to a specific package) is simply impossible in the abstract, because Mathematica does not support that, even at a conceptual level."


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 ...


8

To create Experimental`NumericalFunction, one needs to evaluate Experimental`CreateNumericalFunction[vars, expr, dims] where vars is a list of arguments, expr - the expression from which the numerical function will be created, dims - the dimensions of the output matrix produced by this expression. If the output is scalar, then dims should be set to {}. It ...


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 ...


2

If you use: SB[n_?NumericQ, r_?NumericQ] in your definition things work as you expect. Otherwise, SB is evaluated symbolically and that will take forever...


0

Clear["Global`*"] k = 6.; SB[n_, r_] := Sum[Binomial[r Binomial[2 k, 2]/2, i] Binomial[ Binomial[n, 2] - r Binomial[2 k, 2]/2, r Binomial[k, 2] + r - i], {i, r Binomial[k, 2] + r/2, r Binomial[k, 2] + r}] SB[# k, #] & /@ Range[100] // Timing ListLogPlot[%[[2]]] way 2 Clear["Global`*"] sum[r_] := Sum[(Gamma[1 + 33 r] Gamma[1 - 36 r + 18 r^2])/( ...


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}} ...


-5

There is no possible known method to add subtract multiply or divide, using a microprocessor, with equal efficiency. If you look at the various hardware implementations of ALU implementations you will see radically different designs for each function that all have pros and cons. It's an open question in computer science that will make you a very rich person ...



Top 50 recent answers are included