[Scilab-users] solve a system of equations in scilab

Rafael Guerra jrafaelbguerra at hotmail.com
Sun Sep 17 12:05:41 CEST 2017


The "expected" solution is not a solution of the equations you forwarded:

--> Q([1.496447;-0.9574371],0)

ans  =

  - 7.659497

  - 0.0000001



Therefore there is probably a typo in the Q function forwarded.



Plugin-in the fsolve solution into the Q-function does output zeros:

-->Q([1.496447;0.9574371],0)

ans  =

  - 0.0000002

  - 0.0000001



-----Original Message-----
From: users [mailto:users-bounces at lists.scilab.org] On Behalf Of Hermes
Sent: Sunday, September 17, 2017 11:52 AM
To: users at lists.scilab.org
Subject: Re: [Scilab-users] solve a system of equations in scilab



Hi, Rafael

In my case,

by setting as initial values [1.5, -0.9]

I get:

1.496447

0.9574371

I always get the second positive value, when it is expected to be negative.

clear;

function Sys=Q(x,z)

Sys(1)=(x(1)-2)^2+(x(2)+2)^2+z^2-9;

Sys(2)=x(1)^6+x(2)^6+z^6-12;

endfunction

z=0;



a=[0,0;1,0;1.2,-1;1.5,-0.9]

for i = 1:3

[j,v,info]=fsolve(a(i,:)',list(Q,z))

disp(j,v,"results",a(i,:),"inc;",i)

end



in this script with several initial values, in the last pair of values, the

solution is negative for the two variables, when in fact it is expected:



and to my pairs the results are changed with respect to the variables

/

--> exec('C:\Users\hermesr\Documents\Scilab Xcos\fsolve_eje19.sce', -1)



   1.



inc;



   0.   0.



results



  0.

   1.243D-14



  -0.9574371

  -1.496447



   2.



inc;



   1.   0.



results



   1.137D-13

   1.345D-11



   1.496447

   0.9574371



   3.



inc;



   1.2  -1.



results



   0.

  -1.599D-14/



* -0.9574371

  -1.496447*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20170917/2a94bc16/attachment.htm>


More information about the users mailing list