Minerr(var1, var2, ...) Returns the values
of var1, var2... that satisfy the equations and inequalities
in a Solve Block. Minerr differs from
Find or Minimize
in that, if the chosen algorithm fails
to converge, whatever answer found on the last allowable iteration will be returned,
even if it doesn't meet the convergence criteria. If you are solving for n
variables, the solve block must have at least n equations.
Matrix notation is allowed, as is solving for matrix variables.
Arguments:
var1, var2,... are scalar or array variables
found in the system of equations. Guess values for each variable to be found
must be defined above the Given
keyword. If solutions are expected to be complex, complex guess values must
be used.
Notes:
The universal notes on constructing solve blocks
apply. Within the body of the block:
Equations: Equations must be defined using Boolean
equals. No definitions are allowed within the body of a solve block.
Constraints: Inequality constraints, using Boolean operators,
are allowed.
Form of Equations: If you are using the Levenberg-Marquardt method
from the right-click menu and are solving a residuals minimization problem,
express your equations as the vector of residuals set equal to zero, rather
than summing and squaring the error.
Output of the Minerr function may be assigned to a single variable,
a vector of explicit variable names, or a function of other variable names
within the solve block, therefore parameterizing the solve block. See the
QuickSheet example. If the variables have different units, they may only be
assigned to an explicit vector of names to avoid mixed units in matrices.
When there is one unknown scalar variable, the solution is a scalar. Otherwise
the solution is a vector where the first element is var1,
the second element is var2, and so on. You cannot
solve for a single element of a vector used in the block. All vector values
will be adjusted simultaneously to minimize the error.
TOL and CTOL can affect the solution to nonlinear
systems. Setting these values too small may cause the solver to not converge.
If adjusting these parameters does not help, try different guess values, or
add an inequality constraint.
You can use Minerr in those cases where Find fails to converge.
If you use Minerr in a solve block, you should always include additional
checks on the reasonableness of the results. The built-in variable ERR returns
the size of the error vector for the approximate solution returned by Minerr.
There is no built-in variable for determining the size of the error for individual
solutions to the unknowns.
You can also use Minimize
to solve this type of problem, but the equation(s) is placed outside the solve
block, and treated as the objective function, rather than as a constraint.
This may result in different answers using the same solver method. Reduce
TOL to get equivalent performance from the Minimize function.