matrix - I don't comprehend why Scilab is giving me "syntax error, unexpected ;" -


well, got newton's method multiple variables code modified me function 4 variables instead of 2, keep getting error

syntax error, unexpected ;

referencing line 9 jacobian matrix partial derivatives of equations on function f. every " " column , every ";" line.

clear;clc function z=f(p1,p2,p3,p4)      z(1)=0.3*(500-p1)^0.5-0.2*(p1-p2)^0.5+0.2*(p1-p3)^0.5     z(2)=0.2*(p1-p2)^0.5-0.1*(p2-p4)^0.5+0.2*(p2-p3)^0.5     z(3)=0.1*(p1-p3)^0.5-0.2*(p3-p2)^0.5+0.1*(p3-p4)^0.5     z(4)=0.1*(p2-p4)^0.5+0.1*(p3-p4)^0.5-0.2*(p4)^0.5 endfunction function z=j(p1,p2,p3,p4) //jacobiano     z=[-0.3/(2*sqrt(500-p1))-0.2/(2*sqrt(p1-p2))+0.2/(2*sqrt(p1-p3)) 0.2/(2*sqrt(p1-p2)) -0.2/(2*sqrt(p1-p3)) 0;0.2/(2*sqrt(p1-p2)) -0.2/(2*sqrt(p1-p2))-0.1/(2*sqrt(p2-p4))+0.2/(2*sqrt(p2-p3) -0.2/(2*sqrt(p2-p3)) -0.1/(2*sqrt(p2-p4));0.1/(2*sqrt(p1-p3)) 0.2/(2*sqrt(p3-p2)) -0.1/(2*sqrt(p1-p3))-0.2/(2*sqrt(p3-p2))+0.1(2*sqrt(p3-p4)) -0.1/(2*sqrt(p3-p4));0 0.1/(2*sqrt(p2-p4)) 0.1/(2*sqrt(p3-p4)) -0.1/(2*sqrt(p2-p4))-0.1/(2*sqrt(p3-p4))-0.2/(2*sqrt(p4))] endfunction 

the code doesn't end here, error in format used in 4x4 jacobian matrix or in function itself, don't why wrong.

appreciate help.

you forgot close parenthesis in column 191 of line 9, , forgot operator on column 319.

if you're creating matrix in elements results of operations, you'd better use commas instead of blank spaces separate them. should using ... break matrix definition in more 1 line improve readability. jacobian function lot easier debug if written this:

function z=j(p1,p2,p3,p4) //jacobiano     z=[-0.3/(2*sqrt(500-p1))-0.2/(2*sqrt(p1-p2))+0.2/(2*sqrt(p1-p3)),...         0.2/(2*sqrt(p1-p2)),...        -0.2/(2*sqrt(p1-p3)),...         0;...         ...         0.2/(2*sqrt(p1-p2)),...        -0.2/(2*sqrt(p1-p2))-0.1/(2*sqrt(p2-p4))+0.2/(2*sqrt(p2-p3),...        -0.2/(2*sqrt(p2-p3)),...        -0.1/(2*sqrt(p2-p4));...         ...         0.1/(2*sqrt(p1-p3)),...         0.2/(2*sqrt(p3-p2)),...        -0.1/(2*sqrt(p1-p3))-0.2/(2*sqrt(p3-p2))+0.1(2*sqrt(p3-p4)),...        -0.1/(2*sqrt(p3-p4));...         ...         0,...         0.1/(2*sqrt(p2-p4)),...         0.1/(2*sqrt(p3-p4)),...        -0.1/(2*sqrt(p2-p4))-0.1/(2*sqrt(p3-p4))-0.2/(2*sqrt(p4))] endfunction 

in style, mistakes can spotted: notice missing ) in line 8, , missing / in line 14.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -