Question about maximizing pyramids volume So i have sphere with radius $R$, and inside there is a  4 sided regualar pyramid with $a$ and $h$ as it's data. 
So now i have to find $a and h$ such  that volume $V=\frac{1}{3} a^2h$ will maximized.
So because the base is a square and 2R is the diagonal i came to this:
$$2R=a\sqrt{2}$$
$$ a=\sqrt{2}R$$
hence: 
$$V(h)=\frac{1}{3}2R^2 h$$
So i managed to get the volume as a fucntion of $h$
I could use multivariable functions as well, i know, but this one is suppose to be solved using only the one variable functions.
Did i do it correctly though, since if i calculate its derivative, it doesn't have a zero.
So i probably did something wrong? Is it okay to use this: $2R=a\sqrt{2}$.
Thank you for any help. 
 A: You have to write R as a function of h.
V(h)=2/3 * R(h)^2 * h

Where R(h)^2 + (1-h)^2= 1
A: You didn't specify that the pyramid base must be on the equator of the sphere so you cannot use $2R=a\sqrt{2}$.
The image in general looks like this (the notation is different):

Source: https://www.mathalino.com/reviewer/differential-calculus/66-67-maxima-and-minima-pyramid-inscribed-in-a-sphere-and-indian-tepe
Rotate the pyramid so that the base is horizontal and the apex is at the North pole. The distance from the center of the sphere to the center of the pyramid's base is $h - R$ (distance from the apex to the center of the base minus the distance from the apex to the center of the sphere, they lie on the same line).
Since $a$ is the side length of the square base, the distance from the base center to one of the vertices on the base is $\frac{a\sqrt{2}}{2}$. On the other hand, the distance from the center of the sphere to the same vertex is of course $R$, because the vertex lies on the sphere. Now, using the Pythagorean theorem, we get:
$$\frac{a^2}{2} = \left(\frac{a\sqrt{2}}{2}\right)^2 = R^2 - (h - R)^2 = 2hR - h^2$$
Plug $a^2$ in the volume formula:
$$V = \frac{1}{3}a^2h = \frac{2}{3}h^2(2R-h)=\frac{4}{3}h^2R - \frac{2}{3}h^3$$
So $V(h) = \frac{4}{3}h^2R - \frac{2}{3}h^3$ and the derivative is $V'(h) = \frac{8}{3}hR - 2h^2$. Equating this with $0$ we get the optimal $h$:
$$h_{max} = \frac{4}{3}R$$
The second derivative is $V''(h) = -4h + \frac{8}{3}R$. From $V''(h_{max}) < 0$ we see that $V(h_{max})$ will really be the maximum.
From here we can calculate $a$ and $V$:
$$a_{max} = \sqrt{4Rh_{max}-2{h_{max}}^2}=\frac{4}{3}R$$
$$V_{max} = \frac{1}{3}{a_{max}}^2h_{max} = \frac{64}{81}R^3$$
