It looks like I may not be using this invest script correctly. I guess I don't get it.

I copied the formulas from the Black Book and made a Python script and got different results so it looks like your instincts were probably correct.

With the new code I got 13612.27 as the new slider value.

I'll paste the output and attach the code and let you be the judge.

Capital: 14000
Profit: 3000
C
14000.0
P
3000.0
W
0

Balance_on_the_account
17000.0

Minimum_amount_in_the_account
15427.248620541512

Available_for_removal
1572.7513794584884

Available_for_reinvesting
15427.248620541512

Withdraw Amount: 2000
Actual Payout
2000.0

Account_after_profit
15000.0

Growth_factor
1.2142857142857142

f
1.1019463300386794

Account_minimum
15427.248620541512

Maximum_payout
-427.2486205415116

Investment After Payout of $2000.0
13612.278194595452



Code
import math

C = float(input("Capital: "))
P = float(input("Profit: "))
W = 0
f=math.sqrt(1+(P/C))

print('C')
print(C)

print('P')
print(P)

print('W')
print(W)

Balance_on_the_account= C + P - W 
Minimum_amount_in_the_account= C * f 
Available_for_removal= C + P - W - C * f 
Available_for_reinvesting= C * f - W/f 
print()
#print(f)
print('Balance_on_the_account')
print(Balance_on_the_account)
print()
print('Minimum_amount_in_the_account')
print(Minimum_amount_in_the_account)
print()
print('Available_for_removal')
print(Available_for_removal)
print()
print('Available_for_reinvesting')
print(Available_for_reinvesting)
print()

W = float(input("Withdraw Amount: "))

#Previous_margin =  0.5 * OptimalF * $10000 
Account_after_profit =  C + P-W  # $13,000 
Growth_factor =  1+P/C # 1.3, 
f=math.sqrt(Growth_factor)
#its_square_root f  # 1.14 
Account_minimum =  C * f # $10,000 * 1.14 # $11,400 
Maximum_payout =  C + P-W-C * f # $13,000-$11,400 # $1600

print("Actual Payout")
print(W)
print()
print('Account_after_profit' )
print(Account_after_profit )
print()
print('Growth_factor' )
print(Growth_factor )
print()
print('f')
print(f)
print()
#print(#its_square_root f  # 1.14 )
print('Account_minimum' )
print(Account_minimum )
print()
print('Maximum_payout' )
print(Maximum_payout )
print()
Investment_after_Payout = C * f - W/f
print("Investment After Payout of $" + str(W))
print(Investment_after_Payout)