Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Favorites infavorites:mine
infavorites:1234
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with Search options user 4999

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.

3
votes
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. Internal`InheritedBlock[{Interpolation}, Un …
answered Dec 12 '18 by Michael E2
6
votes
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
4
votes
There's NDSolve`FEM`MapThreadDot[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
4
votes
Experimental`OptimizeExpression gives a significant speed-up. After injecting the values, First will let the optimized expression evaluate: opt = Experimental`OptimizeExpression[acPhaseEnergy]; opt …
answered Apr 17 '18 by Michael E2
2
votes
Using Compile is a straightforward way to speed up procedural code based on machine numbers: OP's: SeedRandom[1]; NM = 50; minitial = 2 RandomInteger[{}, NM] - 1.; Matrix = IdentityMatrix[NM] 0; ste …
answered Jul 14 by Michael E2
1
vote
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
9
votes
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
8
votes
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
5
votes
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
3
votes
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
3
votes
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
1
vote
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
4
votes
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
10
votes
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
9
votes
You can also convert the Piecewise[] into terms of UnitStep[], using Simplify`PWToUnitStep, 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