From e6dfa9a04550a127df36bca3ae614ebca99401c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Sat, 8 Jan 2022 13:14:17 +0100 Subject: Pole und Nullstellen der Gewichtsfunktion --- buch/chapters/070-orthogonalitaet/images/weight.m | 59 +++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 buch/chapters/070-orthogonalitaet/images/weight.m (limited to 'buch/chapters/070-orthogonalitaet/images/weight.m') diff --git a/buch/chapters/070-orthogonalitaet/images/weight.m b/buch/chapters/070-orthogonalitaet/images/weight.m new file mode 100644 index 0000000..62ea447 --- /dev/null +++ b/buch/chapters/070-orthogonalitaet/images/weight.m @@ -0,0 +1,59 @@ +# +# weight.m +# +# (c) 2022 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule +# +global N; +N = 200; +global s; +s = 8; +global l; +l = 10; +global A; +A = 0.3; + +function retval = gewicht(x) + global s; + retval = (x + 1)^(-2) * (x + 1/3)^(-0.9) * (x - 1/3) * (x - 1)^2 * exp(s * x); +endfunction + +h = 2 / N; +x = (-1:h:1); + +function punkt(fn, x, y) + global A; + fprintf(fn, "(%.4f,%.4f)", x, A * abs(y)); +endfunction + +fn = fopen("weightfunction.tex", "w"); +plotting = 0; +drittelsuchen = 1; +for i = (1:N+1) + if (drittelsuchen > 0) + if (x(i) > (1/3)) + fprintf(fn, "\n\t-- "); + punkt(fn, 1/3, 0); + fprintf(fn, "% drittel"); + drittelsuchen = 0 + end + end + y = gewicht(x(i)); + if (plotting > 0) + if (abs(y) > l) + fprintf(fn, ";\n"); + plotting = 0; + end + fprintf(fn, "\t\n-- "); + punkt(fn, x(i), y); + else + if (abs(y) < l) + fprintf(fn, "\\draw[color=red,line width=2.0pt] "); + punkt(fn, x(i), y); + plotting = 1; + end + end +endfor +if (plotting > 0) + fprintf(fn, ";\n"); +end +fclose(fn); -- cgit v1.2.1