[Scilab-users] numderivative Heart function

Hermes herozigle at gmail.com
Fri Dec 1 09:59:11 CET 2017


Help me,
why the same function with different procedures to determine the critical
points; these differ in the results.
What am I not doing correctly or interpreted?
*
function val = Heart(x1, x2) 
    val=(1.25*x2-sqrt(abs(x1))).^2+x1.^2-1;
endfunction;


function y = heart_up(x1)
    y = 4/5 * (sqrt(abs(x1))+sqrt(1-x1.^2))
endfunction
function y = heart_down(x1)
    y = 4/5 * (sqrt(abs(x1))-sqrt(1-x1.^2))
endfunction

function y = du_heart(x1)
    y = numderivative(heart_up, x1);
endfunction
function y = dd_heart(x1)
    y = numderivative(heart_down, x1);
endfunction

x1 = fsolve(-0.6, du_heart); y1 = heart_up(x1);disp(y1,"y1",x1,"x1");
x2 = fsolve( 0.6, du_heart); y2 = heart_up(x2);disp(y2,"y2",x2,"x2");
x3 = fsolve( 0.0, du_heart); y3 = heart_up(x3);disp(y3,"y3",x3,"x3");
x4 = fsolve( 0.0, dd_heart); y4 = heart_down(x4);disp(y4,"y4",x4,"x4");

x = -1:0.01:1;
contour2d(x, 2*x, Heart, [0 0]);
plot([x1 x2],[y1 y2],'gd');
plot([x3 x4],[y3 y4],'rx');
replot([-1.415,-1,1.415,1.415]);
*




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



More information about the users mailing list