Skip to main content
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: ...
MarcoB's user avatar
  • 67.6k
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.
Jason B.'s user avatar
  • 69.7k
12 votes
Accepted

Which functions use a given option?

You can use WolframLanguageData with the property "SymbolsUsingAsOption" for this: ...
Lukas Lang's user avatar
  • 34.4k
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 ...
A. Kato's user avatar
  • 2,960
11 votes
Accepted

How does this code work?

+## stays for Plus[##] and 1 ## for Times[##]. So it ...
azerbajdzan's user avatar
  • 21.4k
10 votes

Stopping mathematica from rearranging elements in a list

You can use DeleteElements which came with V 13.1: ...
eldo's user avatar
  • 82.6k
10 votes
Accepted

Are there any better methods to solve this problem?

Function ForAll and Resolve help. ...
Jie Zhu's user avatar
  • 2,285
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] *) ...
xzczd's user avatar
  • 67.7k
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]} *)
A. Kato's user avatar
  • 2,960
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: ...
Domen's user avatar
  • 31.2k
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; ...
cvgmt's user avatar
  • 79.8k
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 ...
cvgmt's user avatar
  • 79.8k
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 ...
eldo's user avatar
  • 82.6k
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 ...
flinty's user avatar
  • 25.6k
8 votes

Blurry shadows of 3D plots and objects

I've tried adding multiple semi-transparent shadows at different angles: ...
SHuisman's user avatar
  • 3,500
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 ...
Roman's user avatar
  • 49.3k
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: ...
Roman's user avatar
  • 49.3k
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} *)
user1066's user avatar
  • 21k
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}]
Goofy's user avatar
  • 3,619
7 votes
Accepted

How to fit function with data?

Provide initial estimates for a and b ...
Bob Hanlon's user avatar
  • 161k
7 votes

How to fit function with data?

NonlinearModelFit default settings work ok with simpler model and thena and b can be derived,...
ubpdqn's user avatar
  • 63.1k
7 votes

Finding Saddle Points

...
MarcoB's user avatar
  • 67.6k
7 votes

Finding Saddle Points

...
rmw's user avatar
  • 1,950
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: <...
Jason B.'s user avatar
  • 69.7k
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-...
lericr's user avatar
  • 31.7k
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 ...
Edmund's user avatar
  • 43.1k
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. ...
Domen's user avatar
  • 31.2k
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]...
eldo's user avatar
  • 82.6k
7 votes
Accepted

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

Using Composition: ...
Syed's user avatar
  • 56.2k
7 votes
Accepted

Composition of vectorvalued functions

You must use SetDelayed (:=) in your function definitions Without the curly braces: ...
eldo's user avatar
  • 82.6k

Only top scored, non community-wiki answers of a minimum length are eligible