The problem is as follows: Let $X$ be a curve of degree $d$ embedded into $\mathbf{P}^2$ with $r$ nodes. Show that the number of inflection points of $X$ is $6(g-1)+3d$ (nodes do not count as inflection points).
To answer this, I will use three pieces of data: first is the degree formula for singular curves. I should have $g_X=\frac{1}{2}(d-1)(d-2)-r$.
Second, I will use the fact that if we define a map $X \mapsto L$ by $x \mapsto T_x(X) \cap L$ for some $\mathbb{P}^1$ named $L$ (where $L$ is chosen not tangent to X in $\mathbb{P}^2$), this morphism has degree $d(d-1)$. Moreover, this map is ramified if and only if $x$ is an inflection point or $x$ lies on $L$.
Lastly I will use the Hurwitz theorem: given a map $f: X \rightarrow Y$ of curves, $2g_X-2=d_f(2g_Y-2)+deg(R)$, where $d_f$ is the degree of $f$ and $R$ is the ramification divisor on $X$.
Putting all of this together (i.e. writing down the Hurwitz theorem when $f: X \rightarrow L$ is of degree $d(d-1))$ leaves me with $d^2-3d-2r=-2d(d-1)+deg(R)$, or $3d^2-5d-2r=deg(R)$. Subtracting off $d$ from both sides (so as to not count the ramification points where $L$ intersects $X$) I get $3d^2-6d-2r$.
This is close to what is written: using the degree-genus formula again I would expect $6(g-1)+3d$ to be equal to $3d^2-6d-6r$. How do I account for the difference in these two answers?
There are two mistakes here: computing the degree of $\varphi$ (denoting the map $P \mapsto T_PX \cap L$) and applying Hurwitz' theorem to the wrong maps. Both of these stem from treating the singular projection like a smooth curve.
To fix some notation, let $X \subset \mathbb{P}^2$ the nodal curve obtained from projecting the smooth curve $\tilde{X}$ to $X$. Now, as you stated correctly, the genus of $\tilde{X}$ is $\frac{1}{2} (d - 1)(d - 2) - r$ since we have to take into account the $r$ nodes.
I am also struggling with working out the details of this exercise. In particular, the exercise seems to rely on this key assumption which I have not yet justified:
Now that we have this, it makes sense to apply the solution to the previous exercise which identifies ramification points of $\varphi$ with $\{P \in X \;|\;P \text{ is an inflection point or } P \in X \cap L\}$. Similarly if we fix a sufficiently general $O \in \mathbb{P}^2 - X$, we can project from $O$ to get a morphism $X \to \mathbb{P}^1$ of degree $d$, and hence one $\tilde{X} \to \mathbb{P}^1$ of degree $d$. Using this assumption again, we see that the ramification points of this map correspond to the distinct tangent lines of $X$ passing through $O$. (see exercise IV.2.2(c)) The degree of the corresponding ramification divisor is easily seen to be the degree of $\varphi$.
We can then use Riemann-Hurwitz to compute this to be $$\deg R = 2d + 2g(\tilde{X}) - 2 = 2d + (d - 1)(d - 2) - 2r = d(d - 1) - 2r.$$
Now that we know $\deg(\varphi) = d(d - 1) - 2r$, we apply Hurwitz to the first map $\varphi: \tilde{X} \to L$. We subtract $d$ to disregard the points of $X \cap L$.
\begin{align*} \deg R - d &= 2(d(d - 1) - 2r) + (d - 1)(d - 2) - 4r - 2 - d\\ &=3d^2 - 6d - 6r \end{align*}
which is what we needed.