# Trying to solve Bethe equations - system of non linear equations

1 ビュー (過去 30 日間)
Daniel Vainshtein 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: https://www.mathworks.com/help/optim/ug/fsolve.htm
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)
L=1;c=1;N=10;
syms k
for n=1:N
P(n) = symprod(((x(n)-x(k)+i*c)./(x(n)-x(k)-i*c)), k, 1, N);
F(n)=(exp(-i*x(n).*L)).*P(n)+1;
%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;
end
end
And the code for solving (solver) is:
%Bethe Eq Solver
options = optimoptions('fsolve','Display','none','PlotFcn',@optimplotfirstorderopt);
fun = @root2d
N=10;
x0=[];
for n=1:N
x0=[0,x0];
end
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 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

サインインしてコメントする。

R2020b

### Community Treasure Hunt

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

Start Hunting!

Translated by