16
votes
Accepted
Finding an ellipse of minimum area that encloses a set of points
You are looking for BoundingRegion with the "MinEllipse" region specification:
...
15
votes
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.
12
votes
Accepted
Which functions use a given option?
You can use WolframLanguageData with the property "SymbolsUsingAsOption" for this:
...
12
votes
How to optimize performance with DeleteDuplicates?
In checking duplicates, you are considering 2, 4, 6, 8, 10 are the same as 1, 3 ,5, 7, 9, respectively.
Then, instead of testing all possible replacement, I recommend you to convert into standard ...
11
votes
Accepted
10
votes
Stopping mathematica from rearranging elements in a list
You can use DeleteElements which came with V 13.1:
...
10
votes
Accepted
9
votes
Perform Apply[] to a sum of objects
As of version 14.0, ComapApply is introduced:
ComapApply[f + g, {a}]
(* f[a] + g[a] *)
ComapApply[f + g]@{a}
(* f[a] + g[a] *)
...
9
votes
How to raise a vector to powers contained in a vector, change the list into a product, and do this for all the lines of a matrix, efficiently?
Use Inner
Inner[Power, var, #, Times] & /@ expo
(* {x[1],x[2],x[3] x[4],x[2] x[5]} *)
8
votes
Is there a better way to achieve the same result with {f[#],g[#]}&@list?
In version 14.0, Comap was introduced exactly for this purpose:
...
8
votes
Accepted
How to draw an image similar to a periodic function (f [x+1]=2 f [x])?
Edit
For x<0,we rewrite f[x+1]=2f[x] to `f[x]=f[x+1]/2;
...
8
votes
Accepted
How to use the symmetry of a function to find the analytical expression of a function on a certain interval?
f[-x] == -f[x] means that the graph is point reflection respect to {0,0}.
f[1-x]+f[1+x]==2 ...
8
votes
Accepted
Reversing the order of function arguments by a replacement rule
expr = g[x3, x2, x1];
You must use RuleDelayed (:>) instead of Rule
...
8
votes
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 ...
8
votes
Blurry shadows of 3D plots and objects
I've tried adding multiple semi-transparent shadows at different angles:
...
8
votes
What is a simpler method to find the analytical expression for the function f[x]?
Eliminate[{f == x + 1/x, t == Sqrt[x] + 1/Sqrt[x]}, x]
(* t^2 == 2 + f *)
from which $f(t)=t^2-2$ follows immediately with ...
7
votes
Accepted
How to invert this function when the argument e is small?
As @userrandrand suggests, series-expand the function in $\epsilon$ and then invert the series:
...
7
votes
Stopping mathematica from rearranging elements in a list
UniqueElements[{set1,{ -1/x}}][[1]]
(* {-x^(-1)+x/2-2*Log[x]-Log[x]/x,1} *)
7
votes
How to draw an image similar to a periodic function (f [x+1]=2 f [x])?
Plot[With[{qr = QuotientRemainder[x, 1]},
2^First[qr] Last[qr] (Last[qr] - 1)], {x, 0, 3}]
7
votes
Accepted
7
votes
How to fit function with data?
NonlinearModelFit default settings work ok with simpler model and thena and b can be derived,...
7
votes
7
votes
7
votes
Undocumented behavior of Fold for arbitrary heads
This behavior is actually documented further down in the page in the "Scope" section, so you can rely on it not changing in the future.
The head of the third argument need not be List:
<...
7
votes
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-...
7
votes
How to stop mapping on true results for large lists?
You can use AnyTrue. AnyTrue short-circuits on first True result and returns ...
7
votes
Accepted
Define a function on a single element but linear in sums
Just reorder the two definitions, so that the one for sums comes first. You can read more about it in the tutorial The Ordering of Definitions.
...
7
votes
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]...
7
votes
Accepted
Given two functions, generate all nested applications of the functions to a given order
Using Composition:
...
7
votes
Accepted
Composition of vectorvalued functions
You must use SetDelayed (:=) in your function definitions
Without the curly braces:
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
functions × 3856function-construction × 532
list-manipulation × 457
plotting × 448
calculus-and-analysis × 264
equation-solving × 202
evaluation × 137
matrix × 123
programming × 111
performance-tuning × 103
simplifying-expressions × 100
replacement × 86
graphics × 85
complex × 85
syntax × 85
differential-equations × 83
variable-definitions × 76
numerical-integration × 72
pattern-matching × 72
functional-style × 71
mathematical-optimization × 69
numerics × 66
symbolic × 63
probability-or-statistics × 61
core-language × 60