# Tag Info

Accepted

### Visualizing gravity warping the fabric of spacetime

Here my physicist approach to the problem: I consider a cloud/grid of test-particles which get attracted to a reference point by a force. In the following I assume attraction by gravity -- i.e. the ...
• 3,410
Accepted

### Mapping function across its arguments

Tuples[expr, 1] (* {f[a], f[b], f[c]} *)
• 941

### C++' "do ... while" loop equivalent in Mathematica

Version 13.1 introduced the function Until Until[test,body] evaluates body and then test, repetitively, until test first gives True.
• 69k

### Mapping function across its arguments

Using Subsets: expr = f[a, b, c]; Subsets[expr, {1}] (*{f[a], f[b], f[c]}*) Or using ...
• 26.2k
Accepted

### Apply a function row- and columnwise

If we change dt to: ...
• 238k
Accepted

### Curve shortening flow

This is roughly the algorithm in the link. Like it says there, it's potentially numerically unstable. The funny curlicue example in the OP was not provided, so I can't check that. In fact, most of the ...
• 3,405

### Mapping function across its arguments

Operate[Map[#]@*List &, expr]
• 30.3k
Accepted

### Why doesn't b = a; f[a_] := b; f[2] return 2?

Caution The post is long. If you just want to know how to fix the code, please search "fix the code in title in 10 ways" in the page. If you want to read discussions about global/local ...
• 67k
Accepted

### How can I change elements in a matrix to a combination of other elements?

A simple way would be to define a function to transform a single triple: transform[{x_, y_, z_}] := {x + Cos[z/x], y, z - Sin[z/x]} and then map it over your list: ...
• 30.3k

...
• 20.3k

### Mapping function across its arguments

Some alternatives: f[a, b, c] // #[[0]] /@ Level[#, 1] & (* {f[a], f[b], f[c]} *) f[a, b, c] // #[[0]] /@ List @@ # & (* {f[a], f[b], f[c]} *) Sharper, ...
• 3,405

### Create n random points on [0,1] with minimum distance

If you want to generate independent random samples under the stated restrictions and $s<1/(n+1)$, then consider the following: ...
• 41.9k
Accepted

### Functions, Speed, and Evaluate[]

It's the automatic simplification of the expression that spends the additional time. Compare the following two definitions of a function: ...
• 27.4k
Accepted

...
• 160k
Accepted

### Trick to apply function on a variable and store output in the same variable

Yes, there is ApplyTo with a shorthand notation //=. var //= AnyFunction
• 27.4k

### How can I change elements in a matrix to a combination of other elements?

Equivalent to @lericr`s answer except a pure function is used rather than defining a helper function ...
• 160k

### How can I change elements in a matrix to a combination of other elements?

Another way using Cases: ...
• 26.2k

### Mapping function across its arguments

expr[[0]]/@{Delete[0][expr]} (* {f[a],f[b],f[c]} *) or ...
• 20.3k

### Mapping function across its arguments

expr = f[a, b, c]; Using BlockMap BlockMap[# &, expr, 1] Using ...
• 4,961

### Create n random points on [0,1] with minimum distance

Thanks to the comment from Izaak van Dongen, it can be solved with straightly : umd[n_, s_] := Sort[RandomReal[{0, 1 - (n + 1) s}, n]] + s Range[n]; Pick ...
• 4,315
Accepted

### How to use || as a function name and apply it to calculate the equivalent resistance of parallel resistors as we typically write?

It won't work with || for reasons described in the comments. However, you can use a unicode character or ...
• 25.6k

### Module that finds the sum of digits of any given positive integer

Mathematical v14.0 introduced DigitSum. For example: DigitSum[2525] (* 14 *) DigitSum ...
• 5,235

### Visualizing gravity warping the fabric of spacetime

Related posts:In general relativity vizualizations what are the equations of grids? How exactly does curved space-time describe the force of gravity? Solving the physics equation makes the problem ...
• 874
Accepted

...
• 160k

### Plotting multiple parametric 3D curves without using the Show command

To get different colors automatically for a plot, the idea is to do this data=.... (*generate list of data*) Plot[Evaluate[data],.....] What you did is generate ...
• 146k

### How to stop mapping on true results for large lists?

The AllTrue function will short circuit. AllTrue[list, EvenQ] But I may have misunderstood, because you said you want short-...
• 30.3k

### How to stop mapping on true results for large lists?

You can use AnyTrue. AnyTrue short-circuits on first True result and returns ...
• 42.4k

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

First level a = {f[x], g[x]}; Second level b = Flatten @ Transpose @ Query[All, {f, g}] @ a {f[f[x]], f[g[x]], g[f[x]], g[g[x]...
• 78.8k
Accepted

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

Using Composition: ...
• 55.7k