]> gitweb.michael.orlitzky.com - octave.git/blobdiff - tests/fixed_point_method_tests.m
Move all of the tests into a subdirectory.
[octave.git] / tests / fixed_point_method_tests.m
diff --git a/tests/fixed_point_method_tests.m b/tests/fixed_point_method_tests.m
new file mode 100644 (file)
index 0000000..df3b05e
--- /dev/null
@@ -0,0 +1,19 @@
+g = @(x) 1 + atan(x);
+expected_fp = 2.1323;
+tol = 1 / 10^10;
+x0 = 2.4;
+unit_test_equals("Homework #2 problem #5 fixed point is correct", ...
+                expected_fp, ...
+                fixed_point_method(g, tol, x0));
+
+
+h = 0.5;
+g1 = @(u) 1 + h*exp(-u(1)^2)/(1+u(2)^2);
+g2 = @(u) 0.5 + h*atan(u(1)^2 + u(2)^2);
+my_g = @(u) [g1(u), g2(u)];
+tol = 1 / 10^9;
+u0 = [1,1];
+expected_fp = [1.0729, 1.0821];
+unit_test_equals("Homework #3 problem #3i fixed point is correct", ...
+                expected_fp, ...
+                fixed_point_method(my_g, tol, u0));