To understand how to proceed you have to dispense with the formula and look at the derivation of the tangent portfolio from first principles. The multiobjective model is
$$\begin{array}{ll}
\text{maximize} & (\bar{R}^T x + R_f x_f, - \tfrac{1}{2} x^T V x) \\
\text{subject to} & \vec{1}^T x + x_f = 1
\end{array}$$
The zero risk solution is of course $x_f=1$, and the maximum return solution is $x_i=1$ where $i=\textrm{argmax}_i \bar{R}_i$. To examine the rest of the tradeoff curve we
scalarize the model with $\gamma^{-1}\in(0,+\infty)$ as the weight of the risk term. (The reason we use the reciprocal will become clear later.)
$$\begin{array}{ll}
\text{maximize} & \bar{R}^T x + R_f x_f - \tfrac{1}{2} \gamma^{-1} x^T V x \\
\text{subject to} & \vec{1}^T x + x_f = 1
\end{array}$$
The Lagrangian is
$$L(x,x_f,\lambda) = -\bar{R}^T x - R_f x_f + \tfrac{1}{2} \gamma^{-1} x^T V x - \lambda ( \vec{1}^T x + x_f -1 )$$
The optimality conditions are
$$-\bar{R} + \gamma^{-1} V x - \lambda \vec{1} = 0 \quad - R_f - \lambda = 0 \quad \vec{1}^T x + x_f = 1$$
Eliminating $\lambda$ and solving for $x$ yields
$$x = \gamma V^{-1} ( \bar{R} - R_f \vec{1} ) \quad x_f = 1 - \vec{1}^T x.$$
The tangent portfolio is found by finding the value of $\gamma$ for which $x_f=0$: $$\gamma=\left(\vec{1}^TV^{-1}(\bar{R}-R_f\vec{1})\right)^{-1}.$$
This coincides with the solution you have offered in your post.
Now that the general principle is illuminated, we can apply it to the model with a short sale restriction. The zero risk and maximum return solutions are identical, so we immediately return to the scalarized model with a nonnegativity constraint added:
$$\begin{array}{ll}
\text{maximize} & \bar{R}^T x + R_f x_f - \tfrac{1}{2} \gamma^{-1} x^T V x \\
\text{subject to} & \vec{1}^T x + x_f = 1 \\
& x \succeq 0
\end{array}$$
The Lagrangian is
$$L(x,x_f,\lambda,z) = -\bar{R}^T x - R_f x_f + \tfrac{1}{2} \gamma^{-1} x^T V x - \lambda ( \vec{1}^T x + x_f -1 ) - z^T x$$
where $z \geq 0$. The optimality conditions are
$$-\bar{R} + \gamma^{-1} V x - \lambda \vec{1} - z = 0 \quad - R_f - \lambda = 0 \quad \vec{1}^T x + x_f = 1 \quad z \geq 0$$
Eliminating $\lambda$ and $z$ yields
$$V x \geq \gamma(\bar{R} - R_f\vec{1}) \quad \quad \vec{1}^T x + x_f = 1$$
Unfortunately, even for fixed $\gamma>0$, it is not likely that there is an analytic solution for $x$ and $x_f$ (unless, say, $V$ is diagonal).
To determine the tangent portfolio, we need the value of $\gamma$ for which $x_f=0$. It also cannot be determined analytically, but it can be determined computationally.
\begin{array}{ll}
\text{maximize} & \gamma \\
\text{subject to} & V x \geq \gamma ( \bar{R} - R_f \vec{1} ) \\
& x \geq 0, ~ \gamma \geq 0 \\
& \vec{1}^T x = 1
\end{array}
The efficient frontier with a risk-free asset and a short sale restriction is no longer a straight line; I believe it is piecewise linear. So calling this a "tangent" portfolio may be a bit misleading. But it is still the portfolio found at the point where the tradeoff curves with and without the risk-free asset touch.
It is not necessarily the case that this new portfolio is strictly positive in all assets. I do not believe you can offer an a priori condition that ensures they will be.
first form the covariance matrix, $C,$ its entries are found from the standard deviations and correlations.
Let $e = (1,1,\dots,1).$ In this case, $(1,1,1).$
Solve $Cy = e.$
Normalize the elements of $y$ so they add to $1.$
Done.
(for discussion of why this is the minimal variance portfolio, see Joshi--Paterson, Introduction to Mathematical Portfolio Theory.)
Best Answer
Let A and B be the two assets. From the Covariance Matrix, you get
$\sigma_A^2 = 2$, $\sigma_B^2 = 2$ $Cov(A,B) = 1$
Expected Excess Returns, $R_A = 7$, $R_B = 4$
Let A and B be have weights $w_A$, $w_B$ in the portfolio.
Now Variance of the Portfolio $Var(P) = w_A^2\sigma_A^2+w_B^2\sigma_B^2+2w_Aw_BCov(A,B)$
$\sigma_P = \sqrt{Var(P)}$
$R_P = w_{A}R_A + w_{B}R_B$
$$Sharpe Ratio= \frac{R_P}{\sigma_P}$$
USing the above information set up a solver to find $w_A$ and $w_B$. The below image illustrates and find the optimal solution that will maximize sharpe ratio.