Solution of nonlinear equation

3 views (last 30 days)
lei
lei on 25 Aug 2022
Commented: Torsten on 29 Aug 2022
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

Accepted Answer

Torsten
Torsten on 25 Aug 2022
Edited: Torsten on 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)
Local minimum possible. lsqnonlin stopped because the final change in the sum of squares relative to its initial value is less than the value of the function tolerance.
a = 1×7
0.197493709597352 0.281302916777374 0.140651449715022 -0.140651455082789 0.000000000021439 0.140651453041311 -0.140651455260134
norm(fun(a))
ans =
3.040264027305917e-09
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 Comments
Torsten
Torsten on 29 Aug 2022
Edited: Torsten on 29 Aug 2022
I am confused that whether it implies that the equations only two exact solutions?
Seems the solution is parametrized by one parameter (see above).
Torsten
Torsten on 29 Aug 2022
@lei comment moved here:
Torsten, thank you very much! The result is what I want. Thanks again and have a nice day!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!