Permalink
Browse files

slight progress.

  • Loading branch information...
1 parent e9665eb commit 55abbd5dc1026cba8628c37c82a86f69fe103b9c @uberj committed Oct 23, 2012
Showing with 13 additions and 11 deletions.
  1. +12 −6 labs/lab3/lab3.m
  2. +1 −5 labs/lab3/make_lib.m
View
@@ -1,11 +1,17 @@
%% Lab 3
-the_root = 1
-six_digits_of_accuracy =.5E-6;
+lib = make_lib();
+
%% Problem 1
%%
+disp(sprintf('Table:'));
+disp(sprintf('Initial Interval \t Approximation \t \t Error'));
+x0 = 0.0;
+x1 = 1.0;
+[it_count, root, xn] = bisect(lib.f,x0,x1,lib.accuracy,10);
+disp(sprintf('%g to %g \t\t\t %0.10f \t\t %0.10f', x0, x1, root, lib.the_root - root));
-k = 1;
-while abs(eq1(reqx, k) - xtrue) > six_digits_of_accuracy
- k = k + 1;
-end
+x0 = 0.2;
+x1 = 2.0;
+[it_count, root, xn] = bisect(lib.f,x0,x1,lib.accuracy,10);
+disp(sprintf('%g to %g \t\t\t %0.10f \t\t %0.10f', x0, x1, root, lib.the_root - root));
View
@@ -1,9 +1,5 @@
function lib = make_lib()
- lib.f = @the_function;
+ lib.f = '(x ^ 5) - (x ^ 4) + x - 1';
lib.the_root = 1;
lib.accuracy = 5E-6;
end
-
-function y = the_function(x)
- (x ^ 5) - (x ^ 4) + x - 1;
-end

0 comments on commit 55abbd5

Please sign in to comment.