# Is it possible to find this z value working backwards after a matrix multiplication?

I multiply a 4 x 4 matrix by a 4 component vector, and I'm trying to find the value of the z component working backwards. The following picture is just to show you what I'm talking about.

After doing this multiplication then z is divided by w, which as you can see always ends up being negative z. Before multiplying the w component is ALWAYS 1.

The final result I get we'll call "d". Now I try to write an equation which shows this, and I get:

Then I simplify this to:

I would like to know if this is solvable for z. Every time I try I end up getting something like z over z on one side. I'm not good at math at all, this is my attempt:

First simplify a little:

Multiply both sides by "f - n"

There are many different different ways I've tried it, in one case I got a solution which was:

But it didn't work out. I mean the image didn't display the correct depth value. I'd appreciate any help.

The correct solution is $$z = {2fn \over \color{red}{(f-n)d-(f+n)}}.$$ Whatever error you’re making occurs after the last step that you showed. Unfortunately, you don’t show any of your work after that, so I can only guess at what that mistake might have been. Perhaps you made a simple sign error. Anyway, starting from where you left off, a correct solution might proceed as follows: \begin{align} -(f-n)dz &= -(f+n)z - 2fn \\ (f-n)dz-(f+n)z &= 2fn \\ \left((f-n)d -(f+n)\right) z &= 2fn \\ z &= {2fn \over (f-n)d-(f+n)} . \end{align} To check this solution, substitute this expression for the original $z$-coordinate of the point, apply the projection and simplify. You should end up with $d$.