When vibrating a string, how exactly is the vibration inverted to create an identical wave traveling in the opposite direction? I am currently trying to understand standing waves. The key to the phenomenon is that:
$$A\sin(kx+\omega t) + A\sin(kx-\omega t)=2A\sin(kx)\cos(\omega t)$$
The shape of $2A\sin(kx)\cos(\omega t)$ is constant, as only the amplitude changes with time due to the $\cos(\omega t)$. This creates the familiar "standing wave", as the shape remains the same while the amplitude goes up and down, occasionally hitting $0$. The following post also explains that the wavelength is not actually required to fit $L/0.5n$ to form a standing wave: That is only a requirement if the amplitude on both ends of the string has to be $0$. In most string setups, the ends are fixed though, so practically speaking this is a requirement.
Suppose that I have a string of length $L$ with fixed ends, and that I have somehow managed to make a perfect sin-wave on one side of the string. This wave is traveling to the other side of the string:

As most articles and videos have described it, when a wave hits the end, it will both change direction, and flip/be inversed. But I have great difficulty seeing how this ends up creating an identical wave with identical phase to the first one. There is also a great deal of ambiguity in how one is supposed to visualize this flip and reverse action:

*

*Is the whole wave flipped at once, or is it flipped "gradually" as each point of it hits the end?

*Does the wave move while it's in the action of being inverted? If so, wouldn't that mean that a lot of parts of it never hit the end, and are thus never reflected properly?

*Does the standing wave phenomena only occur because new waves are constantly created on one end. Is it these waves that the original waves form interference with, or does the wave form interference with "itself"?

The problem isn't that I don't get how the initial wave is created on a string instrument:
I get that when plucking a string instrument, a triangle shape is created, and that this shape can be described as a sum of harmonic frequencies of varying amplitudes. The problem is that I don't really get the geometry of this whole inversion process, and how it forms two identical waves.
 A: The boundary condition imposed is:
\begin{equation}
\psi(x=0)=\psi(x=L)=0
\end{equation}
The right side of the wave arrives at $\psi(x=L)$, in the next steps of the time the wave will start to reflect keeping the condition $\psi(x=L)=0$.
Why the wave reflects when arrives at $\psi(x=L)=0$?
Because doing $\psi(x=L)=0$ is like folding the x-axis in $x=L$.

*

*You keep the condition $\psi(x=L)=0$, and the wave continue travelling, but in this case, with the x-axis folded the wave continue travelling backwards.


*The resultant wave during the reflection is the sum of the reflected wave and the wave that continue arriving at $x=L$.


*When the wave finishes its reflection you have all the wave travelling with velocity $-v$. That is coherent with what we did, that is folding the x-axis:
$\psi(x-vt)$ $\longrightarrow$ is a wave travelling forward.
$\psi(-x-vt)$ $\longrightarrow$  is a wave travelling forward with the x-axis folded.
$(-1)\cdot\psi((-1)\cdot(-x-vt))$ $\longrightarrow$  is a wave travelling with the x-axis folded.
$(-1)\cdot\psi(x+vt))$ $\longrightarrow$  is a wave travelling with velocity $-v$.
As you can see $\psi(x-vt)=(-1)\cdot\psi(x+vt))$ is why the backward travelling wave is inverted.
A: Propagation of waves is described by the wave equation $$\frac{d^2u}{dx^2}=\frac{1}{c^2}\frac{d^2u}{dt^2}.$$
But on its own this is not enough: we also need boundary conditions. You are describing what's called fixed boundary conditions or Dirichlet boundary conditions. This amounts to setting $u(x,t)$ to a fixed value on the boundary. It turns out in 1D this is quite easy; in 1D you can always decompose a solution to the wave equation in a left- and right travelling part
$$u(x,t)=u_R(x-vt)+u_L(x+vt).$$
Now let's say we want to impose $u=0$ at $x=0$. In that case we get
\begin{align}
u(0,t)=0&\implies u_R(-vt)=-u_L(+vt)\\
&\implies u_R(-z)=-u_L(z)
\end{align}
where I used $z$ to remind you that $u_R,u_L$ are just functions of one variable. So we can conclude $u_R,u_L$ have the same shape, but they are reflected in the y-axis (one is upside down) and reflected in the x-axis (they are mirrored around $x=0$). So as a recap because we set $u$ to some fixed value at a particular $x$ the left- and right travelling solutions are mirror images of eachother: the reflected wave is minus the incoming wave. To see this in action look at the following animation.

Here the green line shows the actual solution $u$: it is a sum of the blue and red lines which are the right- and left travelling solutions. The blue and red lines are extended past the domain to make it more clear what is happening. Notice how blue and red work together to keep the boundary point of green at a fixed height.

Edit in response to Michael. I saved the code to make this gif so here's a version with a wave that has no symmetry at all

A: Let me offer an entirely intuitive understanding, based on Newton's law of action and reaction.  Pay attention to what happens when the wave, as depicted in the answer by Accidental Taylor Expansion, first strikes the rightmost RIGID support.  Because of the shape of the wave, having the string ABOVE the neutral position of the support, the wave wants to pull up on the support; i.e., it imparts a force upwards to the support.  But the support is immovable, and thus MUST impart a reaction force DOWNWARD on the string EXACTLY equal to force the string imparts on it. That reaction force is now propagated leftward, EXACTLY as an original force on the left side of the string imparted a rightward moving wave.  That's all you need to know and you can reason thusly for any portion of the wave.
