Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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

3
votes
1answer
31 views

evaluation about Exp[] and Complex problem [on hold]

Exp[I*Pi*0.75]*Exp[I*Pi*0.75] Exp[I*2*Pi*0.75] the results are: -2.22045*10^-16 - 1. I -1.83697*10^-16 - 1. I I know it is ...
0
votes
1answer
27 views

How can I optimize plotting the solution to ParametricNDSolve as a function of a range of values of the parameter?

I'm using ParametricNDSolve to find a solution to a set of first order ODEs which have one independent variable, z. The set of initial values contains a function of t. ...
0
votes
0answers
31 views

How can I convert the result from the graph to all set of coordinate? [on hold]

How can I convert the result from the graph to all set of coordinate? Part of the code: ...
0
votes
0answers
26 views

`Minimize` keeps running

I'm trying to determine the effect of small changes in one parameter of my problem on the KKT multipliers. The program computes the values of those multipliers (γVec...
3
votes
1answer
108 views

Generate convex-hull of a 15 dimensional space

This question follows my last post. I have a function $ \vec{f}: S^6 \times S^6 \rightarrow \mathbb{R}^{13} $ defined on two 6-dim hyperspheres. We will denote the function $ \vec{f}(\vec{x},\vec{y}) ...
0
votes
1answer
25 views

How to find minima for non scalar-valued [closed]

I want to find minima. My code: ...
1
vote
1answer
90 views

Minimization of a function

Let $T$ be a $n\times m$ matrix, I'm trying to solve $$ \min \sum_i T_{ij}{\lambda_i}^{\frac{1}{\alpha_i}}$$ $$ s.t. \sum_i \lambda_i =1, \lambda_i \geq 0$$ for $j=1,2,...,m$. When $\alpha_i=\alpha$ ...
1
vote
0answers
35 views

Finding zero linear combinations of polynomials (numerically)

I have two functions of real variables defined on two compact spaces ...
1
vote
2answers
50 views

Solve multiple equations and getting solutions [duplicate]

This is my first post here so I'm not really sure how all of this works, but I'll try my best to explain my problem. I'm supposed to solve the equation system ...
0
votes
1answer
49 views

How to optimize this script?

fx8350, 16Gb ram just need to solve this: 13, 19, 19, 16, 26, 33, 26, 31, 5, 24, 21, 34, 35, 35, 35, 20, 7, 12, 18, 17, 6, 8, 15, 24, 2, 17, 15, 22, 29, 15, 21
3
votes
2answers
88 views

Programming with Mathematica Syntax - Dunford decomposition

I am always amazed while I am reading some solutions of problems in mathematical problems of this site with Mathematica. For instance, look at the problem 48. Whereas I am writing 100 lines of code ...
3
votes
2answers
53 views

Find the base vectors of a point set

I have a list of coordinates that fits into a 2D periodic lattice, with some error ( $\vec{R}=n\vec{i}+m\vec{j}+\vec{\varepsilon}$). Is there a way to find the base vectors of the lattice? I guess the ...
2
votes
1answer
45 views

FindInstance for all real values satisfying a condition

I seek at least one instance of positive fractions $p,q,r$ where $p,q,r \in \mathbb{Q}^+$, for which $$\frac12 (a - 2 b + c)^2 \ge pa^2 + qb^2 + rc^2\quad \forall\ a,b,c \in \mathbb{R}.$$ I used this ...
4
votes
1answer
40 views

AccuracyGoal & PrecisionGoal: how to know which was used to yield the result?

With NMinimize (or many other functions), when an answer is found without any warnings, this means that a certain convergence criterium was achieved. It could be ...
2
votes
2answers
37 views

SearchPoints -> Automatic within DifferentialEvolution: what's its meaning?

A simple question: what is the meaning of the standard option (Automatic) for SearchPoints within the ...
1
vote
0answers
29 views

Do you know what's issue of my code, NDsolve and ParametricPlot [closed]

Could you please point out my isse of the code? Frustrated. ...
2
votes
0answers
103 views

Adjacency Matrix to Clusters of Equal Sizes

I have a system with 72 nodes. I have a binary adjacency matrix $S$ of size $72\times 72$. If $S_{i,j}=1$, then node $i$ is adjacent to node $j$. So, we also have $S_{i,j}=S{j,i}$. So, $S$ is a ...
0
votes
1answer
62 views

How to find clusters with same cluster sizes?

I have a set of 71 data points. Each data point is represented by its latitude and longitude. I want to divide them into 12 clusters. The first 11 cluster will have exactly 6 points each and 12th ...
1
vote
3answers
92 views

Find k largest edges with unique nodes (kind of maximum weighted matching)

I have a weighted graph, and I am interested to find k largest edges with unique nodes. Currently, I do it in the following manner ...
0
votes
1answer
46 views

NMaximize refuses the constraint set [closed]

I want to run the following NMaximize code but I receive warnings that the constraint set is not right. ...
4
votes
4answers
283 views

Solve struggles to solve equation with variable constraint

I am trying to find {x,y} set satisfying first order conditions with the constraint: 0<x<=y<1 Here is my code, which ...
5
votes
5answers
162 views

For a polynomial F with dependence on a parameter beta, find the value of beta for which F has 2 positive roots

Good morning, I have the following polynomial with degree 4 and its coefficients are quadratic functions of a parameter beta: ...
0
votes
2answers
44 views

Minimizing a univariate function that receives a vector?

I'm trying to minimise a function of the form $f(s)=\frac{1}{T}\sum^T_{t=1}(x_t-s_t)^2+\sum^T_{t=2}(s_t-s_{t-1})^2$, where the vector $x$ is fixed, and $T$ is of the order of $10^2$. I've tried <...
1
vote
2answers
93 views

Optimization Problem: NMaximize goes out of the constraints

I am having issues with the code: ...
3
votes
0answers
159 views

Speeding up an optimization problem

I have the following code which is working well but for matrices $M_i$ of size $40000\times 4$ the optimization problem takes extremely long. ...
0
votes
0answers
55 views

Optimization issue: I'm not getting the correct maximum

I have the following code: ...
2
votes
1answer
109 views

Maximax optimization over a particular matrix

I have the summation of $N$ matrices which are weighted by some weighing factors (parameters): $$M_\alpha=\sum_{i=1}^N \alpha_i M_i$$ $$d_{\alpha}=\arg\max_{rows} M_\alpha$$ The ideal vector $d$ is ...
3
votes
0answers
31 views

NMaximize not finding initial points within simple constraints

I'm trying to do an optimization, but Mathematica seems not to be able to find starting coordinates within a simple rectangular region. When I run this code: ...
2
votes
1answer
45 views

Unable to use `Solve` to solve simultaneous equations, or use `Maximize` for exact maximum solution

Mathematica has found that the maximum of the following function is negative using NMaximize, but I am trying to prove that the maximum is negative (i.e. that the ...
0
votes
0answers
48 views

Find minimum precision setting

I am using FindMinimum command to find a local minimum of an object function. My code is below ...
0
votes
0answers
69 views

Parametric minimization running forever

I am trying to solve for the minimum distance between a line and a cone, for all possible lines in 3D space. I've formulated this as a call to Minimize, but it ...
1
vote
1answer
55 views

Golden section search method that terminate after $n$ iterations

I am attempting to code a program that executes the golden section search method and I would like to terminate the computations after $n$ iterations, where the user decides what $n$ is. My code works ...
0
votes
2answers
58 views

Global minimum of a function in a specified interval [closed]

I've got the following definition of fun1. epsilon = 10^(-8) fun1[h_] := (2 epsilon*Abs[Cos[1]]/h ) + (h*Abs[Cos[1]]/2) Let'...
0
votes
2answers
123 views

Is my Maximize expression too complicated for Mathematica to handle?

I am new to Mathematica and am using it to determine when a function reaches a maximum. ...
1
vote
1answer
42 views

Optimize the distribition of a dataset over 4 quadrants

I want to optimise the distribition of a number of records over four quadrants. As a example I use this dataset ...
3
votes
1answer
156 views

How can I get the exact answer of the maximum of this function?

I am trying to find the maximum of a fuction: $ f(x)=\sqrt{x^2+9}-\sqrt{x^2-\sqrt{3} x+1} $. I tried Maximize[Sqrt[x^2 + 9] - Sqrt[x^2 - Sqrt[3]*x + 1], x] and ...
3
votes
2answers
138 views

Formulating a tailor-made Maximum Flow problem in a directed graph

Let a digraph, G, be given, where t[i,j] and a[j,i], respectively, denote transfer capacity ...
1
vote
0answers
27 views

How do I maximise the first real root of a multi-variable polynomial in x?

I have a polynomial in x, that also depends on {y1,y2,y3,y4,y5}. It always has 10 (not necessarily distinct) real roots. It's top coefficient is (1*x^10) I aim to find the y's that maximize the ...
12
votes
10answers
1k views

Given a list of integers, find the largest sum of a contiguous subsequence

Given a list of integers, find the largest sum of a contiguous sub-sequence. {1, 2, 3, 4, 5, -1, 7, -4, -2} (* 21 *) And print the sub-array which is ...
0
votes
1answer
58 views

Constrained Optimization doesn't converge?

Given a $n\times J$ matrix $T$ with strictly positive elements, I'm trying to obtain the values ($\lambda_i$) that minimize $\sum T_{ij}\lambda_i^{\alpha_i}$ with the constraints $\lambda_i \geq 0$ ...
0
votes
0answers
32 views

Constrained optimisation problem with Maximize

I am trying to solve a constrained maximisation problem in Mathematica but I am getting the same output as my problem. My input is ...
1
vote
0answers
68 views

Is it possible to solve following question about integer programming using mathematica?

Consider a $5$-uple $(r,a,b,c,s)$ with $a,b,c\in\mathbb{Z},s\in\mathbb{Q}_+,r\in\mathbb{Z}_+$, denote $\frac{1}{2}(a^2-b^2-c^2)-\frac{s}{r}$ by $\Delta(\mathbf{v})$. Let $A$ be a positive real number....
3
votes
1answer
71 views

Solving a non-linear system of equations given $1000$ data points

I have a vector of $1000$ data points saved in a vector $y$ and I need to solve a set of non-linear equations. Since I cannot write down all $1000$ values, I will assume that I have the following data ...
0
votes
1answer
35 views

Optimization with constraint or with the constraint embedded into the problem?

I need to find the minimum of a function. However, the condition is that the final state should be normalized i.e. sum of the squares must be one. One way to deal with it is just add the constraint ...
0
votes
2answers
173 views

How to use Levenberg-Marquardt for parameter identification

Imagine I have a function called fun1 that returns a vector of numbers fun1[a,b,c,d,...]:=. ...
1
vote
1answer
45 views

Finding algebraic expression for local minimum of a function with one unassigned variable

I want to find the local minimum in the region 0.5<x<=1 of a function which has an unassigned variable r (note: ...
6
votes
1answer
442 views

Which algorithm does Mathematica use for “RandomSearch”?

Recently I have used Mathematica for minimization of certain functions and I have realized that even though it lasts much longer, the method "RandomSearch" functions much better than the other methods ...
1
vote
0answers
113 views

Finding an optimal location of 2D points?

I have a function f that returns the number of triangles formed by given line segments. For example, in the following case f ...