[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 * / ^.
f.m and
fp.m for the function and the Jacobian. The file f.m
should look like this:
function w=f(v) w = zeros(19,1); w(1) = ... for i=2:18 w(i) = ... end w(19) = ...
The file fp.m should look like this:
function A=fp(v) A = sparse(19,19); % 19x19 zero matrix as sparse structure ... % row 1 for j=2:18 % rows 2,...,18 A(j,j-1) = ... A(j,j) = ... A(j,j+1) = ... end ... % row 19
It is easy to see that
(v1,...,vn) = (0,...,0)is one of the five solutions. If you find solutions which are very close to (0,...,0) they are approximations to the zero solution. You have to find four other solutions which are not close to (0,...,0).
Use plot(0:.05:1,[0;v;0]) to plot the angle of the rod vs. the
arclength.
num2bin.m
and bin2num.m (note that you
have to put the files where
Matlab can find them)
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,...,nThen
|(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(Then(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)[Q,R] = qr(A,0)
b = Q'*y
c = R\bc = A\y
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])includes information about textbook, office hours, grading policy