teaching code for newton2



"Robert Dodier" <robert.dodier at gmail.com> schrieb:
> Here's an attempted rewrite.
> numer  : true;
> f(ax) := [sin(ax[1,1]*ax[2,1]), ax[1,1] - 2];
> J(ax) := ''(matrix (diff (f(ax), ax[1,1]), diff (f(ax), ax[2,1])));
> ax : matrix ([1.5], [1.5]);
> for i:1 thru 100 do ax : ax + J(ax)^^(-1).(- f(ax));
> ax;

Dear Robert,

in thinking about your code I must confess that it is with some 'raffinesse' and
experience.
Using one variable ax and splitting it in parts, good idea. But I ask myself: why does
Robert use _double_ indexing ax[2,1] etc., i.e. a mathematical matrix construct? 
I hear my students asking: why is it not sufficent to use _single_ indices, i.e. vectors?

So I tried the following:

numer : true; 
f(X) := [sin(X[1]*X[2]), X[1] - 2]; 
J(X) := ''(matrix (diff (f(X), X[1]), diff (f(X), X[2]))); 
X : matrix ([1.5,1.5]); 
/* X : matrix ([1.5], [1.5]); worked neither */
for i:1 thru 100 do X : X + J(X)^^(-1).(- f(X)); 
X;

.. and it does _not_ work. Surely you have known this beforehand.

Please, what is the rationale behind the fix using double indexing?
It would be nice if someone could elaborate a little bit about it.
 
HTH  Wolfgang