2 f_prime = @(x) 6*x^5 - 1;
5 expected_root = 1.1347;
6 unit_test_equals("Newton's method agrees with Haskell", ...
8 newtons_method(f, f_prime, tol, x0));
11 f1 = @(u) u(1)^2 + u(1)*u(2)^3 - 9;
12 f2 = @(u) 3*u(1)^2*u(2) - u(2)^3 - 4;
13 f = @(u) [f1(u); f2(u)];
14 ## The partials for the Jacobian.
15 f1x = @(u) 2*u(1) + u(2)^3;
16 f1y = @(u) 3*u(1)*u(2)^2;
17 f2x = @(u) 6*u(1)*u(2);
18 f2y = @(u) 3*u(1)^2 - 3*u(2)^2;
19 ## f_prime == Jacobian.
20 f_prime = @(u) [ f1x(u), f1y(u); f2x(u), f2y(u) ];
23 expected_root = [1.33635; 1.75424];
24 [actual_root, iterations] = newtons_method(f, f_prime, tol, u0);
25 unit_test_equals("Homework #3 problem #4 root is correct", ...