# All Questions

92 questions
Filter by
Sorted by
Tagged with
306 views

### Brute Force for solving Diophantine equation

I'm trying to solve the following Diophantine equation using Mathematica: $$2^x=5^y+3$$ I have a code,but is very slow. Can we speed up ? ...
71 views

### Finding the smallest integer such that a given condition holds with “binary search”

Setup. Suppose we are given a function $$f:\mathbb N\to\{\text{False},\text{True}\}$$ such that $$f(n)=\text{True}\implies f(n+1)=\text{True}$$ and such that $f(n)=\text{True}$ for some $n$ large ...
78 views

### How can I make this “Pick” inside a “Table” run faster?

I am working on becoming more and more familiar with MMA and on a scale from one to ten, I would rate myself as a four or a five. I understand vectorization and that loops-are-very-bad. I have ...
315 views

### Improving Performance of an XY Monte Carlo

I normally write my Monte Carlo codes in Fortran for speed, but I was doing some quick and dirty work and wrote one in Mathematica for the XY model on a square lattice (see Kosterlitz-Thouless ...
91 views

### Efficient manipulation of Associations passed to functions, how-to? [duplicate]

I have some data wrapped into a MyData[data_Association] "structure". My Association contains some big arrays and I do not want ...
33 views

### A newbie question about the use of the FourierSeries functions

Although I have had no previous experience with the Mathematica Fourier Series functions ( or package ), I am writing a tutorial on Fourier Analysis and Transformations in a Mathematica Notebook, ...
251 views

### Finding the path in a graph from A to B then back to A with a minimum of shared edges

the problem is to find cycle from A to B back to A, so that the path B-A would use minimum edges from path A-B. The graph is undirected and can have cycles. The paths don't have to be shortest, they ...
110 views

### Check if number is in list

I have a nested list, but don't know how long the individual lists are. Sometimes they may be 2 numbers long sometimes 1000, so i need to check if theres is a number at position 6 but i doesn't ...
53 views

### Fold/ NestList/ etc in MCMC loop for optimisation

I am trying to simplify and optimise an old loop code I wrote. Since Fold and NestWhile use the results of the last iteration in the new iteration, I would like to use them in order to get rid of Do ...
1k views

### Speed up code to numerically simulate a game of coin tossing

Description I would like to simulate n games in which two players toss one coin each at the same time: If you toss a tail you will receive two tokens, if you toss ...
141 views

### Computation performance involving multiple numeric integrals

I have the following code that has been running for more than three days without an answer, unfortunately. Now, my institution provides us with a computer with Intel Xeon CPU E-52650 v3 @ 20 CPU, 2....
177 views

### Generating lists of integer numbers with two constraints

I am looking for an effective way to generate all lists of non-negative integer numbers $\{k_0,k_1,k_2\dots\}$ such that $$\sum_{i\ge0} k_i=K, \quad\sum_{i\ge0} i k_i=N$$ for given $K$ and $N$. The ...
438 views

### How can I create an enumeration variable by groups?

I copied the title and concept for this question from here. I have ...
82 views

563 views

### Relaxation of Mass-Spring System with Pinned Masses

Problem Assume that four masses are connected to each other by springs while two of them are pinned down at their initial positions. Find the position of masses when system is at its minimum (...
124 views

### How to efficiently find parts of a string with beginning and ending specified?

I'm trying to find specific URL addresses from a html document. The addresses can be found between the strings "href=\"" and "\" class=\"listing". The problem is not including strings like this: "href=...
196 views

### How to speed up my code about Divisors?

This code is about PE496 In[21]:= ParallelSum[n*Count[Divisors[n^2], a_ /; n < a < 2 n], {n, 1, 10^5}] // AbsoluteTiming Out[21]= {5.987342,10724527832} I ...
1k views

### Collatz optimization

I'm VERY new to Mathematica programming (and by new I mean two days), and was solving Project Euler question 12, which states: Which starting number, under one million, produces the longest [...
424 views

### Why does this line increase the consumed memory?

Probably this is a simple question, however I really don't understand this behavior in Mathematica. It particularly leads to a memory leak in a huge program I have to do processing of 3D images. I ...
134 views

### Slowdown of Flat attributed function

I was trying to write an associative function f using the attribute Flat. ...
191 views

### How to handle Indeterminate TimeConstrain

I have to use Timeconstrained[aux] first for avoid some bigs calculation that dont need and it use a lot of time of calculate, so i can't do this. ...
731 views

### Colorize Grayscale Image

I have a grayscale image that contains two objects. The grayscale pixel values can be divided into three intervals where two of them represent objects and the third represents the background. The ...
2k views

### How to speed up my Project Euler code

The evaluation speed of Mathematica often depresses me. It did it again when I wrote a code to solve a Project Euler problem. https://projecteuler.net/problem=206 Here's my code: ...
566 views

### Can code optimize code?

Are there functions, programs or packages that deal with optimizing mathematica code i.e. re-writing ineffecive or convoluted code. -This question has haunted me since I joined SE. The background for ...
92 views

### Timing Differences

In More efficient implementation for comparing coefficient lists in a Do-loop link, george2079 posts in his first answer a piece of code that takes 352 seconds to compute. When I run this same piece ...
I'm wondering how to speed up the following code so it actually computes for $n=2$: ...