Question: Printing the Jacobian at each iteration (Newton's method for a nonlinear system)

Dear all,
Greetings!
I have made a code that solves a nonlinear system of equations by using Newton's Method. I am facing a problem in printing the Jacobian at each iteration. It only prints its lable not the Jacobian matrix itself. Please help me in this regard.
 

"restart;  iter:=5;  f[1](x,y):=3 x^(2)-y^(2);  f[2](x,y):=3 x^()*y^(2)-x^(3)-1;"

5

 

proc (x, y) options operator, arrow; 3*x^2-y^2 end proc

 

proc (x, y) options operator, arrow; 3*x*y^2-x^3-1 end proc

(1)

var := x, y

x, y

(2)

pointt := [x[n], y[n]]

[x[n], y[n]]

(3)

NULL

NULL

NULL

x[0] := 1; y[0] := 1

1

 

1

(4)

for n from 0 to iter do print('f1' = f[1](x[n], y[n]), 'f[2]' = f[2](x[n], y[n])); print('J'*[n] = J[n]); J[n] := Student[MultivariateCalculus][Jacobian]([f[1](x, y), f[2](x, y)], [var] = pointt, output = matrix); sol[n] := eval((Vector(2, {(1) = x[n], (2) = y[n]}))-1/J[n].(Vector(2, {(1) = f[1](x[n], y[n]), (2) = f[2](x[n], y[n])}))); x[n+1] := evalf(sol[n][1]); y[n+1] := evalf(sol[n][2]); print(x[n+1], y[n+1]) end do

f1 = 2, f[2] = 1

 

J*[0] = J[0]

 

.6111111111, .8333333333

 

f1 = .4259259256, f[2] = 0.44924554e-1

 

J*[1] = J[1]

 

HFloat(0.5036590808700434), HFloat(0.8524944221287727)

 

f1 = HFloat(0.03427066946790058), f[2] = HFloat(-0.029666658033242088)

 

J*[2] = J[2]

 

HFloat(0.4999641210723523), HFloat(0.8660456363859079)

 

f1 = HFloat(-1.4267722412308892e-4), f[2] = HFloat(-1.2576398193964167e-6)

 

J*[3] = J[3]

 

HFloat(0.50000000001492), HFloat(0.8660254018170033)

 

f1 = HFloat(3.45245787514159e-9), f[2] = HFloat(-5.089167087746205e-9)

 

J*[4] = J[4]

 

HFloat(0.5), HFloat(0.8660254037844386)

 

f1 = HFloat(1.1102230246251565e-16), f[2] = HFloat(-2.220446049250313e-16)

 

J*[5] = J[5]

 

HFloat(0.5), HFloat(0.8660254037844387)

(5)

NULL

NULL


 

Download q1nwtnnonlinearsys.mw

the print output is too ugly, any help in making it more elegant would also be appreciated .

Please Wait...