Questions tagged [iteration]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
10 votes
3 answers
1k views

Simple Fractal square

I am working on a math question about infinite series, and one of the question images is below. Each new white square has an area that is 1/4 of the previous square. Always looking to learn elegant ...
Tom De Vries's user avatar
  • 3,718
10 votes
2 answers
539 views

What is the most efficient way to define a Loop until function?

Mathematica has the While function which is very convenient when we need to process some code until the attainment of a certain state (identified with a condition). ...
Denis Cousineau's user avatar
10 votes
5 answers
1k views

Simple Birth Death Process

I am trying to implement simple birth death process. Why my code does not work? Any suggestion. Thanks. Cross posted http://community.wolfram.com/groups/-/m/t/1205656 ...
OkkesDulgerci's user avatar
9 votes
6 answers
703 views

Delete repeating elements across sublists

I have a list like this test = {{1, 3, 5}, {7, 2, 8, 5}, {7, 1, 3}}; The list is guaranteed to have duplicates only across sublists and not within. I would like ...
Three Diag's user avatar
8 votes
5 answers
760 views

Create a regular polygon with n vertices given two points

I want to create a regular polygon from the initial two points $A$, $B$ and number of vertices $n$, regularPolygon[{0, 0}, {1, 0}, 3] gives ...
expression's user avatar
  • 5,540
7 votes
2 answers
448 views

How can I iterate this process?

a = RandomVariate[UniformDistribution[{0, 1}]]; b = RandomVariate[UniformDistribution[{0, 1}]]; c = RandomVariate[UniformDistribution[{0, 1}]]; a + a b + a b c ...
geoffrey's user avatar
  • 785
7 votes
2 answers
349 views

Using Nest to build continued fraction

To build basic continued fraction one can simply use: Nest[1/(1 + #) &, x, 3] However, it's unclear how using Nest ...
Elias's user avatar
  • 357
6 votes
4 answers
319 views

Using multiple hashtags in NestList

Are multiple hashtags allowed in NestList usage? If yes, how to implement it? Example, f[{x_, y_}] := {x + y, x - y}; NestList[f, {100, 75}, 5] My attempt, ...
Aschoolar's user avatar
  • 883
6 votes
2 answers
258 views

How to create a nested list of variable depth with indexed elements

i want to obtain this definition of a nested list t = Table[C[i, j], {i, 3}, {j, 3}] with arbitrary depth, ...
Rainer Glüge's user avatar
6 votes
2 answers
301 views

How to iteratively build a list?

I have the following c++ code that I want to translate to Mathematica. ...
SmileyCraft's user avatar
6 votes
1 answer
369 views

Heat transfer with functions defined on different domains

I'm attempting to model a situation in which a polymer initially at a higher temperature is sandwiched between two cooler metallic mold pieces with conductive boundary conditions in between the ...
Rpj's user avatar
  • 249
6 votes
1 answer
778 views

Coding the Mandelbrot Set for Beginners

I'm new to Mathematica and will need some help in coding the Mandelbrot set. I don't want to use MandelbrotSetPlot since I want to understand the interior ...
Hannes Schumacher's user avatar
6 votes
1 answer
82 views

RecurrenceTable and While

Good day. Let's take an example from Help on RecurrenceTable: ...
macros's user avatar
  • 99
5 votes
5 answers
536 views

Best way to count nest depth in e.g. f[f[f[...[f[x]]...]?

What is the best way to count nesting depth in e.g. f[f[f[...[f[x]]...]? In other words, what function func is good for giving ...
Trev's user avatar
  • 753
5 votes
3 answers
287 views

Iterate over deepest values in a nested Association

Is it possible to iterate over the values of the deepest layer of keys in a nested association? For example: ...
BOUNCE's user avatar
  • 549
5 votes
1 answer
292 views

How to recreate this complex iteration

I came across this image in a book Im reading: (taken from Rational Iteration Complex Analytic Dynamical Systems from Steinmetz. I hope it is okay to share it here) and I try to recreate it in ...
Arjihad's user avatar
  • 1,134
5 votes
3 answers
296 views

ParallelDo barely faster than Do

I am new to parallel computing, so I am trying to get a grasp as to how this works. Many posts seem to indicate that overhead (like here) is a common pitfall, but I do not see why this would be the ...
Patrick.B's user avatar
  • 1,349
5 votes
2 answers
491 views

Replacing elements at a single level in a nested list

I want to replace all instances of 0 in the outer most level of a nested list with 1. However, when I use ReplaceAll as ...
Chris's user avatar
  • 973
5 votes
2 answers
145 views

Building Truncatable Primes using Nest(List), While, Fold

Here is a video on Truncatable Primes. I tried to build it myself. Here is what I have tried using the method in the video for left Truncatable Primes. ...
CasperYC's user avatar
  • 1,416
5 votes
3 answers
342 views

How to use FoldList / NestList and Pure function for this?

...
Chen Stats Yu's user avatar
5 votes
1 answer
223 views

NestList: How to have a parameter that is changing as a function of nest index, n?

I have a NestList construction NestList[STEP[#] &, m0, NT] where a function is being called repeatedly that acts on a list and returns a list, for details, ...
anon248's user avatar
  • 604
5 votes
1 answer
93 views

List operation for beginner Usage of #1 and #2 (in stead of using for loop)

I have trouble using list operation of #1 and #2. Could you please tell me how to make it? I prepared the list as below, ...
rani's user avatar
  • 99
5 votes
1 answer
123 views

Nest or fold a series of geometric transforms

I have a requirement to perform a series of GeometricTransformation[]s using the AfineTransform[] function. I use these to set ...
user74549's user avatar
  • 187
5 votes
1 answer
138 views

Recursive nesting with parameter

I would like to apply a function f recursively to an expression expr an arbitrary number of times. However the catch is that <...
typedrums's user avatar
5 votes
1 answer
70 views

Functional iteration of list of functions

I'm getting completely stumped on writing a function makeIterate that constructs an iterated structure out of a list of functions e.g. ...
QuantumDot's user avatar
  • 19.3k
5 votes
1 answer
84 views

What is the most efficient way to implement NestPairWhileList[f,expr,test,g]

Question NestWhileList[f,x,test] lets you iterate a function until a condition is satisfied, outputting the list of iterated values ...
ComptonScattering's user avatar
5 votes
3 answers
88 views

Removing from a sublist, inserting into another one

From a list like test = {{1, 3}, {2,7, 8}, {5,6}}; I would like to randomly select k elements, lift them out of their current ...
Three Diag's user avatar
5 votes
0 answers
125 views

NestList in 12.1/12.2 is 10x slower than 11.3/12.0

Are there any configurations to fix it? Test code: ...
AsukaMinato's user avatar
  • 7,619
4 votes
2 answers
140 views

How do we optimise double Tables?

I have made the following code which I shall explain it in two parts: First Part: ...
Wiliam's user avatar
  • 2,766
4 votes
1 answer
459 views

How to nest multiple functions with multiple variables

I'm trying to solve coupled equations by using iteration. There are two functions $G$ and $H$ that I need to find. In the code, G and H are actually lists of numbers. I start by using a simpler ...
P. C. Spaniel's user avatar
4 votes
2 answers
361 views

Efficient implementation of Non-Maximum Suppression

I would like to know is there is a way to do this: ...
Maria Sargsyan's user avatar
4 votes
2 answers
155 views

Fixed point of a vector

It seems to me that FixedPoint is designed to work with a particular value, but what if we want it to operate on a vector instead? I start with an nxn matrix mat and the function: ...
David Pepper's user avatar
4 votes
1 answer
124 views

Two variable recursive integral equation

I'm trying to improve the question posted in Solving an integral vectorial equation by iterations but when the iterations are for two variables. I mean, suposse that I have the following integral ...
Jorge Castaño's user avatar
4 votes
1 answer
120 views

Iterative comparison between different vectors

I have some soccer outcomes for each league round to import in a data form similar to that: ...
Nate's user avatar
  • 401
3 votes
3 answers
770 views

Iteration on a matrix

I want to update "matrix1" 100 times. "matrix3" will be new "matrix1" and it will iterate 100 times. Should I use a loop or function? First iteration is: ...
ithilquessirr's user avatar
3 votes
4 answers
367 views

Defining a function iteratively without Mathematica getting stuck in a recursion loop

I have the following code: ...
Rain's user avatar
  • 636
3 votes
3 answers
395 views

Better way to do such iteration

Consider such an iteration function ...
matrix42's user avatar
  • 6,697
3 votes
1 answer
140 views

FixedPoint not working, despite quick convergence of sequence [closed]

Trying the computation below, with Mathematica 13.0.0, I am not getting a result returned. FixedPoint[Cos, 0.85] This appears in the 3rd edition of "...
S.V's user avatar
  • 315
3 votes
2 answers
186 views

Using the Fold function with multiple parameter inputs [closed]

I want to construct something like: f[a, b, c, f[a, b, c, f[a, b, c, f[a, b, c, f[a, b, c, f[a, b, c, x]]]]]]. I believe this can be done using the Fold or Nest ...
Stan's user avatar
  • 39
3 votes
3 answers
118 views

Symbolic nest expressions

I'm trying to understand how to use symbolic expressions as arguments. The following example represents my problem: ...
Svetlana's user avatar
  • 153
3 votes
2 answers
122 views

Solving an integral vectorial equation by iterations

I'm triying to solve a problem like the following: $$ \binom{f(t)}{g(t)}=\binom{f_0(t)}{g_0(t)}+\lambda\int_0^t ds\hat{A}(s)\binom{f(s)}{g(s)}, $$ where $f_0(t),g_0(t)$ and $\hat{A}(t)$ (a $2\times2$ ...
Jorge Castaño's user avatar
3 votes
3 answers
110 views

I need to create a series of polygons from a list of lists that form a stair step shape

This code ...
Rogo's user avatar
  • 748
3 votes
2 answers
468 views

two tier compound interest problem

I am trying to make sense of how mortgage repayment figures are calculated for two tier mortgages, where you fix your interest rate for a certain period and after that period, you fall back to the SVR ...
Shb's user avatar
  • 701
3 votes
1 answer
308 views

How can I iteratively add elements to a list

Basically I want to make a histogram with a list of dates by using DateHistogram[]. However I have the data of the dates in nested list format, with elements like ...
Andoni Royo's user avatar
3 votes
1 answer
112 views

Iterative simultaneous numerical optimization of two functions

p = y 10 - 2 x^2 + 5 x; q = 20 y x - y^2 + 2 x; I want to maximize both functions simultaneously (Maximise p to get x and Maximise q to get y). I know that I could ...
Nandan's user avatar
  • 41
3 votes
2 answers
53 views

How to use ReplaceAll iteratively over a list of lists?

I want to build a matrix J for each of the solutions of an equation. And each solution is also a set of 3 variables (x,y,z). In ...
Girardi's user avatar
  • 204
3 votes
1 answer
57 views

NestWhileList stop criteria for second appearecnce of element

How i can stop evaluation of NestWhileList after second zero occurs? In my variant it stops at the first step. ...
Чорны Бусел's user avatar
3 votes
1 answer
152 views

How to use NestList for coupled equations?

I have a code that works for a single equation. How to I use NestList for two equation that are coupled? Below is the code for single equation, ...
Aschoolar's user avatar
  • 883
3 votes
2 answers
224 views

Using NestList?

Here is the code that I have so far: ...
Carrson Baldwin's user avatar
3 votes
2 answers
351 views

Efficient way to iterate over large list and check conditions

The problem I am trying to solve is how to assign charges to a number of particles based on some conditions on the charges. It is conceptually very simple but requires processing a very large list. ...
amasics's user avatar
  • 249