aboutsummaryrefslogtreecommitdiffstats
path: root/buch/chapters/090-pde/bessel/besselzeros.m
blob: 9c8fa9df434b846f2e2b0f315f78f834921c82b6 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#
# besselzeros.m -- find zeros of bessel functions
#
# (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule

global maxmu;
maxmu = 7;
global maxk;
maxk = 10;
global mu;

nachkommastellen = 4;

function retval = f(x)
	global mu;
	retval = besselj(mu, x);
endfunction

kzeros = zeros(maxk+1, maxmu+1);
for mu = (0:maxmu)
	k = 0;
	if (mu > 0)
		kzeros(1, mu+1) = 0;
		k = k+1;
	endif
	x = 0.0001;
	while (k <= maxk)
		bracket = [ x, x+1 ];
		if (f(bracket(1)) * f(bracket(2)) < 0) 
			kzeros(k+1,mu+1) = fzero("f", bracket);
			k = k + 1;
		endif
		x = x + 1;
	endwhile
endfor

# kzeros

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

fprintf(fn, "\\begin{tabular}{|>{$}c<{$}");
for mu = (0:maxmu)
	fprintf(fn, "|>{$}r<{$}");
endfor
fprintf(fn, "|}\n");

fprintf(fn, "\\hline\n");
fprintf(fn, " k ");
for mu = (0:maxmu)
	fprintf(fn, "& \\mu = %d ", mu);
endfor
fprintf(fn, "\\\\\n");
fprintf(fn, "\\hline\n");

for k = (0:maxk)
	fprintf(fn, " %d ", k);
	for mu = (0:maxmu)
		value = kzeros(k+1, mu+1);
		if (value == 0) 
			fprintf(fn, "& 0\\phantom{.%0*d}", nachkommastellen, 0);
		else
			fprintf(fn, "& %*.*f", nachkommastellen+4, nachkommastellen, kzeros(k+1, mu+1));
		endif
	endfor
	fprintf(fn, "\\\\\n");
endfor
fprintf(fn, "\\hline\n");
fprintf(fn, "\\end{tabular}\n");

fclose(fn);