MATLAB Answers

Trying to solve Bethe equations - system of non linear equations

2 ビュー (過去 30 日間)
Daniel Vainshtein
Daniel Vainshtein 2021 年 10 月 12 日
回答済み: Alan Weiss 2021 年 10 月 12 日
Hello there,
I'm trying to solve numericlly the system of non linear equations: Bethe equations of homogenous Lieb-Linger model:
to do so I tried to generlize the idea of the 2 non linear equations system , given in:
to N system of equations:
The code for function that generates the N system of equations:
%Bethe Eqs (Homogenous Lieb-Liniger)
function F = root2d(x)
syms k
for n=1:N
P(n) = symprod(((x(n)-x(k)+i*c)./(x(n)-x(k)-i*c)), k, 1, N);
%For example for N=2 I will get the functions:
%F(1) = (exp(-i*x(1).*L)).*((x(1)-x(1)+i*c)./(x(1)-x(1)-i*c))).*((x(1)-x(2)+i*c)./(x(1)-x(2)-i*c)))+1;
%F(2) = (exp(-i*x(2).*L)).*(((x(2)-x(1)+i*c)./(x(2)-x(1)-i*c))*.((x(2)-x(2)+i*c)./(x(2)-x(2)-i*c)))+1;
And the code for solving (solver) is:
%Bethe Eq Solver
options = optimoptions('fsolve','Display','none','PlotFcn',@optimplotfirstorderopt);
fun = @root2d
for n=1:N
x = fsolve(fun,x0,options)
But unfortenatly Iv'e got the errors:
Error using sym/subsindex (line 857)
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must be symbolic variables, and function body must be sym expression.
Error in root2d (line 7)
P(n) = symprod(((x(n)-x(k)+i*c)./(x(n)-x(k)-i*c)), k, 1, N);
Error in fsolve (line 258)
fuser = feval(funfcn{3},x,varargin{:});
Error in lieb_liniger_bethe_eq (line 10)
x = fsolve(fun,x0)
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.
What can I do to fix my code and get the Bethe roots of the N system equation?

回答 (1 件)

Alan Weiss
Alan Weiss 2021 年 10 月 12 日
You are the unfortunate victim of a naming discrepancy. The fsolve you linked is for Optimization Toolbox, not Symbolic Math sym objects. You cannot use symbolic variables directly in this fsolve.
It is possible that you can convert your code to something that would work in Optimization Toolbox by using matlabFunction. See an example here and a very similar one here.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by