https://math.stackexchange.com/a/398282/1257548
In this answer it is said that $f:S→\mathbb{R}, (x,y,z)↦y$ is Morse function but I don't see why.
As far as I understand, because function is defined on manifold $S = \{(x,y,z):z^4+(x^2+y^2-1)(2x^2+3y^2-1)=0\}$ then using implicit function theorem we have that $$\frac{dy}{dz} = -\frac{4z^3}{12y^3+10x^2y-8y}$$ and $$\frac{dy}{dx} = -\frac{8x^3+10xy^2-6x}{12y^3+10x^2y-8y}$$ so $$\frac{d^2y}{dz^2}(x,y,0)=0, \frac{d^2y}{dx^2}(0,y,0)=a,\frac{d^2y}{dxdz}(x,y,0)=0.$$ So Hessian of $f$ is degenerated in $(0,−1,0),(0,−\frac{1}{\sqrt{3}},0),(0,\frac{1}{\sqrt{3}},0),(0,1,0)$ thus it can't be Morse function. Even differentiating $f$ like $\frac{df}{dy}=1$ and $\frac{d^2f}{dy^2}=0$ shows that it's also degenerated. I don't know if I don't understand something or if the answer is wrong.
I know that taking the height function as Morse function works on torus and I see that taking $f(x,y,z)=y$ on S should work the same but I don't know why it doesn't work (or if I'm just doing something wrong). And if the function is wrong is it possible to correct it to proper Morse function?
It helps to look at the picture in the linked answer, looking near $(0, -1, 0)$. You can see that $y$ grows very slowly as a function of either $x$ or $z$ (or even along the direction $x = z$). In fact, looking just in the plane $x = 0$, we have $$ 0 = z^4 + (y^2-1) (3y^2 - 1) $$ At the point $y = -1$, this looks like \begin{align} 0 &= z^4 + (y+1)(y-1)(3y^2 - 1)\\ 0 &\approx z^4 + (y- (-1))(-2)(2)\\ &= z^4 + 4y+4 \end{align} so it's approximately the curve $$ y = (z^4 - 4)/4 $$
The idea of a Morse function is that when you approximate like this, it's supposed to look like a quadratic in the remaining two coordinates. Indeed, if we take the best quadratic approximation to this curve, it's just $$ y = -1 $$ The same general idea applies in any other direction, too, and we see that the best quadratic approximation to this surface near $(0, -1, 0)$ is in fact the plane $y = -1 + 0x + 0z$...which has a Hessian that doesn't tell us anything about the shape.
So your analysis is correct --- it looks as if the other answerer was a little bit too glib.
On the other hand, it does look as if perhaps $y^2-1$ might be a good morse-function near that point ... but then you'd have a problem near $y = 0$.
Anyhow, it sure looks to me as if your conclusion here is correct and this isn't really a a good Morse-theory analysis. Too bad.