[Scilab-users] Find the points of intersection of two curves

Hermes herozigle at gmail.com
Fri Jan 12 10:46:57 CET 2018


Hello,
How could I improve the accuracy of intersection points?

clear;
funcprot(0);
timer();
function Sys=F(x)
x0=x(1);x1=x(2);
Sys(1)=x1^2-x0*x1+x0^2-1;
Sys(2)=sin(4*x1^2)+sin(5*x0^2);
endfunction  
function D=Draghilev(x)
x0=x(1);x1=x(2);x2=x(3);x00=ics(1);x01=ics(2);
D=[8*x01^2*x1*cos(4*x1^2)-8*x00*x01*x1*cos(4*x1^2)+8*x00^2*x1*cos(4*x1^2)-8*x1*cos(4*x1^2)-2*sin(4*x01^2)*x1-2*sin(5*x00^2)*x1+x0*sin(4*x01^2)+x0*sin(5*x00^2);
-sin(4*x01^2)*x1-sin(5*x00^2)*x1+2*x0*sin(4*x01^2)-10*x0*cos(5*x0^2)*x01^2+10*x0*cos(5*x0^2)*x00*x01+2*x0*sin(5*x00^2)-10*x0*cos(5*x0^2)*x00^2+10*x0*cos(5*x0^2);
-8*x1^2*cos(4*x1^2)+16*x0*x1*cos(4*x1^2)-20*x0*cos(5*x0^2)*x1+10*x0^2*cos(5*x0^2)];
endfunction

ics=[0;1]
ics=[ics;1];
disp(ics)
function [dxdt]=odes(t,x)
[dxdt]=Draghilev(x);
endfunction
N=100;
smin=0.0;
smax=5;
h=0.0001;

step=smax/N;
    t=smin:step:smax;
    t0=0;
    atol=h;
    LL= ode("fix",ics,t0,t,atol,odes)
disp(timer(),"tiempo de ejecucion C");
a=get("current_axes")//get the handle of the newly created axes
a.axes_visible="on"; // makes the axes visible
a.font_size=3; //set the tics label font size
a.x_location="middle"; //set the x axis position
plot(t,LL(1,1:$),"-cya",t,LL(2,1:$),"-g",t,LL(3,1:$),"-r")


s=LL(3,:)-LL(1,:);
ym=s(1:$-1).*s(2:$);
z=find(ym <= h);

yi=interpln([t;LL(1,:)],t(z+1));
plot(t(z+1),yi,"b*") 

//
s=LL(3,:)-LL(2,:);
ym=s(1:$-1).*s(2:$);
z=find(ym <= 0);
I1=LL(2,find(ym <= h));
plot(t(z+1),I1,"g*") 

Gracias




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



More information about the users mailing list