# Search Results

Results tagged with Search options user 4999
135 results

Questions on optimizing Mathematica code for higher performance. This may mean faster execution, lower memory usage or both. Not to be confused with mathematical optimization.

The following produces an InterpolatingFunction that does the desired extrapolation. It's about the same speed as @Henrik's, but I think it's convenient. InternalInheritedBlock[{Interpolation}, Un …
answered Dec 12 '18 by Michael E2
I have one improvement to suggest. Instead of finding the minimums with MapThread, use a compiled version that threads itself over the lists: mappedmin = Compile[{{x, _Real, 1}}, Min[x], Runti …
answered Jun 14 '14 by Michael E2
There's NDSolveFEMMapThreadDot[mTest, xTest], which seems fairly fast on Henrik's example: mTest = RandomReal[{}, {1000000, 3, 3}]; xTest = RandomReal[{}, {1000000, 3}]; compiled1 = First@RepeatedT …
answered Feb 25 '18 by Michael E2
ExperimentalOptimizeExpression gives a significant speed-up. After injecting the values, First will let the optimized expression evaluate: opt = ExperimentalOptimizeExpression[acPhaseEnergy]; opt …
answered Apr 17 '18 by Michael E2
Using Compile is a straightforward way to speed up procedural code based on machine numbers: OP's: SeedRandom; NM = 50; minitial = 2 RandomInteger[{}, NM] - 1.; Matrix = IdentityMatrix[NM] 0; ste …
answered Jul 14 by Michael E2
Without knowing much about the data, it seems likely that it consists of numbers, and the the times and efficiencies are positive real numbers. Further I have to guess that Select[EquipParams, #[[co …
answered Jun 11 '13 by Michael E2
This is as fast as I can do: delLong[list_, length_] := Pick[list, UnitStep[Length /@ list - (1 + length)], 0] delLong[{{1}, {2, 3}, {3, 4, 6}, {6, 7, 8, 5}}, 2] (* {{1}, {2, 3}} *) Big example, …
answered Aug 9 '16 by Michael E2
SparseArray can help, given the size and nature of the mask. It's slightly faster to convert c and d to sparse arrays than to convert a and b. mask = SparseArray@RandomChoice[{0, 0, 1}, {n, n}]; Fi …
answered Oct 28 '14 by Michael E2
Evaluate the integral once and for all (cf. cdfc): cdfc[k_] = Integrate[PDF[NormalDistribution[0, 1], y], {y, k, Infinity}]; TCJS[T_, k_] := A/T + c1[T]*d1*T + h1*((d1*T)/2 + k*σ1*Sqrt[T + …
answered Aug 11 '15 by Michael E2
If you don't need symbolic expressions for the functions, I would suggest sticking as closely as possible to numeric evaluation. All you need to store is the vector of values of $z$ and for each $p$, …
answered Sep 16 '17 by Michael E2
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 …
answered Jul 26 '15 by Michael E2
Maybe there's something I do not understand because this seems fast to me. I used Do instead of For, since it is faster: (nodes = ConstantArray[0, {200000}]; Do[ nodes[[ji]] = List[{8, 3, 2}, { …
answered Jul 31 '15 by Michael E2
We can find the minimum-producing argument x as a function of n2 using NDSolve. We need only find an initial minimum and a differential equation for the trace of the minima. In fact, we can integrat …
answered Jun 30 '14 by Michael E2
If you change to polar coordinates and simplify the coefficients, Integrate will calculate the radial integral symbolically. This reduces the numerical integration to one dimension, over the angle, w …
answered Feb 22 '18 by Michael E2
You can also convert the Piecewise[] into terms of UnitStep[], using SimplifyPWToUnitStep, and get a significant speed-up: current[t_] := Simplify`PWToUnitStep@ Piecewise[{ {3, t <= 50} …
answered Jan 20 '17 by Michael E2

15 30 50 per page