FIND ZERO(xs,z,zs,xi,n,skip,tol,max iter,method)†
FIND the value of x that makes z ZERO
|Top Previous Next|
Returns a vector of values that make z zero.
The FIND ZERO function is used to solve nonlinear simultaneous algebraic equations. It is designed to be used in situations where the SIMULTANEOUS function will not work. FIND ZERO solves for the value of the vector x that will make z zero (where x is the variable on the left hand side of the equation). It can only be used with subscripted variables.
NOTE The FIND ZERO function actually takes over the control of the last subscript loop. Because of this the variable on the left hand side of the equation (x) can be thought of as a hidden argument to the function. If you want to use this function with variables having more than one subscript the function will operate on only the final subscript.
xs is a scaling vector for x. After multiplying x by this vector all of the values of then product should be of the order of magnitude of 1. xs must be a vector of the same length as x and will often be a vector of ones.
z is the vector of values that should be set to zero by the appropriate selection of x. If the functional form being solved is y = f(y) then z would be set to y - f(y) in another equation. z must be a vector of the same length as x.
zs is a scaling vector for z. After multiplying z by this vector the results should all be of the order of magnitude of 1. zs must be a vector of the same length as x and will often be a vector of ones.
xi is the initial set of values that x will start with in the search for the solution. Depending on the problem, a good initial guess can be essential for finding a solution. xi must be a vector of the same length as x. In some cases a vector of ones will suffice.
n is the number of vector elements in the vectors. This is almost always ELMCOUNT(z), though a smaller number can be used if appropriate. Note that skip should be used to mark systems that are homogeneous of degree 0, you should not decrease the value of n.
skip specifies how many elements of the vector should be skipped in solving x. For systems of equations that are homogenous of degree 0, this should be set to 1 to skip the first element, or -1 to skip the last element. If it is zero, no elements will be skipped. There may be situations were other values could be used. All elements of x will be initialized using xi whether they are to be skipped in the active computation of x or not.
tol specifies the tolerance that must be achieved in zeroing z. If this is set too small numerical problems may prevent it from being reached. In general .001 is probably a reasonable choice.
max iter specifies the maximum number of iterations that will be taken before failure will be declared. A value of 100 is reasonable for this. More frequently failure will result when it is not possible to get closer to 0 within an iteration.
method determines the method that will be used to find the zero.
0 Indicates the use of a Broydn search.
1 is the same as zero except that the initial search value is reset each time. This can sometimes help when there are convergence problems though it will, in general, slow simulation down considerably.
Any other value will be treated the same as a 1.
Restrictions: The FIND ZERO function must appear first on the right hand side and not be followed by anything else. There can be no simultaneous loop enclosed within the loop from x to z (put another way, given x it must be possible to compute the value of z in a simple chain).
Subscript Note: The FIND ZERO function is designed to work with a vector of values but will also work with scalar values.
x = FIND ZERO(one,z,one,one,1,0,0.01,100,0)
z = (x-target)^2
one = 1
Solution to the above FIND ZERO usage will result in x being set equal to target.
commod : c1,c2,c3
ones[commod] = 1
price[commod] = FIND ZERO(ones[commod],excess demand[commod],
excess demand[commod] = demand[commod] - supply[commod]
supply[commod] = price[commod]
demand[commod] = 100 - price[commod]
Solution to the above will result in a price of 50 for each commodity.
Availability: Professional and DSS only.