[size=85]Die Methode aus dem [url=https://www.geogebra.org/m/asnbssck]Applet[/url] wird hier verwendet, um nach der Nahfeldextrema der Beugungsfeldverteilung J(x,y) hinter dem Spalt durch Suche der lokalen Extrema entlang einer Polylinienreihe mit Hilfe JavaScript zu suchen. [u]Berechnungsgenauigkeit:[/u] err = Math.pow(10, -15).[/size]
[size=85][b] [size=100]JavaScript:[/size][br]b0 = ggbApplet.getValue('b_λ');[br]fs = ggbApplet.getValue('kkSTOP');[br][br]zo = ggbApplet.getValue('zo ');[br]//r = zo;[br][br]for (var r = zo; r <= b0 - 2; r++) {[br][br] ggbApplet.evalCommand('RunClickScript[button8]');[br] agr = 0.02;[br] bgr = 1;[br] N = ggbApplet.getValue('N');[br] m1 = [];[br] af1 = [];[br] mf1 = [];[br] m2 = [];[br] af2 = [];[br] mf2 = [];[br] ma1 = [];[br] ma2 = [];[br] m4 = [];[br] m5 = [];[br] hs = (bgr - agr) / N;[br] k = 0;[br] xa1 = agr;[br] xa2 = agr;[br] do {[br] a = agr + k * hs;[br] ggbApplet.evalCommand('t1=' + a);[br] ggbApplet.evalCommand('t2=' + (a + hs));[br] ggbApplet.evalCommand('t3=' + (a + 2 * hs));[br] f11 = ggbApplet.getValue('f1');[br] f22 = ggbApplet.getValue('f2');[br] f33 = ggbApplet.getValue('f3');[br] if (f11 < f22)[br][br] {[br] if (f22 > f33) {[br] xa1 = a;[br] m4.push((a + xa2) / 2);[br] }[br] } else {[br][br][br] if (f22 < f33) {[br] xa2 = a;[br] m5.push((a + xa1) / 2);[br] }[br] }[br][br] k = k + 1;[br] }[br] while (k <= N);[br][br] var c0 = ggbApplet.getValue('buemaxmin01');[br][br][br][br] if (c0 == 1) {[br] c01 = "max" + "_{" + r + "}";[br] c02 = "maxsat" + "_{" + r + "}";[br] } else {[br] c01 = "minsat" + "_{" + r + "}";[br] c02 = "min" + "_{" + r + "}";[br] }[br][br] h0 = ggbApplet.getValue('h0');[br][br] err = Math.pow(10, -15);[br] la = [];[br] lf = [];[br] lA = [];[br] i = 0;[br] f0 = 0;[br] j = 1;[br][br] while (j - 1 < m4.length) {[br] a = m4[j - 1];[br] h = h0;[br] while (h > err) {[br] k = 1;[br] do {[br] ggbApplet.evalCommand('t1=' + a);[br] ggbApplet.evalCommand('t2=' + (a + h));[br] f11 = ggbApplet.getValue('f1');[br] f22 = ggbApplet.getValue('f2');[br] a = a + h;[br] k = k + 1;[br] }[br] while (f11 < f22);[br] a = a - h;[br] k = k - 1;[br] ggbApplet.evalCommand('t1=' + (a - h / 2));[br] f1 = ggbApplet.getValue('f1');[br] if (f1 < f11) {[br] a = a;[br] f0 = f11;[br] } else {[br] a = a - h;[br] f0 = f1;[br] };[br][br] h = h / 2;[br] i = i + 1;[br] f11 = 3;[br] f22 = 1;[br] };[br] la.push(a);[br] j = j + 1;[br] }[br][br] ggbApplet.evalCommand('xy' + c01 + ' = CopyFreeObject[If[buemaxmin01, Append[F_max(j0 + 1), Zip[(x(Point(poly, a)), y(Point(poly, a))), a, { ' + la + ' } ] ], Zip[(x(Point(poly, a)), y(Point(poly, a))), a, { ' + la + ' }]] ] ');[br][br] ggbApplet.setVisible('xy' + c01, true);[br] ggbApplet.setPointSize('xy' + c01, 3);[br] if (c0) {[br] ggbApplet.setPointStyle('xy' + c01, 10);[br] ggbApplet.setColor('xy' + c01, 255, 0, 0);[br] } else {[br] ggbApplet.setPointStyle('xy' + c01, 3);[br] ggbApplet.setColor('xy' + c01, 137, 207, 240);[br] }[br][br][br] la = [];[br] lf = [];[br] lA = [];[br] i = 0;[br] f0 = 0;[br] j = 1;[br][br] while (j - 1 < m5.length) {[br] a = m5[j - 1];[br][br] h = h0;[br] while (h > err) {[br] k = 1;[br] do {[br] ggbApplet.evalCommand(' t1 = ' + a);[br] ggbApplet.evalCommand(' t2 = ' + (a + h));[br] f11 = ggbApplet.getValue(' f1 ');[br] f22 = ggbApplet.getValue(' f2 ');[br] a = a + h;[br] k = k + 1;[br] }[br] while (f11 > f22);[br] a = a - h;[br] k = k - 1;[br] ggbApplet.evalCommand(' t1 = ' + (a - h / 2));[br] f1 = ggbApplet.getValue(' f1 ');[br] if (f1 > f11) {[br] a = a;[br] f0 = f11;[br] } else {[br] a = a - h;[br] f0 = f1;[br] };[br][br] h = h / 2;[br] i = i + 1;[br] f11 = 3;[br] f22 = 1;[br] };[br] la.push(a);[br][br] j = j + 1;[br] }[br][br][br] ggbApplet.evalCommand('xy' + c02 + '=CopyFreeObject[If[¬buemaxmin01,Append[F_min(j0),Zip[(x(Point(poly,a)),y(Point(poly,a))), a,{' + la + '}] ],Zip[(x(Point(poly,a)),y(Point(poly,a))), a,{' + la + '}] ] ]');[br][br] ggbApplet.setVisible('xy' + c02, true);[br] ggbApplet.setPointSize('xy' + c02, 3);[br] if (c0) {[br] ggbApplet.setPointStyle('xy' + c02, 1);[br] ggbApplet.setColor('xy' + c02, 205, 149, 117);[br] } else {[br] ggbApplet.setPointStyle('xy' + c02, 10);[br] ggbApplet.setColor('xy' + c02, 0, 0, 255);[br] }[br][br] // alert("r=" + r);[br] if (r < (b0 - 2)) {[br] if (r % fs == 0) {[br][br] alert(' zo=' + r + ' bll=' + b0);[br] }[br] ggbApplet.evalCommand(' SetValue[zo,zo+1] ');[br] ggbApplet.evalCommand('If(floor(zo / 2) 2 ≟ zo, Execute({ "SetValue[buemaxmin01,1]","SetValue[l_Poly,Fresmax_j]" }), Execute({ "SetValue[buemaxmin01,0]","SetValue[l_Poly,Fresmin_j]" }) ) ');[br] } else {[br] rr = 1;[br] }[br]}[/b][/size]