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

learn more… | top users | synonyms (4)

14
votes
2answers
1k views

Find maximum value of interpolation function - obviously wrong result

Minimizing and maximizing interpolation function has already been asked and answered, see here for example. Yet, I observe a strange behaviour. Well, I can understand that the wrong guess of ...
1
vote
2answers
90 views

FindMinimum and WhenEvent

Is there any way to incorporate WhenEvent[] into the FindMinimumfunction ? I'm currently trying to minimize an interpolating function with FindMinimum (since the origional function is to cumbersome ...
2
votes
1answer
64 views

NMaximize with Nelder-Mead method fails to convergence when tolerance set too high

Recently I have been working on a optimization problem for which I use NMaximize with Nelder-Mead method. In general, I have to check a lot of systems which are built automatically. I want to skip ...
0
votes
0answers
48 views

Sharp Ratio Maximization, Closed Forms

I am trying to get a closed form for the following first order conditions (n=4): Here's the nb-File. The code is as follows: ...
5
votes
0answers
98 views

Custom Methods for NMinimize/NonLinearModelFit

Is there a way to write custom methods for NonLinearModelFit or NMinimize? To give background, I currently have a batch of code ...
9
votes
2answers
226 views

Relaxation of Mass-Spring System with Pinned Masses

Problem Assume that four masses are connected to each other by springs while two of them are pinned down at their initial positions. Find the position of masses when system is at its minimum ...
0
votes
0answers
42 views

Recursive method for the SR1 correction

I am looking to program a recursive formula for implementing the Symmetric rank-one correction. I am not sure exactly where my program fails. Every value is correct except the value for ...
0
votes
1answer
85 views

Both FindMinimum and NMinimize have trouble

I'm trying to minimize a function I wrote, in a not entirely elegant (but functional) way. As a side note, if you have advice on how to write this in a smarter way, that's also welcome. In any case, ...
2
votes
2answers
110 views

Reordering numerically calculated eigenvalues assuming smooth dependence on a parameter

As was discussed in a different question here on SE (link) if you compute eigenvalues numerically of a matrix which depends on a parameter y, the resulting plot of ...
3
votes
0answers
69 views

Symbolically Minimizing a Max function

I'm having a tough time with seemingly simple symbolic Minimization/Maximization in Mathematica. I would like to use the Maximize function to work on some unknown random variables and so use min/max ...
1
vote
1answer
118 views

Equation solution using minimization

I have an equation F[x,y]=0. I need to plot y as a function of x. Due to the properties of ...
4
votes
0answers
73 views

How to perform Bayesian optimization with Mathematica?

Does Mathematica have any Bayesian optimization methods for learning hyper-parameters? Practical Bayesian Optimization of Machine Learning Algorithms Jasper Snoek, Hugo Larochelle and Ryan P. ...
0
votes
0answers
156 views

Optimization method L-BFGS-B

I am comparing a result of optimization using R and Mathematica. Mathematica (NMaximize) has found a significantly better (global optimum) result then R (using ...
1
vote
0answers
48 views

How can I calculate Lagrange multiplier and the critical points with Mathematica? [closed]

I have constraints and a function I want to know the critic points but is there a way that I can compute this method so that I can see results faster
3
votes
1answer
210 views

Finding peaks of data

I want to find peaks in my data. My code in a reduced form so far: ...
14
votes
3answers
2k views

How can I implement the method of Lagrange multipliers to find constrained extrema?

I want to form the function $h=f-\lambda_{1}g_{1}-\lambda_{2}g_{2}$ where $f$ is the function to optimize subject to the constraints $g_{1}=0$ and $g_{2}=0$ so that I can solve the first partial ...
8
votes
2answers
555 views

Is there any fast way to solve a quadratic matrix equation in Mathematica approximately?

Let the square nonsingular matrix $M$ is a given convergent matrix. What are the best scalar values for $\alpha$ and $\beta$ (in the real numbers domain), at which the following quadratic matrix ...
17
votes
0answers
231 views

Can code optimize code?

Are there functions, programs or packages that deal with optimizing mathematica code i.e. re-writing ineffecive or convoluted code. -This question has haunted me since I joined SE. The background for ...
1
vote
3answers
125 views

Minimize method is not giving minimum. Why?

I was doing an optimization but facing a problem getting what exactly Minimize function do. I run the following code: ...
14
votes
2answers
451 views

Determining the default Method used in optimization and root-finding algorithms

Is it possible to extract the Method which is used in functions like NMinimize, FindRoot, ...
3
votes
3answers
79 views

Minimizing Multiple Functions

I'm trying to write a script that will minimize a given set of functions. The homework problem I've been given lists a set of dietary information, and I'm supposed to build the optimal salad based on ...
0
votes
0answers
59 views

Which method to use for finding maximum without actually computing optimization function explicitly?

I am new to Mathematica and I am currently working on an optimization problem. The optimization function that I have easy to calculate for some assignment of variable but it is very difficult to ...
2
votes
1answer
186 views

How to build a list of constraints for NMinimize

Let's say I have aset = {-1, 0, 2}. I would like to create a variable Var that takes values from that set, i.e. ...
4
votes
1answer
81 views

What is the status of the FindMinimum method “QuadraticProgramming”?

As a method option to FindMinimum "QuadraticProgramming" is still a valid option. It has the advantage of being significantly ...
0
votes
0answers
52 views

Constrained optimization and problem with complex numbers

I am trying to solve a constrained optimization problem with an implicitly defined function $\pi$. The problem is non linear and of high order, so I use numerical methods instead. The code I use is: ...
1
vote
0answers
104 views

Using NMinimize to solve the Multi Commodity Flow problem

I have the following optimization problem and I was hoping to solve it with NMinimize. Unfortunately, I don't get the desired result. I would like to get an optimal vector for $d_{e}$. This is how ...
2
votes
1answer
117 views

Maximizing the number of zero entries in a matrix

I have a matrix with a bunch of parameters in its entries, they all come in different combinations in different places of the matrix. I can post the matrix itself if requested, but I think what I mean ...
5
votes
1answer
295 views

Lagrange Multiplier

We are asked to maximize and minimize $f(x,y)=4xy$, given the constraint $4x^2+y^2=8$, using the Lagrange Multiplier method. First, I enter the functions f and g. ...
1
vote
2answers
187 views

Is it possible to monitor the sum of squared errors in a NonlinearModelFit or FindFit procedure during the process?

Since fitting procedures using NonlinearModelFit (or FindFit) sometimes take very long, I would like to monitor the sum of ...
2
votes
1answer
103 views

How can I change a lot of parameters to Real? [closed]

Because of some formulas with Conjugate in a notebook, I have to tell mathematica to change a lot of parameters to Real! I know that I can use Refine with Element or Assumptions: ...
1
vote
2answers
95 views

Does FindFit use symbolic differentiation?

Does FindFit use symbolic differentiation when optimizing by least squares a non-linear function?
0
votes
1answer
67 views

Minimization Nminimize nnum error

I have imported data (mat is the name, 1x100 dimensional vector)and written a likelihood function for normal distribution. ...
1
vote
0answers
28 views

Using ForAll in Maximize to define a bunch of conditions

I'm trying to do something very straight forward. The following maximization works: ...
1
vote
1answer
50 views

NMinimize error: Nearest::neard:

I have this function GuessError, here's a plot assuming a single variable x, Plot[GuessError[10^x, etc..], {x, 8, 12}] , being etc some more variables which are ...
2
votes
1answer
72 views

NMinimize works only if expression is pasted directly

Niminize works fine if I copy the minimized function directly by hands, but doesn't work if I try to do something like this: ...
1
vote
1answer
138 views

Why does it matter at what point I replace?

I need to find four orthogonal linear combinations of complicated functions, that vanish at four different points. I use (LK4 is defined below, but its shape should have nothing to do with my ...
2
votes
1answer
49 views

Application of Maximize: The cuboid constrained to the ellipsoid in $\mathbb{R}^3$

Since I am a student of Mathematics I enjoy to apply MMA to problems that I have a solid understanding in. The following would be such a problem: Maximize $f: \mathbb{R}^3 \to \mathbb{R}$ given by ...
3
votes
1answer
109 views

How to stop optimization (e.g. NMinimize) after reaching target value

Suppose we have some function f[x,y] that we want to optimize in way that we are only interested in values (x,y) that guarantee ...
4
votes
1answer
70 views

Why does EvaluationMonitor in FindMaximum only work for some regions?

This has come about after trying to understand what was going on with this question about FindMaximum and regions. My first thought in that scenario was to set-up ...
3
votes
1answer
75 views

Why minimization does not work with symbolic array as arguments

If I try to minimize with constraints a function of several variables, with Gamma regularized function involved in the constraints it seems to works, as shown below (this is just a dummy example ...
0
votes
0answers
23 views

Timing of an Evaluation is not correctly displayed

From: http://reference.wolfram.com/language/howto/DisplayTheTimingOfAnEvaluationInANotebookWindow.html I ran a process that took about two minutes to finish. But the time recorded is only 0.18 ...
1
vote
2answers
105 views

Minimize the sum-of-squares errors for a system of ODEs

I'm trying to minimizing the sum of squared errors on a 2-equation system of ODEs and empirical data. I keep getting an error and I think the root of the problem is my invocation of ...
1
vote
0answers
57 views

Maximize and NMaximize don't work for my function

I defined the following function: d1[x_] := Min[Abs[FractionalPart[x]], 1 - Abs[FractionalPart[x]]] and tried to evaluate the following function: ...
4
votes
1answer
111 views

Possible bug / numerical issues with HypergeometricU — any suggestions for a fast workaround?

I've encountered some problematic behaviour with HypergeometricU. I have a probability distribution on the positive integers that takes the following form after ...
0
votes
1answer
57 views

Plotting Minimize output for a range of constraint values

I want to plot the minimum of a function returned by Minimize over a range of constraint values. ...
1
vote
1answer
56 views

FindMinimum function does not produce minimum from near point

Using my simple program and I would like to find such matrix elements that minimize difference of their eigenvalues. ...
5
votes
1answer
207 views

Is there any strategy to have a compiled version of FindFit or NonlinearModelFit?

Disclaimer: This is not a precise question with a definite answer. I know that neither FindFit nor NonlinearModelFit is in the ...