14
votes
How to plot an imaginary number, i, power tower as done in the following way?
Plot the left graph.
...
13
votes
Accepted
13
votes
How to recreate this complex iteration
The theorem is talking about disks and you've plotted a Julia set which doesn't involve transforming any disks, but instead iterates at every point and testing if that point reaches the escape radius. ...
13
votes
Reproduce the annulus fractal
There is some bug in ConicGradientFilling if more than 2 colors are used. (see line at right of each annulus)
Bellow are images ...
12
votes
Accepted
12
votes
Accepted
Create a regular polygon with n vertices given two points
AnglePath.
For two point {x1,y1} and {x2,y2}, at first we locate at ...
12
votes
Accepted
Reproduce the annulus fractal
First, a variation on @azerbajdzan's approach to subdivide an annulus:
...
11
votes
Accepted
10
votes
Accepted
10
votes
What is the most efficient way to define a Loop until function?
Here's a simpler version:
SetAttributes[Until,HoldAll]
Until[body_, test_] := While[body; !test]
10
votes
Accepted
FixedPoint not working, despite quick convergence of sequence
$Version
(* "13.0.1 for Mac OS X x86 (64-bit) (January 28, 2022)" *)
The Possible Issues section of the ...
10
votes
Accepted
Using multiple hashtags in NestList
Use Apply.
NestList[Apply[{#1 + #2, #1 - #2} &], {100, 75}, 5]
10
votes
Create a regular polygon with n vertices given two points
You can use CirclePoints. You just need to transform them:
...
9
votes
9
votes
Accepted
9
votes
Accepted
What is the most efficient way to define a Loop until function?
I tend to use
While[True,
body;
If[condition, Break[]]
]
but what you show is equally good. This is just an alternative.
Try to avoid procedural loops in ...
9
votes
Accepted
What's a functional alternative to nested Do loops?
Defining a function with some side-effect for demonstration purposes.
f[i_, j_] := Echo[{i, j}]
Here are some more WL-esque options:
...
8
votes
Accepted
Iterate over deepest values in a nested Association
Level[assoc, {-1}]
(* {0, "one", 2, 3, 4} *)
8
votes
How can I iterate this process?
C.E.'s answer is great already. I would just like to point out that we may exploit here that floating point addition is usually significantly faster than floating point multiplication that ...
8
votes
Best way to count nest depth in e.g. f[f[f[...[f[x]]...]?
You can define a simple function to do this:
fdepth[f[u_]] := 1 + fdepth[u]
fdepth[_] = 0;
For example
...
8
votes
Replacing elements at a single level in a nested list
I am sure there are a hundred other solutions, but this one does the job and should be reasonably efficient:
...
8
votes
Using multiple hashtags in NestList
The argument being supplied to the function is a list. It's a single argument with head List. So, #2 cannot be bound to anything. You can either use Apply (per cvgmt's answer) or use Part:
...
8
votes
How to plot an imaginary number, i, power tower as done in the following way?
Plotting the real part on the horizontal and the imaginary part on the vertical axis, as is common:
...
7
votes
Delete repeating elements across sublists
You may use a pattern approach with ReplaceRepeated using RandomChoice and Nothing to ...
7
votes
Iteration on a matrix
Another possibility is to write the problem via a recursion:
f[n_] := 2 f[n - 1] + 4;
f[1] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
To get any power, you then ask ...
7
votes
Accepted
NestList: How to have a parameter that is changing as a function of nest index, n?
You can use FoldList:
FoldList[STEP[#, #2] &, m0, Table[ii/NT, {ii, 1, NT}] ]
7
votes
Accepted
How to create a nested list of variable depth with indexed elements
You can try Array:
Array[c, {3, 3, 3, 3}]
...
7
votes
Accepted
Heat transfer with functions defined on different domains
As I understood the question, the polymer is cooled on two sides by the mold. This implies a symmetry condition at the center of the polymer as shown in the image below.
Create mesh
In multi-material ...
7
votes
Using the Fold function with multiple parameter inputs
You could use Nest instead:
Nest[f[a, b, c, #]&, x, 6]
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]...
7
votes
Accepted
Defining a function iteratively without Mathematica getting stuck in a recursion loop
You can define the function(s) recursively:
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
iteration × 197list-manipulation × 43
procedural-programming × 17
equation-solving × 16
iterators × 16
recursion × 14
plotting × 13
functions × 13
performance-tuning × 13
differential-equations × 12
matrix × 11
functional-style × 11
numerics × 9
numerical-integration × 8
calculus-and-analysis × 7
function-construction × 7
mathematical-optimization × 7
integral-equations × 6
fractals × 6
map × 5
pure-function × 5
infinite-loop × 5
nested-function × 5
graphics × 4
complex × 4