Which C++ library is perfect in solving non-linear set of equations with complex roots? - nonlinear-optimization

I am developing a small kinetic Monte Carlo code to study atomic evolutions in a material and need to solve several linear and non-linear equations with a high accuracy. My main issue is in finding complex roots of a non-linear equation.
Which C++ library is perfect for solving a non-linear set of equations with complex roots? I am already using Eigen and Ceres in my codes, but it seems that they only can find "real" roots and not "complex" ones.
All recommendations and ideas are appreciated in advance.
Update-1:
For example, Eigen provides a nonlinear optimization module,
https://eigen.tuxfamily.org/dox/unsupported/group__NonLinearOptimization__Module.html
which uses (1)Levenberg Marquardt algorithm and (2)Powell hybrid "dogleg" method to find roots and extremums of a nonlinear set of equations. As far as I know, these methods can't find complex roots if any.

Related

What kind of numerical method does 'pdepe' (MATLAB function's) use?

I'm using the MATLAB's function 'pdepe' to solve a problem with some partial differential equations, a parabolic one.
I need to know the kind of numerical method that function uses, 'cause I have to notify this in a report.
The description of the function in MathWorks is "Solve initial-boundary value problems for systems of parabolic and elliptic PDEs in one space variable and time". Is it a finite difference method?
Thanks for helping me.
Taken from the Matlab 2016b documentation for pdepe:
The time integration is done with ode15s. pdepe exploits the
capabilities of ode15s for solving the differential-algebraic
equations that arise when Equation 1-3 contains elliptic equations,
and for handling Jacobians with a specified sparsity pattern.
Also, from the ode15s documentation:
ode15s is a variable-step, variable-order (VSVO) solver based on the
numerical differentiation formulas (NDFs) of orders 1 to 5.
Optionally, it can use the backward differentiation formulas (BDFs,
also known as Gear's method) that are usually less efficient
As indicated by Alessandro Trigilio, ode15s is used to advance the solution forward in time. Exactly what the function is advancing in time is a semi-discrete, second-order Galerkin formulation for non-singular problems or a semi-discrete, second-order Petrov-Galerkin formulation for singular problems (polar or spherical meshes that include the origin). As such, the spatial discretization is finite element in nature.

How to compare gams vs matlab in optimization

Is it possible to use Matlab instead of GAMS for optimization problems? How do they compare? In other words, can every problem solved with gams be solved with some matlab toolbox And finally what is a list of the optimization tools in Matlab.
Matlab and GAMS are very different in how they approach modeling. GAMS is organized along the concept of equations (essentially an optimization model is a collection of equations). This is both for LP, MIP, MINLP and other types of models. These equations largely resemble how you would write things down in Math. Matlab views an optimization model (LP/MIP) as a matrix (or two matrices depending on whether we deal with equalities or inequalities). You have to translate your constraints in these one or two matrices by populating them. Depending on the model this can be a difficult task. For structured models it is not so bad, but for large, complex models the GAMS approach is much more natural and convenient.
NLP problems in GAMS are just like LPs: equation based. GAMS uses automatic differentiation so no need to write gradients and GAMS targets large scale NLP problems. Matlab uses functions in their NLP solvers, and these are mostly suited for smaller problems. Gradients are provided by the user.
GAMS supports many solvers. MATLAB has an optimization toolbox, but these solvers are largely targeted to smaller and medium sized models. Having said that many state-of-the-art solvers have a Matlab interface (e.g. Cplex, Gurobi).
Not all solvers available under GAMS are directly callable from Matlab but many are (sometimes using external toolboxes).

Fit data with a numerical ode solution (on Matlab)

I am looking for a way to fit my experimental data by a theoretical model which is described by a non-linear differential equation.
Unfortunately this latter can only be solved numerically (by solving this second degree, non-linear differential equation).
I manage to solve the differential equation for a set of parameters using the ode45 Matlab solver but now I want to find the proper fit parameters of the model. Also, I may have to mention that my ode45 is initiated at z=zmax (max being large so I can assume it is infinity) by y(zmax)=y0 and yprime(zmax)=yprime0 and I solve backward (from zmax to z=0).
I am quite new to this kind of numerical problems, are there classical ways to solve such problems?
Does anyone knows if there is a Matlab procedure which would help me solve this? On which principles is it based/constructed? (if possible I'd like to know the theoretical trick to solve this problem in a smart way, not by trying all the possible sets of parameters which would be very time consuming (I have 5 fit parameters!).
Thank you for your precious help!
You have facy methods in the Optimization Toolbox. In case you don't have access to it, you could do it manually by:
Selecting a cost function between the experimental and model data. For example, mean-squared-error.
Doing heuristic optimization of the cost function. For example, Nelder-Mead method.

MATLAB nonlinear objective function

I have an OR model, with linear constraints and a nonlinear objective function. Is it impossible to solve it with "linprog"? If so, are there any methods to linearize objective functions, fore example by adding some constraints to the model?
Thanks for your help.
`linprog' solves linear programming problems, and the objective function should be linear. The nonlinear objective functions can be linearized with mathematical linearization method.
Linearization is a linear approximation of a nonlinear system that is valid in a small region around the operating point.
For example you can use Function approximation for linearization. Taylor approximation is one of the methods. The linearization of a function is the first order term of its Taylor expansion around the point of interest. There exist other methods as well.
Matlab has a document for basic methods and functions of linearization that you may check.
If you support the question with code, people at SO can help more with the problem.
If you have Matlab at your disposition, and can use any of the optimization toolbox's functions, you should look at fmincon, which minimizes nonlinear objective functions under linear and nonlinear constraints.

Modelling dynamical systems with MATLAB/Mathematica

Recently I have been performing simulations on some dynamical system, where all the dynamical quantities are interdependent. To therefore simulate the dynamics I performed loops over small time steps dt<<1 and changed the quantities within each iteration. The simulations were done in respectively Mathematica and Matlab.
I got nice results but simulations could take quite long due to the slow iteration process. Generally I hear that one should avoid for loops like I have used, because they slow down the simulation greatly. On the other hand however I am clueless on how to do the simulations without iterations in small time steps. Therefore I ask you: For a dynamical system, where every quantity must be changed in ultra small time steps, what are then the possible methods for for simulating the dynamics.
The straightforward approach is to write the problem as a set of differential equations and use the ODE solving capabilities of either system. Both MATLAB and Mathematica have advanced (and customizable) numerical differential equation solvers, and they both support special "events" in the differential equations that can't be expressed using a simple formula (e.g. the event of a ball bouncing back from the floor).
For Mathematica, first check out NDSolve, WhenEvent then later the Advanced Numerical Differential Equation Solving tutorial.
From your description it sounds like you may be using a naive ODE solving method such as the Euler method. Using a better numerical ODE solving technique can give significant effective speedups (by not forcing you to use "ultra small time steps").
If performance is paramount, consider re-implementing the simulation in a low-level language like C or C++, and possibly making it callable from Mathematica (LibraryLink) to allow easy data analysis and visualization.