Questions tagged [iterators]

Questions on using and specifying iterators used in Mathematica functions.

Filter by
Sorted by
Tagged with
1
vote
0answers
71 views

For- loop which can reuse updated values [closed]

Eout = E^x ; For[kz = 1, kz < 4, kz++, Print[Eout1[kz] = Eout]; Print[kz]] The output is E^x 1 E^x 2 E^x 3 But what ...
4
votes
3answers
333 views

Dot products and For-loops

I'm taking a class where we're working with matrix applications inside of Mathematica. In this case, we're analyzing senatorial votes that have been numericized so that a value of 1 corresponds to "...
1
vote
2answers
76 views

How can I iterate across a list of triples?

i just started to use Mathematica and I`m completely new to programming. So i'm some kind of noob in the purest form.. I'm trying to transform a coordinate system into a different one. I'm using <...
0
votes
1answer
70 views

Creating matrices using a Do-loop

Here is an image of current assignment; I am not able to do step 6 to 8 When I try to do the Do-loop, it states that the {i, j} does not have appropriate bounds. ...
1
vote
1answer
47 views

ListCountourPlot does not show any result [closed]

I was trying to show the heat conduction of Laplace equation problem.But the plot does not show properly ...
1
vote
1answer
66 views

Defining iterative algorithms [closed]

Assume the iterative algorithm of interest to be as follows: ...
1
vote
2answers
174 views

Multivariate Newton-Raphson method and FindRoot module [closed]

Let's suppose that we have the following equation ...
1
vote
1answer
140 views

Golden section search method that terminate after $n$ iterations

I am attempting to code a program that executes the golden section search method and I would like to terminate the computations after $n$ iterations, where the user decides what $n$ is. My code works ...
10
votes
3answers
425 views

How to programmatically specify multiple iterators?

How to use Row[Table[{B[i],0,i},{i,0,2}],","] directly in Do command? I mean that the following command ...
3
votes
1answer
320 views

Encountering 'Error: Set::setraw: Cannot assign to raw object' during procedural function definition

Sorry for the rather vague title, but I don't know what is wrong with my code. Here is a Ruby version of what I'm trying to do: ...
2
votes
1answer
77 views

How to change the dimension of a tensor inside a loop using XAct/XTensor?

I'd like to define a function CDOrder[k] to compute the k-th order covariant derivative of a vector ...
0
votes
0answers
95 views

Operation on sublists with multiple arguments

I have a list and add only the values which are > 0 with: Total[Cases[mylist, x_ /; x > 0]] How to do this if I now have a list of sublists? ...
4
votes
2answers
125 views

use Range to form a vector

I have a function y[k_]:={0,0,0,I*t^k}; and I need to get a vector Join[y[1],y[2],y[3],y[4],y[5],y[6],y[7]] and it is just ...
6
votes
4answers
431 views

Applying loop functions with input list of iterators

Given an iterator, I am trying to generate a table of all possible pairs of values. The form of the iterator I'd like fixed, because I want to run other loops with it as well. The closest to what I ...
0
votes
0answers
63 views

Iterating a Module

I have a Module that can act on other Modules, which is given as Kk[EE,p,z1,z2,z3,K_func] and I am trying to iterate it, such that ...
1
vote
2answers
93 views

What is wrong with the Mann iteration?

I have written the Mann iteration's code for the mapping $\frac{z}{1+z^2}$, in Mathematica, but it is very slow. In fact it needs more than 200 seconds for obtaining 17th iteration, while Matlab does ...
1
vote
3answers
166 views

integral equation iteration

So I am trying to recreate the numerical treatment in this papir (https://journals.aps.org/prb/abstract/10.1103/PhysRevB.29.130), equation 3.7. The main point is to try to solve the following equation ...
1
vote
1answer
57 views

How to implement recurrence operations efficiently?

This question is related to this one. I basically want to partition a volume recursively. Consider a volume as vol = ExampleData[{"TestImage3D", "MRbrain"}]; ...
1
vote
0answers
50 views

Using Iterators within the WebSearch Command

I am currently trying to use the WebSearch command within Mathematica to search names from a Dataset that I have already imported. The names that I am trying to search are located in the 4th column of ...
1
vote
1answer
85 views

Iterator order breaks Table

Evaluating the following Table expression ...
0
votes
0answers
76 views

Variables defined modulo $\pi$ and avoiding singularities; phase plotting for a map

I have the following $2$-dimensional implicitly defined map ...
2
votes
1answer
138 views

How to plot a phase portrait of a map for many initial points?

Suppose I have a 2-dimensional map $x_{n+1} = f(x_{n},y_{n}), \quad y_{n+1} = g(x_{n},y_{n})$, and a number of initial points $(x_{0}, y_{0})$ in some given range. I take each initial point and ...
5
votes
4answers
229 views

Add function arguments in iteration

I have a list which has the number of n. list={x1,x2,x3,x4,x5,...xn} when I use these elements as arguments of a function f[x], I want to express function with ...
1
vote
2answers
182 views

Comparing elements in a list of lists

I'm stuck with yet another list question. The basic gist: I have lists within a list like so: ...
1
vote
1answer
66 views

How to run this statement multiple times and put them in a matrix?

I have the following Mathematica Code. ...
0
votes
2answers
151 views

Replacing For loop with multiple iterator with Table

I have written code for calculating cristofell symbol using for loop with 3 iterators for each coordinate ...
0
votes
1answer
56 views

How to make a continuous graph in 3D under an iterative process?

I'm solving a problem in which I have to plot a series of image points $P'$ from a set of points $P$ that lies 5 cm away from a sphere with radius 2 cm, in such a way that all $P'$ lies inside the ...
1
vote
2answers
159 views

Plotting orbit of a discontinuous map

I'm trying to plot the orbit of a two dymensional discontinuous map. Could you help me please? I tried using Piecewise, but I didn't get the result I wanted. The ...
0
votes
1answer
46 views

Creating a list using previous elements

I am new to stack exchange though I have used it to help me through some struggles before. This question I cannot find an answer to. I'm looking to create a set of polynomials where the 'i'th ...
3
votes
1answer
142 views

Access list position from iterator?

Consider a list, e.g.: list = {a,b,c,d}; One can compose a Table by directly iterating through the list: ...
9
votes
2answers
416 views

multiple reflections of a laser beam in a triangle

I want to make a animation that multiple reflections of a laser beam in a triangle looked like, I have tried following, but it's not a good way, I'm looking for a better way(Nested solution). ...
1
vote
1answer
52 views
0
votes
0answers
112 views

Slow evaluation of large matrix

I have been trying to evaluate the matrix ce[n] in the code below but it is taking too long and still running as you increase n (...
0
votes
2answers
140 views

Efficiently get primes in range

I first had an iterative method, which ran sufficiently fast: ...
1
vote
1answer
183 views

Problem generating a cobweb diagram/ visual iteration of a cubic map

With reference to "Non-linear Physics with Mathematica for Scientist and Engineers", I extrapolate the codes for a visualisation of an iterative cubic map but ran into problems. ...
0
votes
2answers
70 views

Iterating a function

I have a piecewise map of the form $M\left ( x \right )=\left\{\begin{matrix} 2x & x<0.5 \\ 2-2x& x>0.5 \end{matrix}\right.$ The domain is the closed interval from 0 to 1. I would ...
0
votes
1answer
48 views

NestWhile expression adds an extraneous [0] to the expected result

I am trying to iterate a function over 1000 time units using the NestWhile function and Table functions in Mathematica. I have defined all my variables and my function as follows: ...
4
votes
1answer
99 views

How to implement an iterative Lucy algorithm in Mathematica?

I am trying to implement the Lucy algorithm that the authors of this paper use to get a distribution of diffusion coefficients from the distribution of displacements. The equation looks like this. $$...
1
vote
3answers
76 views

Can you determine values in a set of integers from a known set sum and set product

Question: There is a set of numbers defined as {A, B, C, D, E} The sum of the set is 49 (A+B+C+D+E = 49) The product of the set is 13000 (ABCDE = 13000) Can you determine the values of A, B, ...
2
votes
4answers
111 views

Writing an iteration using two functions [closed]

I have been given two functions with an initial condition. One function becomes the variable of the other. I need to run the program for 10 iterations. ...
24
votes
3answers
1k views

Modeling the spread of an infection in networked computers

I would like to show the iterative stages of infection for problem 2 in this link. In case the link dies, I have copied the text for the problem below: One hundred computers are connected in a ...
0
votes
2answers
57 views

Collect function with iterator issue

I've got the following code for the first few terms of an expansion. I want to collect the terms in increasing powers of (s/r) but using an iterator. The code is as ...
2
votes
2answers
122 views

Replacement rule within a iteration with a new replacement needed at each step

I am trying to do a For iteration where at each step, the code solve an equation and use the result for the next step. Nevertheless, I am struggling with the replacement rules that I need to use. I ...
1
vote
1answer
269 views

Help with Function of Do or Nested For Loop [closed]

I'm trying to define a function that calculates a variable 'prob'. Here's the function in Octave: ...
2
votes
1answer
89 views

Floor function not behaving the way I expect inside a For loop

When I execute the following code ...
0
votes
0answers
174 views

Iteration problem using NestList or Do

I am trying to model a tank with discontinuous flow into the tank and discontinuous flow out of the tank. I do it numerically. You can imagine a tank to which I feed blue balls at timepoint t0, red ...
1
vote
1answer
70 views

How to iterate over an “Input” function?

I wasn't sure what to name this title, I will explain this code just incase some people actually aren't running it on Mathematica..This code will ask you "what is #1 * #2", where #1 and #2 are random ...
12
votes
2answers
312 views

RecurrenceTable iteration variable not localized? Bug or user error?

I recently lost a lot of time on this and need to understand whether I have misunderstood MMA operations or there's a problem. I am using MMA 10.1 on Windows 7 64-bit. The essence of the issue is ...
5
votes
2answers
100 views

Sophisticated use of Nest: Using the current iteration number and referring to outer lists

I want to write an iterative algorithm on the base of Nest (avoiding usage of cycles) to create an expression of the type $$ x^{a_1x^{a_2x^{\ldots}}} $$ where the numbers $a_1, a_2, \ldots $ are given ...
1
vote
1answer
518 views

How to apply a function of multiple variable to multiple lists [duplicate]

Im new to mathematica ( from a python background) so apologies if this is easy. I have four lists of equal length from a data set. I would like to iterate through each of the lists and apply a ...