Solution of nonlinear equation
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello everyone!
When solving the following equations, I defined variable parameters by syms, but it implied that wasn't correct. I don't know how to do, could you help me solve it? Thank you very much!
Best regards

clc; clear
%Solve nonlinear equations
syms a(-6) a(-5) a(-4) a(-3) a(-2) a(-1) a(0) a(1) a(2) a(3) a(4) a(5) a(6) a(7)
[Sa(-6),Sa(-5),Sa(-4),Sa(-3),Sa(-2),Sa(-1),Sa(-0),Sa(1),Sa(2),Sa(3),Sa(4),Sa(5),Sa(6),Sa(7)] ...
=solve(e(-3)==0,e(-2)==0,e(-1)==0,e(0)==0,e(1)==0,e(2)==0,a(-6)==a(7),a(-5)==a(6), ...
a(-4)==a(5),a(-3)==a(4),a(-2)==a(3),a(-1)==a(2),a(0)==a(1))
function y=di(x)
% Define dirichlet function
y=0.*(x~=0)+1.*(x==0);
end
function F=e(n)
F=9*symsum(a(s),s,-6,7)*symsum(a(t),t,-6,7)*di(9*n+2+3*+s)-di(n);
end
0 Kommentare
Akzeptierte Antwort
Torsten
am 25 Aug. 2022
Bearbeitet: Torsten
am 25 Aug. 2022
format long
a0 = rand(1,7);
%a0 = [5.3916,0.0342,1.789,0.619,-0.0104,0.2155,0.0575];
options = optimset('MaxFunEvals',1000000,'MaxIter',1000000,'TolFun',1e-14,'TolX',1e-14);
%a = fsolve(@fun,a0,options)
a = lsqnonlin(@fun,a0,[],[],options)
norm(fun(a))
function res = fun(a)
A = [fliplr(a),a];
res = zeros(1,7);
for n = -3:3
sum_j = 0.0;
for j = -6:7
aj = A(j+7);
sum_k = 0.0;
for k = -6:7
ak = A(k+7);
deltak = double(9*n+2+3*k+j==0);
sum_k = sum_k + ak*deltak;
end
sum_j = sum_j + aj*sum_k;
end
res(n+4) = 9*sum_j - double(n==0);
end
end
8 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



