Robert's Octave Assignment

From Class Wiki
Revision as of 09:38, 4 October 2010 by Silent protagonist (talk | contribs) (Created page with 'Solving a System of Non-Linear Equations: Octave can solve a system of non-linear equations of the form f(x)=0 using the function fsolve fsolve (fcn, x0, options) [x, fvec, i…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Solving a System of Non-Linear Equations: Octave can solve a system of non-linear equations of the form

f(x)=0

using the function fsolve

fsolve (fcn, x0, options)
[x, fvec, info, output, fjac]= fsolve (fcn,... )

Where fcn is a vector containing the system, and x0 is a vector containing initial guesses for each variable (nescessary for this particular algorithm).


To solve the system

Failed to parse (syntax error): {\displaystyle −2x^2+3xy+4sin(y)-6=0}


Enter the following:

%define a function for fsolve to use, containing the system
functiony=f(x)
y(1)=-2*x(1)^2+3*x(1)*x(2)+4*sin(x(2))-6;
y(2)=3*x(1)^2-2*x(1)*x(2)^2+3*cos(x(1))+4;
endfunction

%call fsolve, and place the results into a vector
[x,fval,info]=fsolve(@f,[1;2])


See pg 331 in the Octave Manual for more info.