Questions tagged [iteration]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
10
votes
3answers
808 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 ...
7
votes
2answers
402 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 ...
6
votes
2answers
150 views

How to iteratively build a list?

I have the following c++ code that I want to translate to Mathematica. ...
5
votes
3answers
250 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: ...
4
votes
2answers
129 views

How do we optimise double Tables?

I have made the following code which I shall explain it in two parts: First Part: ...
4
votes
1answer
86 views

Iterative comparison between different vectors

I have some soccer outcomes for each league round to import in a data form similar to that: ...
3
votes
3answers
594 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: ...
3
votes
2answers
136 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. ...
3
votes
2answers
94 views

Working Iterative formula for a system of equations

I have been given a project, I need to show the use of a version of Newton's method to solve these non-linear equations. The version of Newton's method I am required to use is: $ X_{n+1} = X_n - J^{(-...
3
votes
2answers
76 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: ...
3
votes
1answer
58 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 ...
2
votes
1answer
73 views

Question about iteration [closed]

I have the following expression: sol1 = (11 + 3*δ - 11*θ + 4*m*θ - 3*δ*θ - 8*Sqrt[(-(2 + δ))*(-1 + θ)*(1 - θ + m*θ)])/(4 + 4*δ) I want to plug numbers into $ \...
2
votes
1answer
32 views

Get all step values from a while-loop

I did a loop (first of my life) for an iterative calculation. Is it possible to get all step values as a matrix. That means the "xValue" variable should be like {215.108,219.688,...} and not only the ...
2
votes
2answers
97 views

Running a notebook which imports and exports files repeatedly

I am trying to automate the process of running a Mathematica notebook that takes as an input a .txt file and exports another .txt file. This notebook was not written by me, and I don't fully ...
2
votes
1answer
154 views

Solving for the recursion relation for the expansion coefficients of the asymptotic expansion of an ODE

I want to solve for the asymptotic solution of the following differential equation $$ \left(y^2+1\right) R''(y)+y\left(2-p \left(b_{0} \sqrt{y^2+1}\right)^{-p}\right) R'(y)-l (l+1) R(y)=0$$ as $y\...
1
vote
2answers
163 views

FixedPoint doesn't work

Do you know why it doesn't print any result?I set intial value is 0.1, h[x_] = Sin[x]; (*Plot[{x,h[x]},{x,1,50}]*) FixedPoint[h[#] &, 0.1];
1
vote
2answers
75 views

How to iteratively (or most efficiently) create such list?

Update A very crude attemp ...
1
vote
2answers
72 views

Apply NestList to Iteratively Calculate Gradient (Gradient Descent)

I'm attempting to calculate the gradient of a function defined by two variables. After following a tutorial I found, I have the following code: ...
1
vote
2answers
135 views

How can I solve iteratively for $\Sigma(r)$, T(r) and h(r)?

My naive attempt: ...
1
vote
3answers
90 views

Create a new matrix from an existing matrix and then plot it

I have some code will test an equation and finds values for (n,j,k,l) in which the expression is true and puts them in the matrix - here is the code. ...
1
vote
1answer
62 views

Iterative Bisector Method for finding the minimum of a non - differentiable function [closed]

I would like to automate a process to find the minimum of a non-differentiable function, perhaps using a similar system as the bisection method but adapted to finding minima instead of roots. Any ...
1
vote
1answer
101 views

Iterating of piecewise function

I have this piecewise function $$ f(x)=\begin{cases} x(1.5-0.5x) \quad\text{if $x\le0.5$},\\ x(0.5+0.5x) \quad\text{if $x>0.5$}. \end{cases} $$ How can I calculate iterated functions for it?
1
vote
1answer
23 views

cannot get EvaluationMonitor to output number of iterations taken to find a root

I was given the following problem: Consider the equation x = exp(-x2). Plot the two curves on the same plot to get a rough idea of the intersection point. Then use a built - in function (e.g. ...
1
vote
1answer
57 views

Bug in FindRoot?

...
1
vote
0answers
34 views

Recursion depth of 1024 exceeded during evaluation of … when importing a directory with many files

I'm doing this: Import["/Volumes/Transcend2/images/", "*.jpg"]; And getting these errors: Then, after it's done, when I type "images" and shift+enter, I just ...
1
vote
0answers
38 views

Need help with understanding a question concerning the power iteration method [closed]

I just need help understanding a question. I was given the question Use the power iteration method to estimate the spectral radius for (I - B A) given a tridiagonal coefficient matrix. Although,...
1
vote
0answers
100 views

Question about approximate squaring iteration [closed]

the iteration map $x*\left\lceil x \right\rceil$, where the initial term is a non integer rational number $b/a$ with $b>a$ and $a>1$. the growth rate of this iteration is similar to the growth ...
0
votes
2answers
79 views

Nested For Do Table cycle problems

I got England and German soccer data with the following: ...
0
votes
1answer
69 views

Solving a system of linear equations with a For-loop [closed]

I need to find the value of c1, c2, c3, c4 and c5, but the output from my code is the simplified equations, not the exact value ...
0
votes
1answer
116 views

How to create a list of undefined functions?

I have a undefined function $\phi[i,j]$ where $i=0,1,...,m$ and $i=0,1,...,n$. How can I generate this list: {$\phi[0,0],\phi[1,0],...,\phi[m,0],\phi[0,1],\phi[1,1],...\phi[m,1],\phi[0,2],...,\phi[m,...
0
votes
2answers
40 views

Current iteration number in “do” command

How can I obtain the current iteration number of the "Do" command? For example I want $N$ to be my iteration number in the following command: ...
0
votes
1answer
31 views

Reading and re-assigning variable

I am trying to create a table by iteratively calculating its values using a temporary variable accu: ...
0
votes
1answer
111 views

How to use a test function correctly to terminate a While loop?

I define a test function in order to stop my While loop: ...
0
votes
2answers
86 views

In an iterative process, how does one simply bypass a step producing an error? [closed]

This is undoubtedly rather elementary, but the remedy escapes me presently (and does not, as far as I can see, readily appear in Help). I'm engaged in an iterative process with several computations ...
0
votes
1answer
69 views

Solve integral equation by iteration

For[{n = 1, y[0][x_] = 1}, n < 4, n++, y[n][x_] = 1 + Integrate[y[n - 1][t]^2 + t^2, {t, 0, x}]; Print[{n, y[n][t]}]] here how can I get table of values ...
0
votes
1answer
176 views

How can I create loop for this iteration integration [closed]

I have definite integral of the form $$f(x)=\int_{-\pi}^\pi\frac{x^2-1}{(x^2-1)^2+x^2+y^2+f(x)}dxdy$$ I want to make a code to calculate $f(x)$ numerically, starting from $f(x)=0$ and stopping when ...
0
votes
1answer
149 views

Plotting Data Iteratively

I have a function of x1 that I can plot in the form y=f(x1). However, I have a relation y=f(x1)=f(x2), where I don't know the form of f(x2), but I can solve for x2 given f(x1) and I want to plot both ...
0
votes
1answer
24 views

Table of convolutes

Inputs Start with a vector $x\in\mathbb{R}^{n}$, and a vector-valued function $f:\mathbb{R}^{n}\mapsto\mathbb{R}^{n}$. Output Given some $k\in\mathbb{Z}^{+}$, what are elegant ways to produce the ...
0
votes
0answers
42 views

Numerical solution to Integral equation by iteration

I want to solve the following integral equation $$ \rho(\theta)=\frac{\rho\exp[-2L^2D\int_{0}^{\pi} d\theta'\sin\theta'K(\theta,\theta')\rho(\theta')]}{\int_{0}^{\pi} d\theta''\exp[-2L^2D\int_{0}^{\pi}...
0
votes
0answers
32 views

Running Nestlist with multiple functions

I want to create a iteration with a loop for my Nestlist with multiple functions. The following code is a very simplified one. ...
0
votes
0answers
27 views

Nested for loop with variable length

I am new to mathematica and I want to create the set of all n-tuples whose sum is less than a fixed number $N$. My idea would be to do a for loop where I choose first number $k_1$ in between 0 and N, ...
0
votes
0answers
21 views

Optimization of storages capacity

Consider a series of storages where different goods are added into daily. I would like to optimize the distribution of these goods between the storages in a way which takes into account some ...
0
votes
0answers
51 views

Iterating over a list and defining the range accordingly

I have the following list, l = {{"a", "b"}, {"a", "b"}, {"c", "d"}, {"e", "f"}, {"e", "f"}, {"x", "y", "z"}, {"m", "n", "o"}, {"p", "q", "s"}}; for each ...
0
votes
2answers
182 views

solve the iterative integral equatio [duplicate]

The following code is incorrect, please specify my mistakes ...
0
votes
0answers
52 views

How to save a all matrices renewed in each iteration?

I have a (n by m) matrix , in which the elements are recalculated and replaced by new ones in each iteration. (In other words I have a loop in which the elements of the mentioned matrix are being ...
0
votes
0answers
43 views

Function iteration

I wrote a function in Mathematica that applies certain construction steps on the "incidence matrix" of a graph in order to obtain a new graph with certain properties. These construction steps can be ...
0
votes
0answers
106 views

How can I make my code containing a For loop more Mathematica-style?

I know there are a lot of questions on this site regarding the use of For loops and how to avoid them in Mathematica. However, in my case I believe it is justified,...
-1
votes
1answer
61 views

Is there a way to get values from a set of functions with circular dependencies? [closed]

I am using the following code to find iteratively the functions $\Sigma(r)$, $h(r)$ and $T(r)$ ...
-2
votes
1answer
88 views

turn infinite loop into finite loop

I am trying to make a table where I can save the stock value with the iterative part, where I should have 100 sequence with 843 entry in each sequence. The loop doesn't run correctly in the sense ...