Questions tagged [iteration]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
0 answers
43 views

Recursively create Graph from seed and Nest GraphUnion, keeping VertexStyle, EdgeLabels, VertexCoordinates, EdgeShapeFunction

TL;DR; GraphUnion does not preserve properties of the input Graphs. How do I combine two ...
  • 31.2k
0 votes
1 answer
79 views

How to find a specific spanning subgraph?

A spanning subgraph is a subgraph that contains all the vertices of the original graph. Given a graph $G$, I would like to write a function $f$ for finding a spanning 5-regular bipartite connected ...
  • 1,179
6 votes
4 answers
305 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, ...
  • 863
0 votes
0 answers
22 views

Difference between SubstitutionSystem and StringReplace

I'm examining two-step substitution model: First step, division: {"A" -> "BC", "B" -> "AC", "C" -> "AB"} Second step, merging: {&...
  • 531
3 votes
1 answer
100 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 ...
  • 41
0 votes
0 answers
56 views

Exponents in my Nest?

While playing around with nests I got an answer from WolframAlpha that I can not quite comprehend. For reference I was inputting power towers in Nesting form. Nest$[x^{\#1} \&, 1, 2]$ For example. ...
1 vote
1 answer
53 views

How do I construct and plot functions properly using NestList?

I am trying to construct a function using NestList and plot the values. Although the individually used and defined functions in my notebook seem to do the right ...
4 votes
1 answer
90 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 ...
3 votes
2 answers
114 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$ ...
1 vote
2 answers
90 views

Using Loop to find a specific Energy

I am given a Hamiltonian: ...
  • 585
3 votes
3 answers
104 views

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

This code ...
  • 649
2 votes
1 answer
223 views

What's a functional alternative to nested Do loops?

How can I use functional code to achieve the same effect as the following procedural code Do[ Do[ f[i,j], {j,1,m} ], {i,1,n} ]
0 votes
1 answer
121 views

Plotting fractals in Mathematica for S iteration

Dears, I'm trying to plot the attached picture figures in Mathematica software. Let $T(z)=z-\frac{P(z)}{P^{\prime}(z)}$. The S iterative scheme is for $z_{0}$ a starting point and $y_{n}=(1-\beta_{n}...
  • 161
0 votes
0 answers
72 views

Solve two equation by fixed point iteration method

I am tryin to reproduce the figure.2 of this paper. In order to obtain this plot, I need to find the global minimum of equation.(7) or equivalently solving two coupled equations of $\frac{\partial \...
  • 63
0 votes
1 answer
122 views

Mathematica does not show anything after running for higher iterations

Consider a BVP: $y^{\prime\prime}=\frac{3}{2}y(t)^{2}$ with the boundary conditions $y(0)=4$ and $y(1)=1$. The exact solution is $y(t)=\frac{4}{(1+t)^{2}}$ and the initial guess is $y(t)=4-3t$. Now I ...
  • 161
0 votes
1 answer
94 views

Implementing While loop in module that will iterate correctly

I am attempting to write a module that prints an optimal path from a starting node to a destination node. The first node is 1 and the final node is 100 (though when module prints these they should be ...
  • 65
0 votes
0 answers
53 views

Solving numerically Pdes and Odes and Iteration processes

Dears, I have the following equations: $x^{\prime\prime}(t)=\frac{3}{2}x(t)^{2}$ with $x(0)=4$ and $x(1)=1$. The exact solution is $x(t)=\frac{4}{(1+t)^{2}}$. Now the corresponding operator is $ Px=x+\...
  • 161
3 votes
1 answer
128 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 "...
  • 315
5 votes
3 answers
259 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 ...
  • 1,249
2 votes
3 answers
259 views

Nested floor functions

I would like to compute a limit involving a particular nested floor function. For example: ...
3 votes
4 answers
322 views

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

I have the following code: ...
  • 618
1 vote
3 answers
61 views

Digits product and an iteration process

I would like to create a code which gives me the square of the product of the digits of a number, with the only rule that if a number has a 0, then it doesn't count in the product (for example, if the ...
0 votes
1 answer
154 views

I'm beginner and do not how to plot the Basins of attraction by the methods

For a complex polynomial $P(z)$, define $T$ by $T(z)=z-\frac{P(z)}{P^{\prime}(z)}$, where $P^{\prime}(z)$ is the first derivative of $P(z)$. We consider Newton method for finding the roots of ...
  • 161
0 votes
1 answer
141 views

How to use for loop in Mathematica?

in most of my job I have to repeat something for different part of data, for example making plot, usually the only thing need to change is index. Below is the example of the code which I have to ...
  • 383
1 vote
1 answer
53 views

Why each iteration takes longer than previous one when using VariationalD in this loop?

I have a function $f$, and I would like to modify it iteratively to approach another one called $a$ (not because I think this is the best way to do anything, but for experimentation). For this, I use <...
  • 137
10 votes
2 answers
475 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). ...
0 votes
1 answer
100 views

Spurious renaming in nested Function construct

From the documentation of Function, I take this example (slightly simplified). Renaming the dummy or bound variable (y->y$ in the inner ...
5 votes
2 answers
349 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 ...
  • 889
0 votes
0 answers
74 views

FindRoot doesn't find root

I am facing a problem that my FindRoot doesn't find the actual roots. I am trying to make a loop that iterates my parameter sets (U0,X0,\Sigma0) to find sets that satisfy some conditions. Here is my ...
  • 109
0 votes
0 answers
90 views

The use of `NestList `

After read Michael answer, code use NestList to compute and feed in numerical integration. I want to learn this idea into my code. In the ...
  • 445
0 votes
0 answers
52 views

Converting 1D map into first order differential equation for bifurcation diagram code

I have existing code to plot bifurcation diagram for coupled first order differential equations. It seems to work for coupled differential equations. To test the code further, I use the simplest ...
  • 863
0 votes
0 answers
37 views

Flatten a pair of matrices within a list of matrices

I have a list of matrices, which I think is better to give an example using the code. ...
0 votes
0 answers
36 views

Force list of colours to have same grayscale value, maintaining hue

A sketch of what I'd like to achieve is given by ...
  • 8,005
5 votes
5 answers
522 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 ...
  • 626
1 vote
1 answer
53 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 ...
3 votes
1 answer
143 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, ...
  • 863
2 votes
1 answer
151 views

Repeating and Sequencing Procedures with two Do-loops

I have a Do loop where I'm looking for the value of certain parameters that respect the conditions inside an If, and with those values, a run another Do to make another calculation of an expression ...
3 votes
2 answers
130 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 ...
  • 39
0 votes
0 answers
111 views

Iteration limit exceeded

I am trying to adapt the following piece of code (coming from this answer): ...
  • 6,214
0 votes
0 answers
68 views

How to use NestWhile to get it to work the way I want?

I have a vector th={0,0,...,1.57}. Now I want to choose the second element and change it by stepsize 0.2 until it is less than 1.57, I need these set of vectors: th={0,0.2,0,...,1.57} th={0,0.4,0,...,...
6 votes
1 answer
311 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 ...
  • 239
5 votes
1 answer
281 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 ...
  • 1,124
6 votes
1 answer
80 views

RecurrenceTable and While

Good day. Let's take an example from Help on RecurrenceTable: ...
  • 99
5 votes
0 answers
123 views

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

Are there any configurations to fix it? Test code: ...
  • 6,827
1 vote
0 answers
105 views

FoldList and Compile [closed]

Let me elaborate my previous question about Foldlist and Composition. ...
  • 99
1 vote
0 answers
98 views

FoldList with Composition and parameter

Good day to everyone! I have two (just for simple example) functions and they compose a map: ...
  • 99
2 votes
1 answer
131 views

Generating a lattice by $𝑁^{𝑡ℎ}$ iteration of unit cell

This question is in continuation of the my previous question that was not clearly presented by me at all. I have a unit cell, and I would like to generate a lattice but in iterative order. For ...
  • 673
5 votes
1 answer
63 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. ...
1 vote
1 answer
95 views

How do I correctly iterate using Outer when an argument / slot is a nested list?

I have the following complex nested iteration situation. I begin with a list, data, that comprises 16 TemporalData objects Each TemporalData object contains 2 ...
  • 115
0 votes
0 answers
44 views

Why Mathematica doesn't compute the permutation products in my NestList[]?

I wrote the following: K = DihedralGroup[5]; K = GroupGenerators[K]; y = K[[1]]; x = K[[1]]; l = NestList[PermutationProduct[x, y], x, 4] But Mathematica gives me ...
  • 4,911