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

Rafael Guerra jrafaelbguerra at hotmail.com
Sun Sep 17 11:05:14 CEST 2017


Hi,



The solution returned by fsolve seems to be a valid one because:

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

ans  =

  - 0.0000002

  - 0.0000001



You say that the initial guess of [1.5;-0.9] is close to the expected values, however:

-->Q([1.5;-0.9],0)

ans  =

  - 7.54

  - 0.077934

is far from being zero. So there is probably a typo in your equations.



PS:

Another trivial solution is:

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

ans  =

  - 0.0000002

  - 0.0000001

Such non-linear problems should have multiple solutions, including complex ones.



Regards,

Rafael



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



Hello,

Please I need your comments.

I have tried to solve the system with different initial conditions for

fsolve and I always get the same wrong result for the second variable.



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;

[j,v,info]=fsolve([*1.5;-0.9*],list(Q,z))

disp(j,v,info)



Even when putting these initial values, very similar to the expected values,

fsolve returns

1.496447

0.9574371 the second positive value



By using these values as initial values in this script:



//Draghilev's Method

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;

[j,v,info]=fsolve([1.5;-0.9],list(Q,z))

disp(j,v,info)



N=100;

smin=0.0;

smax=0.046;

h=0.001;





x01=1.496447;

//3.9691163496*10^-12;

x02=0.9574371;

//0.353580783;

x03=0;

//-1.5130442808;

ics=[x01; x02; x03];



disp(["x(3)^2+(x(2)-2)^2+(x(1)-2)^2-9";"x(3)^6+x(2)^6+x(1)^6-12"],"systema")





disp(["2*(x(1)-2),2*(x(2)-2),2*x(3)";"6*x(1)^5,6*x(2)^5,6*x(3)^5"],"jacobian(Vm,[x(1),x(2),x(3)])");

//



//D1=12*x(2)^5*x(3)-12*(x(2)-2)*x(3)^5;

//D2=12*(x(1)-2)*x(3)^5-12*x(1)^5*x(3);

//DD=12*x(1)^5*(x(2)-2)-12*(x(1)-2)*x(2)^5;

function dydt=odes(t,x)

//dydt=zeros(x);



dydt(1)=-12*x(2)^5*x(3)-12*(x(2)-2)*x(3)^5;

dydt(2)=12*(x(1)-2)*x(3)^5-12*x(1)^5*x(3);

dydt(3)=12*x(1)^5*(x(2)-2)-12*(x(1)-2)*x(2)^5;

endfunction

step=smax/N;

t=[smin:step:smax*N];

t0=0

atol=h/100000;

rtol=h/100000;

LL= ode("rk", ics,t0, t',atol,rtol,odes)

LL=LL'

a=gca();//get the handle of the newly created axes

param3d1(LL(:,3),LL(:,2),LL(:,1),alpha=35,theta=45,"X at Y@Z",flag=[2,2])

a.rotation_angles=[65,75];



The calculations have taken a long time without converging to the solution.

I have interrupted the execution of the same.

By entering the correct values, almost instantaneously, you get the

soclucion of the system.

Help Me!!!

gracias











--

Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html

_______________________________________________

users mailing list

users at lists.scilab.org<mailto:users at lists.scilab.org>

http://lists.scilab.org/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20170917/9a2f7d5a/attachment.htm>


More information about the users mailing list