# Tagged Questions

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

50 views

### FindMinimum runs out of Memory

I have a function (its rather long, but does not matter) which when evaluated (1000s of times) runs fine. However, when I try to find its optimal parameters using ...
33 views

### Minimization problem in a subset of Complex matrices

I would like to minimize $||\mathbf{A} \rho -v||$ (where $\rho , v$ are fixed vectors) with respect to the matrix $\mathbf{A}$ elements, but with $\mathbf{A}$ in a subset of complex matrices (i.e. ...
351 views

### Finding minimal distance between two surfaces

This code will display two parametric surfaces: ...
36 views

### Transform NMinimze into LinearProgramming formulation

I have the following maximization problem that I currently try to solve with Minimize/NMinimize. Unfortunately, this kind of solution method takes really long for large systems of equations and ...
63 views

### Array in Sum in Minimize - error “Part specification x[1] is neither a machine-sized integer”

Help please M = 10; z = Array[x, M] {x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10]} ...
43 views

### Constrained optimization using FindMaximum [on hold]

I am trying to optimize a problem that I have. I am using the findmaximum function for this, and this being the first time I am using mathematica, not sure if the syntax is correct or am I heading in ...
76 views

### NMinimize/NMaximize is unable to generate initial points

Mathematica 10 generates a warning that it is unable to generate initial points for numerical optimization problems. I picked a particularly simple example. The problem goes away when ...
82 views

### Is there any way to solve this convex-concave like optimization problem?

This is a bit of a non-standard way of asking a question perhaps but I couldnt even think of writing any code about the following optimization problem. I wonder if it could be at all solvable and if ...
10 views

### Formula to divide (group) numbers into N proportionally groups [migrated]

Lets take ideal theoretical case as example: we have 20 numbers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 we should split these numbers into 5 groups: lowest, low, ...
79 views

### Optimizing Chi-square distance between two distribution

I want to program the chi-square between two distribution Xu and Vu with length N. This function is defined as below: Xu and Vu are real and positive. ...
58 views

### Updating procedural fitting algorithm to more efficient style?

For some time now, I have used this procedural programming approach to fit data in my research that is too cumbersome for the built in Mathematica functions. (Although this simple example works fine ...
49 views

### Improve on timing of NMinimize

I got a little performance problem with the function NMinimize (it takes mathematica approximately 10 minutes to compute the results). Here i s my sample code: ...
53 views

### Using FindFit to return a list of possible best fits

Can I use some variant of FindFit that will return a list of the best fit and some worse fits, not just the best fit? This is for a function where the residual function can have several local ...
80 views

### Optimization in MMA for time resolved spectroscopy

I want to fit some spectroscopic data with a model. I detect the fluorescence of something over different wavelengths. The detection over each wavelength is one data set in time. The lifetimes of ...
100 views

### PenaltyFunction Option in NMinimize

I am curious if anybody has some experience in using the built-in Option "PenaltyFunction" in any of the numerical optimization functions like NMinimize. According to the documentation the user ...
32 views

### How to set the step in NMinimize

I want to fit multiple data sets with 104 variables. I use NMinimize to do that. I minimize the difference between data and my objective function. How can I tell ...
30 views

### Optimization of two functions under one common constraint

Is it possible to optimize two functions under one common constraint? So to find the common maximum? For example, Optimization of (* 1 *) x*y^2-x^2 (* 2 *) x*y ...
66 views

### Matlab's command counterpart in MMA

Matlab has a command that when is used in fminsearch shows the value of the function which we want to minimize and so gives a trend of values calculated for the ...
35 views

### Speed up numerical optimization (for plotting and solving)?

Briefly speaking, I want to plot a function PIfun[], which its value is based on numerical optimization using NMaximize. It ...
54 views

### A constraint to RandomReal for sum of numbers equal to arbitrary n

I want to generate some random numbers but respect a constraint. So I use RandomReal[{0,1},N,WorkingPrecision -> 2] I want to fix a constraint in order ...
24 views

### NMinimize outside the feasible region

I got the following minimization problem. I get a solution if I set constraints1 := L.x >= y; and eliminate constraint 2 from my set of constraints. So ...
30 views

### Add constraints to a variable number of parameter in Minimize

i want to use Minimize with a variable number of Parameter which works fine: ...
45 views

### NMinimize: Problem with constraints + Simultaneous minimization possible?

Introduction Dear all, I am fairly new to Mathematica. Recently I am trying to do the following: I have a function \textrm{hann}[t,t_g,n_m]=\sum\limits_{n=1}^{n_m}a_n\left[1-\cos\left(\frac{2\pi ...
44 views

### Minimization of a non-linear objective function subject to linear constraints

I have solved a linear program in Mathematica using the LinearProgramming function with arguments of the form LinearProgramming[c,m,{{b1,s1},{b2,s2},...}] i.e. ...
48 views

### Working precision and pure functions in FindMinimum

I have this function: fun = (# - 5.0)^2.0 & Then, I want to find the minimum: ...
142 views

### What is the difference between FindFit and NonlinearModelFit

I cannot get the difference between these two fitting functions in Mathematica. I even read in MMA that the result of these two are the same.
62 views

...
198 views

### How to use a compiled function in numerical optimization

I'm trying to wrap my head around function Compile. So, this is a spin-off question from: a previous question on using compile[] correctly. I have a function that ...
63 views

...
45 views

...
253 views

### Finding the point of minimum distance between two parametric functions

I have two functions re and rm, for which I computed the minimum distance between them. Now I would like to add a point at the ...
50 views

### Calculate the relationship between the duration of two oscillating functions

I am trying to quantitatively determine the relationship between the length of two oscillating functions. Meaning, what is the duration of the green spike in relation to the blue square? Does anyone ...
44 views

### Optimizing evaluation of expressions dependent on four variables and containing double summation

I would like to optimize my code which I use to evaluate expressions containing double summation. These expressions are dependent on 3 space variables ($r$, $\theta$, $\phi$) and time $t$ and consist ...
103 views

### Optimizing code containing an infinite sum

I have the following expression. It's based on the negative-log-likelihood of a Poisson-Gaussian noise model, i.e. a convolution of a Poisson & Normal distribution. The value $x_{i}$ is the ...
41 views

### NMaximize not substutiting parameters of objective function [duplicate]

NMaximize is not substituting parameters of its objective function. Is there a way to fix that? I have a three line program that exhibits the problem. ...
77 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 ...
49 views

### NMaximize stops evaluating my function when run in parallel

I am trying to maximize the results of a Monte Carlo simulation with respect to some input variables. ...
93 views

### How to differentiate a geometric sum [closed]

How do I differentiate both sides of the equation shown below with respect to r?
151 views

### Solving mixed integer programming using Mathematica

Let $x_{ij}$ be an $n\times k$ matrix defined as follows: $x_{ij}=\begin{cases} 1, & \text{if }s_i\text{ is assigned to }S_j \\ 0, & \text{otherwise } \end{cases}$ and $S$ is a set of $k$ ...
67 views

### Efficient processing of Special Ordered Sets with LinearProgramming

I'm playing with integer linear programming, especially problems involving lots of constraints which would appear to be special ordered sets. Below is a toy example, three last rows of the matrix ...
514 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 ...
54 views

### Listable compiled functions used in NMinimize

This is an example from MMA: cListable = Compile[{x}, (x-1)^2, RuntimeAttributes -> {Listable}] In case of single entry: ...
147 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 ...
93 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. ...
158 views

### Using compiled function inside NMinimize

Consider this code: ...
80 views

### Optimization in Mathematica [closed]

There is a R package called TIMP. By this package someone can fit data to a model. There is a GUI for TIMP called Glotaran. When I fit my data by this package it does not take so much time to get the ...
64 views

### How to minimize a list of data points?

I have a list called diff1: ...
142 views

### Finding the minimum of a function

I asked this question Mark Minimum Value in DensityPlot. Another question has come up, or better said, a task: Find the minimum of a function. I haven't been able to write the needed code for that, ...
70 views

### Maximizing Large Multivariable Function over Region with Parameter Constraints

Brand new Mathematica user here. I have a complicated function to maximize, and thought I would try software like Mathematica instead of taking derivatives by hand. I found some Mathematica ...
98 views

### Minimizing a function with some restrictions

I need help in finding a way to minimize a function with some complex constraints. I'm not an expert in this field, but I'm still trying to understand if I can do something with my problem. So, ...