Skip to main content

Questions tagged [iteration]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
13 votes
4 answers
386 views

Reproduce the annulus fractal

I've made some attempts, but I don't know how to set the color and thickness of the circle. ...
vector's user avatar
  • 201
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,780
10 votes
3 answers
698 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
746 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
834 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,652
8 votes
1 answer
1k 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
7 votes
2 answers
452 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
  • 867
7 votes
2 answers
358 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
344 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
4 answers
636 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
  • 1,043
6 votes
2 answers
373 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
359 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
485 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
86 views

RecurrenceTable and While

Good day. Let's take an example from Help on RecurrenceTable: ...
macros's user avatar
  • 99
5 votes
5 answers
555 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
  • 763
5 votes
3 answers
297 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
  • 589
5 votes
1 answer
297 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 ...
Arji's user avatar
  • 1,134
5 votes
3 answers
330 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,511
5 votes
2 answers
148 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,632
5 votes
3 answers
369 views

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

...
Chen Stats Yu's user avatar
5 votes
1 answer
269 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
  • 614
5 votes
1 answer
104 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
  • 343
5 votes
1 answer
135 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
  • 197
5 votes
1 answer
158 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
74 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.7k
5 votes
1 answer
92 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
92 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
126 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
  • 9,948
4 votes
2 answers
236 views

Given two functions, generate all nested applications of the functions to a given order

I have two functions $f$ and $g$. Given some order parameter $n$, I want to created all nested applications of $f$ and $g$ and save them in a list. For example, for order 1 we will have ...
JohnnyB's user avatar
  • 95
4 votes
2 answers
117 views

How to use functional iteration with changing function?

I recently came across this problem on reddit. The problem is supposed to be read like a snake, and the result of each succesive operation is sent to the next operation: There are 9 blank boxes and ...
ydd's user avatar
  • 3,937
4 votes
2 answers
146 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
  • 3,016
4 votes
1 answer
500 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
363 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
232 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
181 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 ...
Albus Black's user avatar
4 votes
1 answer
131 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
859 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
3 answers
211 views

How to reuse an iterator in different functions?

How can I reuse iterators? For example, instead of Table[i, {i,0,10}] Table[i^2, {i,0,10}] Table[f[i], {i,0,10}] write something like ...
homocomputeris's user avatar
3 votes
4 answers
407 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
412 views

Better way to do such iteration

Consider such an iteration function ...
matrix42's user avatar
  • 7,138
3 votes
1 answer
152 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
3 answers
120 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
284 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
2 answers
130 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$ ...
Albus Black's user avatar
3 votes
3 answers
119 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
  • 930
3 votes
3 answers
85 views

How to do simple list traversal? And how do I insert this in a function?

I want to make a function that takes as input a list of numbers and returns a list of 4 lists; the first returned list holds all positive real; the second returned list all negative real; the third ...
golden77's user avatar
3 votes
2 answers
577 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
340 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
135 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
  • 61