19 votes
Accepted

Efficiently Mowing Grass with Mathematica

This is just starting ideas for arbitrary regions. Perhaps you can improve it. Version 1 Define concave region with holes, which can be generalizable to arbitrary complexity: ...
Vitaliy Kaurov's user avatar
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.2k
9 votes

Efficient use of GatherBy on large list to remove duplicates

If you want rules without duplicate keys, you really should be using Associations instead of lists of rules. They're much faster and automatically handle key duplicates. In this case, you could do: <...
Sjoerd Smit's user avatar
  • 23.5k
8 votes

Rectangular matrix for Tikhonov first order regularization

ClearAll[sa] sa[n_] := SparseArray[{Band[{1, 1}] -> -1, Band[{1, 2}] -> 1}, {n - 1, n}] sa[5] Normal @ sa[5] ...
kglr's user avatar
  • 395k
8 votes
Accepted

Placing a disk of maximum size in a region surrounded by random points

We union the boundary of convex hull chm and random points x as a single region and use ...
cvgmt's user avatar
  • 72.7k
7 votes

Finding the largest disk within a convex region using Region primitives

In version 13.3, the problem can be solved with InscribedBall ...
chyanog's user avatar
  • 15.5k
7 votes
Accepted

Minimize is returning unevaluated for a simple positive integer domain problem

You need to specify what you mean by "smallest solution". If it means that you want the smallest value of $x+y$, then you can do ...
Roman's user avatar
  • 47.4k
7 votes

SVD decomposition with optimization

The matrix that you are looking for is B = LinearSolve[A\[Transpose].A + \[Lambda]^2 IdentityMatrix[n], A\[Transpose] ] Here a toy example to convince you: ...
Henrik Schumacher's user avatar
7 votes
Accepted

Using ParallelTable for assignment

The direct answer to "how should it be implemented" is to use SetSharedFunction. Evaluate SetSharedFunction[s1] before ...
lericr's user avatar
  • 28k
7 votes
Accepted

How to find the nearest element that is bigger than x?

Nearest will either give us the value we're looking for or the value to the left in a sorted list. So we can simply find the ...
Greg Hurst's user avatar
  • 35.9k
7 votes
Accepted

FindMaximum, error in solution

I believe it is the non-differentiable kink of your function that is causing troubles to the maximizator. Luckily, in your case, you can use Maximize to find the ...
Domen's user avatar
  • 24.7k
6 votes

How to find the maximum value of this trigonometric function?

A contour plot of the condition shows that $\beta$ will need to be between 0 and around 0.5: ...
JimB's user avatar
  • 41.7k
6 votes

Finding the sum of eigenvalues of a matrix depending on the parameters

The sum of the eigenvalues can be calculated without diagonalizing the matrix. Example: generate random $n\times n$ Hermitian matrices: ...
Roman's user avatar
  • 47.4k
6 votes

Efficient use of GatherBy on large list to remove duplicates

Map[DeleteDuplicatesBy[First]] @ lis {{a1 -> x1, a2 -> x2, a3 -> x3}, {b1 -> y1}}
kglr's user avatar
  • 395k
6 votes
Accepted

Why can't we find the minimum value of 2a+b?

conditions = Reduce[{f[a] == f[b], a > 0, b > 0, b > a}, {a, b}, Reals] Minimize[2 a + b, conditions, {a, b}] ...
cvgmt's user avatar
  • 72.7k
6 votes

Why can't we find the minimum value of 2a+b?

NMinimize together with modified constraint gives a solution: f[x_?NumericQ] := Abs[Log[x]] Plot[f[x],{x,0,2}] Plot show that ...
Ulrich Neumann's user avatar
6 votes

Is it possible to ask Mathematica to obtain the function describing the upper and lower boundaries of a combinations of functions?

Something like: ...
Daniel Huber's user avatar
  • 51.5k
6 votes
Accepted

Improve performance of Linear Optimization

For machine precision numbers, the actual backend of LinearOptimization will be some compiled and heavily optimized library. Such libraries require the problem to ...
Henrik Schumacher's user avatar
6 votes
Accepted

Why hasn't the minimum value of a+b been determined?

The following works in 13.3.1 on Windows 10. Minimize[{a + b, Reduce[9 == 9^(1/a) 3^(4/b) && a*b > 0, Reals]}, {a, b}] $\left\{2 \sqrt{2}+3,\left\{a\to ...
user64494's user avatar
  • 26.3k
6 votes
Accepted

Colouring Bifurcation Diagram

You can use ContourPlot to make such 1D bifurcation diagrams easily as in this answer, using ConditionalExpression to handle the ...
Chris K's user avatar
  • 20.2k
6 votes
Accepted

Findroot :unable to find a solution that meets the convergence criteria

System can be solved with Newton method as follows ...
Alex Trounev's user avatar
  • 44.5k
5 votes
Accepted

Optimize parameters for differential equations

You could use ParametricNDSolve with A and B as parameters and then use ...
ydd's user avatar
  • 3,683
5 votes
Accepted

Find minimum of integral with two variable terms

One way to do it in a more numerical way is this: FindMinimum[ Inactive[NIntegrate][(-b - a*x + (1 + x^2)^(-1))^2, {x, 0, 1}], {{a, 1}, {b, 1}} ] The advantage ...
Sjoerd Smit's user avatar
  • 23.5k
5 votes

Finding maximum value of a function with parameter

Abs is a Complex Function. We use Sqrt[x^2] instead. ...
cvgmt's user avatar
  • 72.7k
5 votes

Minimax problem where a combination of Minimize and Maximize gives no result at all

There doesn't seem to be a closed-form symbolic solution for Minimize[{(p Log[(p/(p + a))] + (1 - p) Log[((1 - p)/(1 - (p + a)))])/a^2, 0 < p < 1/2}, p] So ...
JimB's user avatar
  • 41.7k
5 votes
Accepted

How to find a densest configuration of several non-overlapping unit disks?

We try to manually construct the convex hull. ...
cvgmt's user avatar
  • 72.7k
5 votes

Packing unequal spheres into minimal cuboid

Try RegionBounds to get the enclosing cuboid a,b,c of the two spheres ...
Ulrich Neumann's user avatar
5 votes
Accepted

Packing unequal spheres into minimal cuboid

A generalization of @Ulrich Neumann's code: ...
ydd's user avatar
  • 3,683
5 votes

How to find the nearest element that is bigger than x?

If unsorted, then a straightforward procedural routine might be good: ...
Goofy's user avatar
  • 2,767
5 votes

Evaluating series expansion is very slow

For alternative algorithm and for speed up you can may use: NSeries: ...
Mariusz Iwaniuk's user avatar

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