From: Nils Forssén Date: Mon, 31 Oct 2022 19:41:56 +0000 (+0100) Subject: push X-Git-Url: https://gitweb.forssennils.se/?a=commitdiff_plain;ds=sidebyside;p=TANA21.git push --- diff --git a/Project/grafis.svg b/Project/grafis.svg new file mode 100644 index 0000000..0b9d4dc --- /dev/null +++ b/Project/grafis.svg @@ -0,0 +1,218 @@ + + +11.11.21.31.41.51.61.71.81.92x0.50.520.540.560.580.60.620.640.660.680.7f(x)ApproxExact diff --git a/Project/grafus.svg b/Project/grafus.svg new file mode 100644 index 0000000..219db11 --- /dev/null +++ b/Project/grafus.svg @@ -0,0 +1,218 @@ + + +11.11.21.31.41.51.61.71.81.92x0.50.520.540.560.580.60.620.640.660.680.7f(x)ApproxExact diff --git a/Project/script.m b/Project/script.m index 1790f1f..970e81b 100644 --- a/Project/script.m +++ b/Project/script.m @@ -16,7 +16,7 @@ A %% Section 2 -N = 5; +N = 20; x = linspace(1,2, N); h = x(2) - x(1); @@ -48,12 +48,15 @@ answer = thomas(A, b); answer = [0.5;answer;log(2)]; plot(x, answer); + + hold on; real_values = zeros(N, 1); for i=1:N real_values(i) = (4/x(i)) - (2/(x(i)^2)) + log(x(i)) - (3/2); end plot(x, real_values); - - +xlabel("x"); +ylabel("f(x)"); +legend(["Approx"; "Exact"]); norm(answer - real_values, inf) \ No newline at end of file