No, that's not it.
SG is a function of P. One example of such a function is the ASBC equation.
What you do is put this function P(SG) in the denominator instead of an SG value, and so you are left with only one variable P on both sides of the equation.
I think the problem you must be trying to solve is, in effect:
I have put 126 grams of sucrose into a volumetric flask and made up to 1 L without measuring the amount of water I added. How much water did I add? From the answer to that question we can trivially compute °P, SG and density, the partial molar volume of sucrose at that concentration etc.
I think this must be the problem because the equation you posted solves that problem
P(SG) = 100*M/(V*SG*.998203)
Multiplying both sides by SG gives
SG*P(SG) = M/(0.998293*V)
and we then have to solve the 4th order equation in SG
SG*P(SG) -M/(0.998293*V) = 0
If I plug in my huge inverse ASBC equation above for P(SG) function, I probably won't be able to express P explicitly. So there comes the root finder.
There are closed form solutions for 4th order equations but here a root finder or Newtons method is much easier to implement. For the 100 grams in a 1000 mL solution.
0.126 Extract Mass
1 Volume
1.05 trial SG
0.38434652 trialFunction
-367.6201786 Slope
-0.001045499 Correction
1.048954501 New trial
0.110834741 New Trial Function
-367.4250912 Slope
-0.000301653 Correction
1.048652848 New trial
0.031930129 New Trial Function
-367.3687939 Slope
-8.69157E-05 Correction
1.048565933 New trial
0.00919606 New Trial Function
-367.3525721 Slope
-2.50333E-05 Correction
1.048540899 New trial
0.002648301 New Trial Function
-367.3478999 Slope
-7.20924E-06 Correction
1.04853369 New trial
-6.87555E-06 New Trial Function
12.03914164 °P
1.046649475 Mass of Solution
0.920641862 Mass of Water
8.62% Volume Expansion
The function is
(((135.997*SG - 630.272)*SG + 1111.14)*SG - 616.868)*SG-100*Mass/(0.998203*Vol)
and we want to drive that to 0. The slope is
((3*135.997*SG-2*630.272)*SG+1111.14)*SG-616.868
So the Newton method solution isn't bad though as the problem is now less linear it takes more iterations to get the function down to 5E-5 though note that the SG solution changes in decimal places beyond the 3rd after the 3rd iteration.
Is this what you had in mind?
Does this mean you assume your efficiency = 7/8 = 87.5%?
It's really moot as the numbers are for illustration only but I had intended to mean that rather than 80% extract you might get 10% less than that or 70% - 7 kg extract per 10 kg malt.
Now to the example. I know my grain absorption is 1.2 L/kg.
I don't have any deadspace.
So I get 40-1.2*10=28 L in the first drain.
Then I batch sparge with 10 more L of water.
That leaves me with 38 L of wort (of what mass?) with 7 kg of extract pre-boil?
Keep in mind that if you add 1 liter of water to a wort the volume of the wort will not change by 1 L but by something close to that because the sugar expands the volume of the liquid. In the example above we added 126 grams of extract to 920 grams of water and got 1 L of 12 °P solution. The volume of the water expanded by 8.62%. It is this volume expansion that makes things difficult.
That's the way I was calculating it, but now I'm questioning if I could add volumes like this.
What you can do is make adjustments to get a particular volume in the kettle. You can make up the kettle to 38 L if you want to and, if you know that this 38L really contains 7 kg extract calculate that the wort would be 17.22 P and that it contains 33.6 kg of water.
I instinctively went with kg of extract and post-boil volume as my variables.
It's really much easier to think in terms of mass. I even put load cells under my kettle. If I have 400 lbs wort at 12 °P I imediateley know I have 48 lbs extract and can quickly figure my efficiency by dividing that by the weight of the grain I mashed. You can, clearly, work in terms of volume too if you set the volume. However, as soon as you ask the question 'How strong is a sugar solution with x grams of sugar per liter you have to solve the 4th order equation.