x1 = (4 - x2 + x1x22)/10This is the problem in fixed point form x = g(x). If you use this function g(x) parts (a), (b) should be easy.
x2 = (3 + x1 + x12x22)/10
Problem 2(b): How to plot contours where two functions are zero:
Example: To plot the contours where x1 + x2 -x1*x2 - 2 = 0 and x1 - x2 + x1^3 + 3 = 0
in the rectangle [-4,4]×[3,3] use
[X1,X2] = meshgrid(linspace(-4,4,100),linspace(-3,3,100)); contour(X1,X2, X1 + X2 - X1.*X2 - 2,[0 0],'b-'); hold on contour(X1,X2, X1 - X2 + X1.^3 + 3,[0 0],'r:'); hold offNote that you must use .* ./ .^ instead of * / ^.
num2bin.m
and bin2num.m (note that you
have to put the files where
Matlab can find them)A = sparse(iv,jv,av);E.g., the full matrix given by A = [0 7 0; 0 0 8; 9 0 0] can be defined as a sparse matrix by
A = sparse([1 2 3],[2 3 1],[7 8 9])
divdiff computes the divided differences
d1=f[x1,...,xn],
d2=f[x2,...,xn],...,dn=f[xn]
Algorithm d=divdiff(x,y)
d := y
For k=1 to n-1
For i=1 to n-k
di :=
(di+1-di)/(xi+k-xi)
evnewt evaluates the interpolating polynomial at the point t
Algorithm v=evnewt(d,x,t)
v := d1
For i=2 to n
v := v·(t-xi) + di
h = (b-a)/(n-1); xj = a + (j-1)h for j = 1,...,nIn Matlab you can use x = linspace(a,b,n) to define a vector of equidistant nodes.
|(x-x1)...(x-xn)| ≤ hn(n-1)!/4 for x in [a,b]Chebyshev nodes on the interval [a,b] are given by
xj = (a+b)/2 + cos(The node polynomial has the bound(j-1/2)/n) (b-a)/2 for j = 1,...,n.
|(x-x1)...(x-xn)| ≤ 2 ((b-a)/4)n for x in [a,b]
x contains the x-coordinates of the nodes, the column
vector y contains the function values at the nodes, the
vector yp contains the derivatives at the nodes. The vector
xi contains the points where we want to evaluate the
interpolating function, the vector yi contains the
corresponding values of the interpolating function.
hermite.m . Then use yi =
hermite(x,y,yp,xi)yi = spline(x,[sl;y;sr],xi) yi =
spline(x,y,xi)pp = spline(x,y);
yi = ppval(pp,xi);
xs = fzero(@f,[a,b])
where the function f is given by the m-file f.m.
f=@(x)sin(x); xs=fzero(f,[3,4])function y = f(x)Then use x = fsolve(@f,x0) where x0 is the initial guess.
y = ...
function [y,A] = f(x)Then use
y = ...
A = ...
opt = optimset('Jacobian','on'); x = fsolve(@f,x0,opt);where x0 is the initial guess.
opt = optimset('TolFun',1e-5,'TolX',1e-5);There are many other options, type doc fsolve for more information.
x = fsolve(@f,x0,opt);