Goal Seek Function

I am looking to create an addition to my grasshopper code, where I introduce the goal seek function, similar to that of the goal seek function within Excel.

At present I have a slider which I manually adjust to achieve my desired goal, but would like to automate this process.

To simplify my problem:

Input A = random number - Linked to slider
Input B = Equation driven function calculated from variables within my main grasshopper code, as well as the Input A.

I then compute A-B. I know I have the correct value of A, when the calculation = 0.

I would be grateful for any guidance on this issue.

I worked on this problem some years ago:

Developed further here:

And fully polished here as a “Z-offset Solver” using Anemone:
http://www.islandcad.com/grasshopper/hydrostatics/

Hi Joseph,

This worked perfectly for my application. Thanks