The tag has no wiki summary.

learn more… | top users | synonyms

12
votes
1answer
211 views

the more effective method to find 21 digits armstrong number

In recreational number theory, a narcissistic number (also known as a pluperfect digital invariant (PPDI), an Armstrong number(after Michael F. Armstrong) or a plus perfect number) is a number that is ...
1
vote
0answers
39 views

Understanding Mathematica: How to write fast code? [duplicate]

I'm relatively new to Mathematica but have done a few projects using it so I'm quite comfortable with the syntax and the basic functions available. Since I've had programming experience in the past I ...
7
votes
2answers
232 views

Finding all sets of elements with two common elements in a large dataset

I have a very large network of atoms ($\approx 10^6$ atoms) with fixed positions that resemble a cellular structure: I have two files including: fixed locations of each atom set of points which ...
30
votes
0answers
318 views

Is this the most effective and efficient programming style for prototyping (a ray tracer) in Mathematica?

I am trying out Mathematica as a prototyping tool. As an initial exercise I have put together a brute force ray tracer, with a view to using Mathematica's built in probability distribution functions ...
1
vote
1answer
71 views

Calculate the algebraic multiplicity of known eigenvalues of a large, sparse matrix

I have a large (and sparse) matrix with size 1000x1000 -- 10000x10000. I believe i know all eigenvalues for the matrices. All entries are integers and so are the eigenvalues. I want to check this by ...
5
votes
0answers
93 views

Is there a PrimeQ whose accuracy guarantee you can adjust?

Say I have a list of a million integers each with a million digits, and I want a crude sieve to see which have a chance at being prime. Mathematica has a PrimeQ function, which appears to be slow ...
6
votes
1answer
146 views

Efficient JSON parser for Mathematica

Im looking for a efficient way of parsing JSON data in Mathematica. I am having a lot of problems with ImportString because it uses Java, is too slow, and uses too ...
1
vote
1answer
69 views

Efficient calculation of diagonal matrix elements

I have a matrix $V$ of size $M$ in which each row $i$ is a vector $v_i$. Now I have another matrix $H$ and I would like to calculate as efficiently as possible the list of values $v_i^\dagger\cdot ...
4
votes
0answers
78 views

Challenge: Speeding up MaxDetect for application in 3D blob detection

In image segmentation it is a common problem that objects appear clustered and are therefore undistinguishable from each other when using simple algorithms. Based on this post I obtained efficient ...
0
votes
0answers
64 views

Speeding up Nonlinearmodelfit by constraining parameters?

I have a complicated parametric PDE that can be fitted to some data with NonlinearModelFit, but takes several hours to estimate the best values of the four free parameters. Currently, the code ...
0
votes
0answers
33 views

How can I make this more efficient/why doesn't my naive solution speed things up?

I'm computing a certain power series (up to some number of terms), and I figured I should try to speed up the computation as much as I can. The series is defined as follows: Let $f$ be a Laurent ...
2
votes
2answers
103 views

Counting Events in a moving date range

I want to count the number of times events take place in a date range. The counting is done over a window of e.g. 28 days where the goal is to have between 11 and 13 events in the time window. The ...
-2
votes
2answers
155 views

How to write efficient code? How to make this example run faster? [closed]

I would like to learn writting more efficiently. I am working on problem of simulating random walks (abnormal diffusion). I believe this is good example of inefficient code. How can I make it faster? ...
0
votes
0answers
59 views

Is there a faster way to do Normal[SparseArray[{{1,1,1}→1.2, {1,1,2}→20.2, …, {m,n,p}→0.3}]]?

I have a list of the form {{1,1,1}→1.2, {1,1,2}→20.2, ..., {m,n,p}→0.3} and I want to create an $m \times n \times p$ array, $A$, where the value of $A[[i,j,k]]$ is ...
6
votes
1answer
147 views

Law of Cosines to determine angle change along spiral

The Spiral I'm trying to place circles along the outside of an Archimedean spiral. Shown below: ...
4
votes
2answers
111 views

Gamma function computation efficiency?

I wonder what kind of algorithm is used to compute the values for the gamma function. Specifically, I am interested in how the computational load increases when the complexity of the input grows. So, ...
6
votes
2answers
145 views

Additive SparseArray Assembly

The goal is to assemble a SparseArray in an additive fashion. Let us assume we have a large List of indices (some will be ...
1
vote
3answers
87 views

Efficient matrix multiplication

I have a list of vectors vecs={vec1,vec2,...,vecN} where veci is a list with length N. Now I have a matrix N*N called mat. I would like to efficiently get all the numbers veci.mat.veci for i=1 to N in ...
2
votes
0answers
103 views

Expanding a Function in Series works, SeriesCoefficient Doesn't Work

Take the following definitions: ...
5
votes
1answer
187 views

Efficiently searching a list for the position of the closest number to a specified number

Searching by closest and position I wasn't able to find an answer—but found Nearest by guessing. Nearest, however, returns ...
0
votes
1answer
117 views

Efficiency problem with least square algorithm (Error in both variables)

I was informing myself about the least square algorithms with errors in x and y. I found this post and the top answer wasn't ...
4
votes
3answers
237 views

SparseArray row operations

Given a large (very) sparse matrix, A, how can I efficiently "operate" on only the nonzeros in a given row? For example: For each row in A, generate a list of column indices that have a magnitude ...
0
votes
0answers
146 views

Efficiently tabulating system of coupled ODEs for NDSolve

I am solving a (large) system of second order coupled nonlinear ODEs. I have been increasing the number of dependent variables present in the system slowly, to converge on more physically realistic ...
7
votes
0answers
165 views

Improving the performance of a package for working with rational functions

As Mathematica gets slow for large symbolic calculations, the cost of putting terms over a common denominator (Together), in particular, gets too high. It occurred ...
9
votes
1answer
93 views

IntegerDigits has Listable attributes, but not fast

See this example, a function has Listable attributes often more efficient than Map,but why is this one is an exception? ...
7
votes
2answers
223 views

Complement on pre-sorted lists

Is there any way to instruct Complement to skip the sorting part? If the answer is no (likely), the next question would be: how can I remove from a sorted list ...
5
votes
1answer
315 views

Efficiently generating histograms with large numbers of bins

I'm trying to generate a histogram for a large data set with the following lines of code: ...
3
votes
2answers
418 views
1
vote
0answers
126 views

Making simultaneous equation solving more efficient

I am trying to solve a system of several simultaneous equations that have been generated by a series of modules and functions, using this module: ...
1
vote
0answers
169 views

Get path to end nodes in directed (partially cyclic) graph

I have a large directed graph containing small loops. I would like to extract all paths to all end nodes (no VertexOutComponent) with a given path length $n$. I ...
5
votes
2answers
110 views

DictionaryLookup very slow

I'm trying to plot, given a list of words, how many words belongs to each language. I'm using the following code: ...
1
vote
1answer
142 views

Improving the plotting time of a very complicated expression

The quatity $R$ is defined by a complicated expression in terms of $a_1,a_2,\ldots,a_n$. Now each $a_i$ is a function of $x$, $a_i(x)$. I would like to know what is the most efficient way to ...
8
votes
2answers
126 views

vectorized operations is not efficient?

Consider the following example: ...
9
votes
1answer
146 views

Creating a NearestFunction that returns an index

I use Nearest repeatedly for large data sets. For example pts = RandomReal[{-1, 1}, {1000, 3}]; Nearest[pts, {0, 0, 0}] I ...
20
votes
3answers
560 views

Common subexpression from two expressions

I am working with some unpleasantly tedious polynomials, which need to be manipulated in various ways (integrate with respect to some variable, differentiate with respect to another). Since these ...
2
votes
2answers
340 views

Mass Symbolic Manipulation with Subscripts? (from plaintext Input)

The simplest example of the change being sought is a greek letter, typed in as plaintext nu, and its may be replaced by the symbol, ν: expr = 3nu*kx*ky+ ...
0
votes
2answers
202 views

Import large amount of data with time stamps

I have a large data file (150 000 lines) which I want to import in Mathematica. The first few lines look like this ...
2
votes
0answers
96 views

Significant platform-dependent efficiency when importing data?

I'm curious, as I understand that answer this way: If you are using a Linux derivative or something like cygwin on Windows, then this is an efficient solution for reading only the third field ...
4
votes
2answers
308 views

Efficient drawing of convex polyhedron given a set of points [duplicate]

I have a set of points in the 3D space and I want to draw the bounding convex polyhedron of those points. A very naïve solution would be to draw a triangle between every three points: ...
2
votes
2answers
735 views

Importing several huge files with headers & footers

having here several files in ASCII format http://ge.tt/91rv0Jf/v/0 I want to import, while removing headers and footers and then join the several lists. ...
5
votes
1answer
116 views

How to read off coefficients of tensor-like expression in a speedy way?

I am considering identities involving t[a, b, c, d, ...], where number of indices is fixed. t has the cyclic property so that ...
5
votes
1answer
144 views

Why is Flattening a CoefficientArray so slow?

I have a vector of $n$ degree $n$ polynomials in $(x,y,z)$, each of whose coefficients is an inhomogenous linear expression in $3 n^2$ variables. I want to write down the linear equations in these $3 ...
1
vote
1answer
107 views

Only perform a symbolic differentiation once

I want to define a function that involves a differentiation step that Mathematica can do easily, which might be of the form ...
4
votes
1answer
278 views

A Faster way to combine two Lists of different structures into one of a different structure [duplicate]

I have the following two lists (each containing over 500,000 elements). Here is a sample: ...
8
votes
4answers
489 views

Efficient code for the Ten True Sentences puzzle

I am trying to solve Ten True Sentences Puzzle. Take a look at the following sentences: The number of times the digit 0 appears in this puzzle is _. The number of times the digit 1 ...
12
votes
4answers
481 views

Can you recommend an efficient method for finding the least integer satisfying my inequality?

I tried find the minimum make $\frac{1}{2}+\frac{1}{2+\sqrt{2}}+\frac{1}{3 +\sqrt{3}}+...+\frac{1}{n+\sqrt{n}}>15$ Following code is so slow when I use condition ...
4
votes
3answers
458 views

How to make brute force coding more efficient?

Hi guys and guysettes, The little Mathematica I've been using/seen so far, it seems to be all about neat "one-liners" using the underlying functions and working with lists & maps to solve issues, ...
16
votes
2answers
1k views

Difference between AbsoluteTiming and Timing

I need to evaluate the efficiency of my code. Therefore I would like to evaluate the time the code need for some calculations. Mathematica gives me two possibilities for this kind of evaluation: ...