Taking volume contraction into account when mixing water with ethanol To calculate the amount of purified water and the amount of ethanol (96% Vol.) which is needed for a desired/variable amount of a mixture - given a desired/variable percentage of ethanol - I use the following formula:

$$W = \left(\frac{T * P}{ 100}\right) \times \frac{1}{0.96}$$

and

$$E = T -  W$$

Where $T$ is the desired Total amount of product (in liters); $P$ is the desired Percentage of ethanol in the final product (in %Vol.); $W$ is the calculated amount of Water (in liters) and $E$ is the calculated amount of Ethanol (in liters containing 96 %Vol ethanol).

For example - using this formula - when I need $\pu{40 liters}$ product containing 50% vol. ethanol, the calculated amounts of water and ethanol for the mixture become $19.1667 : 20.833$. 

The problem in the above calculation is that because of volume contraction the desired total amount of the final product will be less as given in the formula. To me, the problem became even more confusing after I learned that volume contraction depends on the mixing ratio of both components in a nonlinear way. 

What changes should I made to the formula to take volume contraction into account?
Measuring out volumes can sometimes be easier than dealing with mass, but in this case, converting the calculations to mass-centric can make the process easier. (I'll use your symbols, but they will now be in mass units (kg). If you desire percentages of ethanol by volume, you still need to convert to mass units because of the volume contraction!))

First, calculate the total mass  in kg of the volume of solution needed; divide the volume by the density of the specific ethanol-water solution. You can look up this density in a handbook or Google it. One simple table is at https://www.engineeringtoolbox.com/ethanol-water-mixture-density-d_2162.html, although many tables are available, even to tenths of a percent.

Second, calculate the mass of 96% ethanol needed:  = (∗/100)×1/0.96. The ratio / will be higher than , the % desired, because the ethanol is only 96%. Convert this to volume in liters, if you desire, by dividing by 0.80138, the density of 96% ethanol.

Third, calculate the amount of pure water needed:  =  − .   / will be less than 100 -   because of the 4% water already in the ethanol. But the total mass will give you the volume required, and the % ethanol will be correct - BY MASS. 

Commercial isopropanol solutions are frequently sold as 70% by volume; this calculates out to 64.7% by weight. Your procedure, if you desire to make variable % solutions BY VOLUME, will need to do a calculation before you even do the first step: convert the % ethanol by volume to % ethanol by mass.