Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 6358

Questions on the optimization functions of Mathematica such as FindMinimum/FindMaximum, Minimize/Maximize, NMinimize/NMaximize, etc.

12 votes
1 answer
365 views

Bug in NMaximize in 12.2?

Bug introduced in 12.2, Fixed in 12.3 Something changed in NMaximze in v12.2: NMaximize[E^(-x^2) - 1, x] (* {(-1 + E^#1)[0.], {x -> 0.}} *) v12.1 works as expected: NMaximize[E^(-x^2) - 1, x] (* {0., …
Chris K's user avatar
  • 20.4k
8 votes

FindMinimum works only if you know the answer

This is more of an extended comment than an answer. First, building off @JackLaVigne's work, I think it's better to work in log of your parameters, so I defined a new objective function chiSquared2[ …
Chris K's user avatar
  • 20.4k
6 votes
4 answers
712 views

MaxDetect speed

What's the fastest way to find the local maxima of a 2D list? E.g. nx = ny = 100; dat = Table[Sin[2. \[Pi] x/nx] (0.1 + Cos[2. \[Pi] y/ny]), {y, 0, ny}, {x, 0, nx}]; ListPlot3D[dat] This (updat …
Chris K's user avatar
  • 20.4k
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 stability analysis. I assume g[x, r] is some kind of potential, not x' …
Chris K's user avatar
  • 20.4k
4 votes
Accepted

Plotting maxima within a simplex

Piggybacking on @kglr's answer, but using a right triangle rather than equilateral, so we can see p and q on the axes and to highlight the symmetry between f and h. How about: Plot3D[max[p, q], {p, …
Chris K's user avatar
  • 20.4k
2 votes
Accepted

Solving for the coefficients in a nonlinear equation according to constraints

This can be solved by choosing a few arbitrary values of θ: FullSimplify[ Solve[0 == E^t (a x^2 + b y^2 + c z^2) /. {x -> r Cos[θ], y -> r Sin[θ], z -> m} /. θ -> {0, 1, 2}, {a, b}]] (* {{a -> …
Chris K's user avatar
  • 20.4k
1 vote

How to extract the last output from the Maximize

All of the answers in @kglr's comment work: nm = Maximize[{x^0.5 - 2*y^3, 0 < x < 1, 0 < y < 1}, {x, y}]; y /. Last[nm] y /. nm[[-1]] nm[[-1, -1, -1]] (* 0.000023912 *) (* 0.000023912 *) (* 0.0000239 …
1 vote

Solve / brute-force for parameters that drive a function to zero at specified points

I have no idea on your actual problem, but your simple example can be solved by choosing a few arbitrary values of θ: FullSimplify[ Solve[0 == E^t (a x^2 + b y^2 + c z^2) /. {x -> r Cos[θ], y - …