aboutsummaryrefslogtreecommitdiffstats
path: root/buch/chapters/070-orthogonalitaet/images/laguerre.m
blob: 0a9c18cbc92bde496c68d8334298d86ad428edd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#
# laguerre.m
#
# (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule
#
pkg load miscellaneous
global N;
N = 120;

function retval = laguerre(n, x)
	s = 1;
	p = 1;
	if (n == 0)
		retval = p;
	else
		for k = (1:n)
			p = p * x * (-n-1+k) / (k * k);
			s = s + p;
		endfor
		retval = s;
	end
endfunction

function retval = laguerrepath(fn, n, name)
	global N;
	h = 12 / N;
	fprintf(fn, "\\def\\laguerre%s{\n", name)
	fprintf(fn, "\t   ({%.5f*\\dx},{%.5f*\\dy})", 0, 1);
	for i = (1:N)
		x = h * i;
		y = laguerre(n, x);
		if (abs(y) > 100)
			y = 100 * sign(y);
		end
		fprintf(fn, "\n\t-- ({%.5f*\\dx},{%.5f*\\dy})", x, y);
	endfor
	fprintf(fn, "\n}\n");
endfunction

fn = fopen("laguerrepaths.tex", "w");

laguerrepath(fn,  0, "zero");
laguerrepath(fn,  1, "one");
laguerrepath(fn,  2, "two");
laguerrepath(fn,  3, "three");
laguerrepath(fn,  4, "four");
laguerrepath(fn,  5, "five");
laguerrepath(fn,  6, "six");
laguerrepath(fn,  7, "seven");
laguerrepath(fn,  8, "eight");
laguerrepath(fn,  9, "nine");

fclose(fn);