[Scilab-users] numderivative Heart function

Hermes herozigle at gmail.com
Thu Nov 30 17:13:34 CET 2017


Hi Rafael,
This is how I have reproduced your guidelines:
*========
funcprot(0);
function val = H(x1, x2) 
    val=(1.25*x2-sqrt(abs(x1))).^2+x1.^2-1;
endfunction;
function m=g(x1,x2)

m=[2*x1-(x1.*(1.25*x2-sqrt(abs(x1))))/abs(x1).^(3/2),2.5*(1.25*x2-sqrt(abs(x1)))];   
endfunction

function val = HH(z) 
    x1=z(1); 
    x2=z(2); 
    val=(1.25*x2-sqrt(abs(x1))).^2+x1.^2-1;
endfunction; 
function z=dH(x)  
z=numderivative(HH,x) 
endfunction 

//test 
xx=[0.2 -0.5];
disp(H(xx(1),xx(2)));
disp(g(xx(1),xx(2)));
disp(dH(xx));

x = -1:0.01:1;
g1=g(x,2*x)
contour2d(x, 2*x', g, [0 0]);

replot([-1.415,-1,1.415,1.415]);


//expected values
//x1 -0.5566931 y1 1.2614695
//x2 0.5566931 y2 1.2614695
//x3 0. y3 0.8
//x4 0. y4 -0.8
//plot([x1 x2],[y1 y2],'gd');
//plot([x3 x4],[y3 y4],'rx');


========
*
but in spite of the fact that the help for abs can be read:
"absolute value, magnitude
Syntax
t = abs (x)
Arguments
x real or complex vector or matrix "
I receive the following alert:
  "Function not defined for given argument type (s), check arguments or
define function% function_abs for overloading."

should I define the function mabs = sqrt (x1 ^ 2 + x2 ^ 2);

And using only the function g in contour2d (x, 2 * x ', g, [0 0]) I also
receive the following alert:
---> in builtin contour2d (C: \ PROGRA ~ 1 \ SCILAB ~ 1.0 \ modules \
graphics \ macros \ contour2d.sci line 12)
at line 33 of executed file C: \ Users \ hermesr \ Documents \ Scilab Xcos \
FORUMs \ Heart and numderivative2.sce

g: Wrong size for output argument # 1: A Scalar expected.

Any help, correction or markings



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



More information about the users mailing list