# Vensim Help

 Preventing Division by Zero
 Ø Add the variable maximum price to the sketch near target price.
 Ø Draw and arrow from maximum price to target price.
 Ø Select the Equation edit tool and click on target price and enter the new equation:
 target price=MIN(
 XIDZ(target revenue, expected demand, maximum price),
 maximum price)

Units: \$/Box

 Ø Add the equation for maximum price.

maximum price=25000

Units: \$/Box

The XIDZ function performs division except when that division would be by 0 (actually a number smaller than 1.0E-6 in magnitude) in which case it returns the third argument.  In other words

XIDZ(target revenue, expected demand, maximum price)

is the same as

target revenue/expected demand

except when the expected demand is 0.  In this case the first returns maximum price and the second causes an error.

The XIDZ function is very useful when you suspect that variables could legitimately take on 0 value and you still want simulations to continue.  A closely related function is ZIDZ which returns 0 when dividing by 0.