Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- r = 0.1;
- x0 = 0;
- y0 = 0;
- z0 = powierzchnia[x0, y0];
- listaKatow = Table[RandomReal[{0, 2 Pi}], {i, 500}];
- powierzchnia[x_, y_] = 2 x + 3 y^2;
- f[x_, y_, xp_, yp_,
- zp_] = (x - xp)^2 + (y - yp)^2 + (2 x + 3 y^2 - zp)^2 - r^2;
- i = 1;
- points = {};
- While[i <= 500, alfa = listaKatow[[i]];
- Result =
- FindInstance[{(y - y0)*Cos[alfa] - (x - x0)*Sin[alfa] == 0,
- f[x, y, x0, y0, z0] == 0}, {x, y}, Reals, 2];
- xPunktu = Result[[1, 1, 2]];
- yPunktu = Result[[1, 2, 2]];
- zPunktu = powierzchnia[xPunktu, yPunktu];
- pointCurrent = {xPunktu, yPunktu, zPunktu};
- xPunktu2 = Result[[2, 1, 2]];
- yPunktu2 = Result[[2, 2, 2]];
- zPunktu2 = powierzchnia[xPunktu2, yPunktu2];
- pointCurrent =
- RandomChoice[{{xPunktu, yPunktu, zPunktu}, {xPunktu2, yPunktu2,
- zPunktu2}}];
- points = Append[points, pointCurrent];
- x0 = pointCurrent[[1]];
- y0 = pointCurrent[[2]];
- z0 = pointCurrent[[3]];
- i++;]
- rows = List[];
- n = 1;
- While[n <= 500,
- r0 = points[[n, 1]]^2 + points[[n, 2]]^2 + points[[n, 3]]^2;
- rows = Append[rows, {r0, n, r0/n}];
- n = n + 1]
- srednia = Mean[rows[[All, 3]]];
- odchylenie = StandardDeviation[rows[[All, 3]]];
- Print["Średnia:", srednia];
- Print["Odchylenie standardowe:", odchylenie];
- rows = Insert[rows, {"r^2", "t", "r^2/t"}, 1];
- Grid[rows[[;; ;; 10]], Frame -> All]
- Animate[Show[
- Plot3D[{2 x + 3 y^2}, {x, -1, 1}, {y, -1, 1},
- BoxRatios -> {1, 1, 1}],
- Graphics3D[{Green, PointSize[.02], Line[points[[;; it]]],
- Point[points[[it]]]}]], {it, 1, 500, 1}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement