solve 3 nonlinear equations with 3 unkonws with vpasolve....warning show up "seems to be affected by some numeric instability."

6 ビュー (過去 30 日間)
Hello everyone...I have problem to solve three system of non linear equations with 3 unknowns as shown below
where phai = 32 and alpha = 20 and Bim = 100
when I solve it, I found the solutions with warning
Warning: Solution '[c1 = 0.56333314518518598688984408662648, c2 =
0.8936045102316401179555243045528, c3 = 0.98968113734245934645180689276312]' seems to
be affected by some numeric instability. Inserting this solution into equation
'1168228461484486686*c1 - 23000232427283236*c2 + 7693275550769427*c3 -
920009297091329440*c1*c2 + 307731022030777080*c1*c3 - 9200092970913294400*c1^2*c2 +
3077310220307770800*c1^2*c3 + 612278275105588400*c1^2 + 6122782751055884000*c1^3 = 0'
produces the residue '0.00000022275530153006534874837556159388'.
> In symengine
In mupadengine/evalin_internal
In mupadengine/feval_internal
In sym/vpasolve (line 172)
In Problem_2_442105849 (line 81)
I use this code
%##########################################################################
% Problem(2)(c) ==> f(c) = c/(1+alpha*c)^2, alpha = 20, phai^2 = 32, Bim = 100
% Subtitute f(c) = c/(1+alpha*c)^2 into Equations as follow:
% Eq.9 (13.59530877 + 1/(1+alpha*c1)^2)*c1 - 20.42831009*c2 + 6.833001321*c3 = 0
% Eq.10 14.57168991*c1 - (91.40469119 + 1/(1+alpha*c2)^2)*c2 - 76.83300129*c3 = 0
% Eq.3 0.9482702526c1 - 14.948270256c2 + (14+Bim)c3 - Bim = 0
% Solution
% Inputs
alpha = 20;
phai2 = 32^2;
Eq9 = phai2*(c1/(1+alpha*c1)^2) + 13.59530877*c1 - 20.42831009*c2 + 6.833001321*c3;
Eq10 = 14.57168991*c1 - phai2*(c2/(1+alpha*c2)^2) - 91.40469119*c2 + 76.83300129*c3;
Eq6 = 0.9482702526*c1 - 14.948270256*c2 + (14+Bim)*c3 - Bim;
sol_3 = vpasolve([Eq9 == 0, Eq10==0, Eq6==0],[c1,c2,c3]); % Using vpasolve to solve numerically
% Display the solutions
fprintf("Solutions (c) as follow:\n");
k=0;
for i=1:length(sol_3.c1)
if isreal(sol_3.c1(i))
k=k+1;
fprintf("|| Solution %d\n",k);
fprintf("|| c1 = %.4f c2 = %.4f c3 = %.4f\n",sol_3.c1(i),sol_3.c2(i),sol_3.c3(i));
end
end
for i=1:length(sol_3.c1)
if ~isreal(sol_3.c1(i))
k=k+1;
fprintf("|| Solution %d\n",k);
fprintf("|| c1 = %.4f%+.4fi c2 = %.4f%+.4fi c3 = %.4f%+.4fi\n",real(sol_3.c1(i)),imag(sol_3.c1(i)),real(sol_3.c2(i)),imag(sol_3.c2(i)),real(sol_3.c3(i)),imag(sol_3.c3(i)));
end
end
fprintf("||=======================================================================||\n");
%##########################################################################

回答 (1 件)

Chidvi Modala
Chidvi Modala 2020 年 10 月 27 日
Hi Abdullah,
The vpa commands, like vpasolve, try to return an answer accurate to the digits() setting. Here that fails and the system issues a warning to indicate that. The error message tells you how accurate the system managed to calculate a solution to. The solutions appear to be fairly accurate and good enough. You will be able to complete your work without trouble by simply turning off the warnings,
warning('off', 'symbolic:numeric:NumericalInstability')
Before doing so, you may check the returned results are good enough. For example in the warning,
Warning: Solution '[c1 = - 0.0051621569086099834898074490891583 - 0.00048822629555725762835974056914787i, c2 = -
0.032429710190290267356308550056465 - 0.039482775202317809077679764419658i, c3 = 0.87298357059287256401584217486686 -
0.0051731247693730497577646047617452i]' seems to be affected by some numeric instability. Inserting this solution into equation
'1168228461484486686*c1 - 23000232427283236*c2 + 7693275550769427*c3 - 920009297091329440*c1*c2 + 307731022030777080*c1*c3 -
9200092970913294400*c1^2*c2 + 3077310220307770800*c1^2*c3 + 612278275105588400*c1^2 + 6122782751055884000*c1^3 = 0' produces the
residue '- 0.00000065744475774907684818232970828457 - 0.000000015950832025180537446276284353478i'.
The system has a solution that is accurate to 7 digits (You can look at the residue and count the zeros). If you require a more accurate result then you can increase digits by inserting, for example,
digits(45)
into the script before vpasolve. This will not remove the warnings though.

カテゴリ

Help Center および File ExchangeNumeric Solvers についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by