I would like to select any value for n, where p[x,y] = k^n
I have tried using the initialize function, but I am not exactly sure what is going wrong
Here is what I have tried so far
Clear[f, m, p, x, y, n]
f[x_] := -x + 6
m1[x_] := -(1/2) x + 3
m2[x_] := -2 x + 6
m3[x_] := 1
p1 = Plot[{f[x], m1[x], m2[x], m3[x]}, {x, 0, 6},
PlotRange -> {{0, 6}, {0, 6}}, AxesLabel -> {x, y},
AspectRatio -> Automatic];
Manipulate[
Show[p1, centroid],
{{n, 10, "value of n"}, 2, 20, 1 , Appearance -> "Labeled"}
Initialization :>
(
p[x_, y_] := k^n;
mass = Integrate[p[x, y], {x, 0, 6}, {y, 0, p[x, y]}];
momentx = Integrate[p[x, y]*y, {x, 0, 6}, {y, 0, p[x, y]}];
momenty = Integrate[p[x, y]*x, {x, 0, 6}, {y, 0, p[x, y]}];
xbar = momenty/mass;
ybar = momentx/mass;
centroid = Graphics[{PointSize[Large], Point[{xbar, ybar}]}];
)
]