function main
global % List parameters you need to communicate to "my_objectives"
% such as weights, endpoints (no commas)
% Set the physical parameter values,
% and code parameters like the number of morphing steps,
% newton tol, etc.
% Set your initial guesses at x's, y's and t's:
% load them into a single vector V with 16 elements.
V =
hold off
for m=1:n_morphing_steps
xnplus1 =
ynplus1 =
V = newton(@my_objectives,V,tol,maxits)
% plot configuration
hold on
end
end
function r=newton(f,x0,tol,maxits)
% Totally general newton's method.
% Calls fdjac(f,x) to get jacobian at x.
% Use backslash operator, not "inv".
end
function fdjac(f,x)
% exactly as I emailed it to you: no changes needed
end
function F = my_objectives(V)
global % List parameters you need here such as weights, endpoints
x = V(1:5); % or maybe x = [x0;V(1:5);xnplus1]
y = V(6:10);
t = V(11:16);
F = zeros(16,1);
% set all 16 function values
F(1) = % ... (or use loops)
% ...
F(16) =
end
BROYDEN does not work: use true newton's method,
and use fdjac.m to approximate the jacobian
for each newton step.
RULE 1: Develop code piece by piece, and test each piece separately on simple cases where you know what the result should be. DO NOT WRITE CODE ALL AT ONCE FOR THE ACTUAL 16D PROBLEM AND EXPECT IT TO WORK. For example, test your newton code with fdjac on the 2D problem from HW5.
RULE 2: Keep all code specific to the hanging objects problem separate from general code. For example, your newton function should have nothing at all in it that refers to the specific objects-dangling-from-a-string problem we'll be using it to solve.
Your code should have at least 3 functions: the main one that sets the parameters and contains the morphing loop, a function "newton" that implements Newton's method using fdjac for jacobian evaluation, and a function that evaluates the 16 components of our objective function F.