Skip to main content

Questions tagged [timing]

This Tag is used for two things: Questions regarding improving execution speed and questions where various methods are compared for execution speed.

Filter by
Sorted by
Tagged with
0 votes
1 answer
25 views

Setting shared function values in parallel is running sequentially

I am trying to define a function whose values can be updated across different Kernels running in parallel, where each Kernel might have to use values defined by other Kernels previously in the process....
BioPhysicist's user avatar
  • 1,146
0 votes
0 answers
82 views

Can this loop / code be optimized to find more items in the sequence?

I am looking at the code snippet for OEIS A067075. Do[k = 1; While[Plus @@ IntegerDigits[k^3] != n^3, k++]; Print[k], {n, 1, 6}] It does okay for the first ...
Moo's user avatar
  • 3,420
2 votes
0 answers
61 views

Stop NSolve after a certain amount of time and return calculated solutions

I am trying to solve a system of equations of the form: ...
A P's user avatar
  • 225
2 votes
0 answers
71 views

Why TimeConstrained does not work when increasing the time?

I found a case where in V 14.4 TimeConstrained hangs when increasing the time from 60 seconds to 120 seconds. This happens only in V 14.0. Same exact code works in ...
Nasser's user avatar
  • 149k
2 votes
0 answers
79 views

Abnormally long computation time using AppellF1 function

I am trying to use the AppellF1 function in Mathematica 13.3.1 on an Ubuntu machine with an i7 13700. The inbuilt function seems to be much slower in some cases ...
Arav BJ's user avatar
  • 66
0 votes
0 answers
74 views

Can we explain why Timing is inconsistent?

I am trying to speed up a code and by placing Timing statements in the code I identified a suspect calculation that I do repeatedly. In order to test out the ...
Hugh's user avatar
  • 16.7k
1 vote
1 answer
160 views

Creating and printing a real-time evaluation timer

I want to print a timer that starts at 0 when an evaluation begins and stops when the evaluation is completed. I have come up with the following solution using Clock...
oakley09's user avatar
2 votes
1 answer
82 views

CPU time in iteration process

Let $Tx=\frac{x}{2}$ for all $x\in[0,1]$. Let $x_{0}\in[0,1]$ and set an iterative sequence $\{x_{n}\}$ by the method $x_{n+1}=Tx_{n}$. Now if $x_{0}=0.8$, then I get a convergent sequence towards the ...
Junaid Ahmad's user avatar
3 votes
2 answers
127 views

Position command runs much slower for range containing numerically evaluated Bessel function

I have a long list (about 10000) of positive numbers (here simply denoted list), for which I want to find the positions of elements lying between 0.5 and the first ...
Chris's user avatar
  • 1,043
13 votes
3 answers
506 views

Why does Module slow down StringMatchQ by 180 times?

I knew that Module is slower than With or Block, often by several times. But it surprises me ...
Lacia's user avatar
  • 2,569
3 votes
1 answer
52 views

Inconsistent Timing on FinancialBond valuations

I need to do bond valuations (lots of them across lots of data) using FinancialBond. Context & Background I have daily interest rate data on 30 year US Treasury ...
Jagra's user avatar
  • 14.5k
1 vote
1 answer
165 views

How do I speed up this numerical integration with Bessel functions? (Tried changing Working Precision and Integration Strategies)

I need to compute the function P[b] given as follows: ...
Dave's user avatar
  • 11
0 votes
0 answers
41 views

Derive a function and then make a fast version for execution

I would like to derive a (complicated) equation of motion and integrate it efficiently numerically. I can do this "by hand" by copying the resulting function in a new function and then ...
John Bechhoefer's user avatar
0 votes
1 answer
151 views

Inverse taking no time? [closed]

I was comparing the time that the computer takes to perform Partial Pivoting, Total Pivoting and multiplying by the inverse. The code (that makes the comparison chart) is as follows: ...
user23004030's user avatar
0 votes
0 answers
94 views

Solving an equation without output

Could you please help in solving the equation below. I am not able to do it with the current version of mathematica (very old one). All parameters are real and positive. Thank you so much in advance <...
ridha's user avatar
  • 21
1 vote
0 answers
73 views

Is there any hope to compute the determinant of $56\times 56$ parametric matrix and simplify the result?

I have this $56\times 56$ parametric matrix $M$ and I want to compute its determinant where $\{t,y,z\}$ are some real parameters. I use Det[M] but it takes a lot ...
charmin's user avatar
  • 1,169
6 votes
1 answer
188 views

Why does Table take so much longer than its constituent computations?

I have a 10x5xn list, which I'll call data, data = RandomInteger[{-500, 500}, {10, 5, n}]; ...
az123p's user avatar
  • 239
11 votes
2 answers
411 views

Speeding up time in computations: a visual and easy way to find the slowest parts of a code

[ Edit 2: The resource function TraceView gives a nice way to visualise the timing. This Resource function is also mentioned here : https://mathematica.stackexchange.com/a/278723/86543 ] [ Edit: I ...
userrandrand's user avatar
  • 5,957
0 votes
1 answer
77 views

Why the performance of list of Timings depend on the order?

It seems that the result of list of Timings and AbsoluteTimings depends on the order, while ...
Lacia's user avatar
  • 2,569
4 votes
1 answer
44 views

Timing Discontinuity with Replace[] Function

When constructing certain square matrices I noticed a sharp jump in the time required to build them. I've included code and a plot of time required to make the matrix vs dimensionality of the matrix. ...
Ken Robbins's user avatar
4 votes
2 answers
90 views

Format Time Reported by AbsoluteTiming

I am trying to format the timing reported by AbsoluteTiming so that it states the hours minutes and seconds of the result. However, probably because ...
Nicholas G's user avatar
  • 2,093
5 votes
1 answer
128 views

Why the coefficient function is very fast

When looking for the coefficients of an desired series, I found that the Coefficient function is very fast compared to other functions and methods. In the following summary, we find the different ...
Tag Mohamed Amine's user avatar
3 votes
1 answer
74 views

Defined function takes more time than pure/anonymous function. Why? [duplicate]

A function defined by f[x_]:=<code> and applied on every element of a list as f /@ testList seems to take longer than the ...
Ondrej Draganov's user avatar
1 vote
1 answer
149 views

Explicit integration of PDE running very slowly

I would like to solve the PDE $\frac{\partial u}{\partial t}=(1-x)\frac{\partial u}{\partial x}$, in the interval $[0,1]$, with initial condition $u(0,x)=e^{-218(\frac{-2}{3}-ln(1-x))^2}$, by manually ...
JBuck's user avatar
  • 199
0 votes
0 answers
70 views

Why is Clip so slow and how can I improve its performance?

The built-in function Clip is defined as a way to clip a value between a specified minimum and maximum. Another way to do this, is simply by utilizing ...
polfosol's user avatar
  • 952
1 vote
1 answer
65 views

How to get correct note timings when importing multi-track Midi files?

I have observed when importing midi files with more than one track, the times for every track except for the first one are sped up. for example, ...
Alec Graves's user avatar
  • 1,078
-1 votes
3 answers
172 views

Elimination of the variables

I am trying to get an equation in terms of variable z by eliminating variables g0 and g1 but Running below code is taking time forever ...
Tiku's user avatar
  • 51
1 vote
1 answer
82 views

Using With[] vs. Using a Pure Function for Constants

There are many cases where I am conflicted over using With[] versus using pure functions when dealing with constants, knowing the output is the same either way. For ...
Just Some Old Man's user avatar
4 votes
4 answers
320 views

Code to solve quadratically constrained quadratic optimisation problem using FindMinimum is very slow. How do I make it faster?

The problem I have a quadratically constrained quadratic optimisation problem (QCQP) which takes about 13 seconds to find the optimal solution. I want to iteratively optimise a large number of times (...
ModCon's user avatar
  • 245
1 vote
2 answers
137 views

How to make the following code work faster?

The problem I would like to compute the Lorentz transformation $\mathbf{p}'$ of an arbitrary 3-momentum vector $\mathbf{p}$ given a boost characterized by some other momentum vector $\mathbf{p}_{N}$, ...
John Taylor's user avatar
  • 5,927
6 votes
4 answers
181 views

Check if list is singleton in sub linear time

A singleton is a list whose elements are equal. Some ways of checking this in Mathematica: {Equal@@#&, 1==Length@Union@#&, MatchQ[#,{x_ ..}]&} I ...
Adam's user avatar
  • 3,986
0 votes
0 answers
66 views

How to evaluate the following integral faster?

I have a problem with the time required for evaluating the multi-dimensional integral and would be grateful for any help in reducing this time. First of all, there are some pre-definitions used in the ...
John Taylor's user avatar
  • 5,927
3 votes
1 answer
164 views

Why Dot product of my vectors takes longer than usual?

I have a list containing 100 complex numbers lying between 1.9 + 1.9 i and 2.0 + 2.0 i you can download its mx file from the link below and import it in Mathematica: http://adambarfib.ir1.rapidpars....
Mostafa Saber's user avatar
1 vote
0 answers
57 views

Long execution time using position

I have two lists, for example: List1={2,4,6,8,10,12} List2={4,10,12} I want to find the positions in List1 such that the element at that position is equal to the ...
Orion's user avatar
  • 107
1 vote
0 answers
71 views

How to reduce the computation time of this series expansion?

I have a complicated function gg[Delta,l][z1,z2] which is given in the sample code below. I would like to expand this function for as many ...
Pxx's user avatar
  • 711
3 votes
0 answers
54 views

Why is doing a computation inside Select slower than a precomputation?

I am trying to generate primitive Pythogorean triples using Euclid's parametrization. I basically want a list of pairs with ordered pairs $(m,n)$ such that $m$ and $n$ are coprime. My first approach ...
Fixed Point's user avatar
4 votes
1 answer
175 views

Multi-dimensional array lookup vs flat array lookup with compute

During Monte-Carlo (MC) simulations on a latice of dimensions $(L_1,L_2,\ldots,L_D)$, all the site varibales are often stored as a $D$ dimensional array array. To ...
lineage's user avatar
  • 1,164
3 votes
2 answers
131 views

NIntegrate timing discrepancy

When I run the following identical numerical integrals ...
Chris's user avatar
  • 1,043
4 votes
0 answers
56 views

Difference in computation speed of Eigensystem not to expectation for ParallelTable and Table

I was trying to compute the time it takes for Eigensystem to evaluate while being inside a ParallelTable, as it is well-known LAPACK subroutine has an inbuilt Parallelization to it. And the difference ...
Roopayan Ghosh's user avatar
0 votes
1 answer
29 views

Calculation time differs between segmented loops and one whole loop

I stumbled on a strange issue while simulating a large number of random values, $10^8$ to be precise. I generated the numbers at first by the following code: ...
Castle's user avatar
  • 127
4 votes
1 answer
240 views

Reduce the time of computation for $5$-dimensional numerical integration

I need to perform (numerically) the $5$-dimensional integral given in the code below for a large number of values of $\epsilon$. The code I have at the moment takes $\sim 11$ minutes and returns an ...
Pxx's user avatar
  • 711
9 votes
0 answers
839 views

Mathematica 12.1 start-up time in Linux extremely slow

I installed Mathematica 12.1 on my Linux machine and the start-up time is extremely slow. I see the Spikey logo and messages like: Initializing Kernel connections ...
Santiago's user avatar
  • 1,201
2 votes
0 answers
46 views

Summing Kronecker Deltas: Sharp slowdowns for simple sums

I'm using Mathematica 12.0 Student Edition. I'm a little confused by the length of time Mathematica takes to evaluate certain sums of Kronecker Deltas or Discrete Deltas. Here's a simple example below:...
user196574's user avatar
1 vote
1 answer
86 views

Converting Timing to TimeObject

What's the proper way to get Timing and post-process it for example to convert to a TimeObject as a defined function? In line, ...
alancalvitti's user avatar
  • 15.2k
1 vote
0 answers
65 views

Filtering Fibonacci numbers for elements meeting certain criteria [closed]

Write a code that selects in less than two seconds from every 123rd of the first 33,333 even Fibonaci numbers; those which contain the digits 2, 3, 6, 7, and 8 and also contains the digit 1 more than ...
User9495's user avatar
2 votes
2 answers
198 views

How to set a timer (countdown) in Manipulate what stops it running?

I have a Manipulate function with 2d slider which I can play with some curves. I consider this as a game (gamification in physics). I want to set a timer so when it countdown to zero then the game ...
Aaron's user avatar
  • 93
0 votes
0 answers
103 views

How to speed up Timing[4^(10^10)]

I have an old computer with a quad-core AMD Phenom II processor (3Ghz). When I run Timing[4^(10^10)]the computer takes hours to evaluate the expression. I'm not ...
bford16's user avatar
  • 101
2 votes
1 answer
322 views

Using Parallelize in a solve function

Is there a way to use Parallelize the following operation, in order to make it do the calculations faster? Or is there another way to speed up this calculation? ...
Jan Eerland's user avatar
  • 2,021
1 vote
1 answer
85 views

Generalization of code is slower than particular case

I wrote the following Mathematica module: ...
user68161's user avatar
  • 153
2 votes
3 answers
114 views

Summing all the times of a column

It is possible to add a last row in the table where I can show the sum of values of the last column. I would like to get the total time value... ...
LCarvalho's user avatar
  • 9,263