Beruflich Dokumente
Kultur Dokumente
Note When you specify the optional arguments a and b for the root function, Mathcad only finds a
root for the function f if f(a) is positive and f(b) is negative or vice versa. (See Figure 9-1.)
If, after many approximations, Mathcad still cannot find an acceptable answer, it marks
the root function with an error message indicating its inability to converge to a result.
To find the cause of the error, try plotting the expression. A plot helps to determine
whether or not the expression crosses the x-axis and if so, approximately where. In
general, the closer your initial guess is to where the expression crosses the x-axis, the
more quickly the root function converges on an acceptable result.
Online Help
For more details and issues on finding roots see Finding Roots in online Help.
The root function can solve only one equation in one unknown. To solve several
equations simultaneously, use Find or Minerr described in Solve Block Functions
on page 99.
Finding All Roots
Use the lsolve function to solve a linear system of equations whose coefficients are
arranged in a matrix M. The argument M for lsolve must be a matrix that is neither
singular nor nearly singular. An alternative to lsolve is to solve a linear system by using
matrix inversion.
Solve Blocks
The general form for using system solving functions in Mathcad is within the body of
a solve block. There are four steps to creating a solve block:
1. Provide an initial guess for each of the unknowns. Mathcad solves equations by
making iterative calculations. The initial guesses give Mathcad a place to start
searching for solutions. If you expect your solutions to be complex, provide
complex guess values.
2. Type the word Given in a separate math region below the guess definitions, in
order to set up a system of constraint equations. Be sure you dont type Given in a
text region.
3. Now enter the constraints (equalities and inequalities) in any order below the word
Given. Make sure you use the Boolean equal symbol (
on the Boolean toolbar
or press [Ctrl] [=]) for any equality. You can separate the left and right sides of
an inequality with any of the symbols <, >, , and .
4. Enter any equation that involves one of the functions Find, Maximize, Minimize, or
Minerr below the constraints.
Tip
Solve blocks cannot be nested inside each other each solve block can have only one Given
and one Find (or Maximize, Minimize, or Minerr). You can, however, define a function like
f(x) := Find(x) at the end of one solve block and refer to this function in another solve block.
Solve Block Functions
Figure 9-2 shows a solve block with several kinds of constraints and ending with a call
to the Find function. There are two unknowns. As a result, the Find function takes two
arguments, x and y, and returns a vector with two elements.
Guess Values
Results
Check
Figure 9-2: A solve block with both equalities and inequalities. The equations
for a circle and line are entered, then the inequality constraints are set. Find
looks for the points of intersection, which are checked back in the original
equations. See the QuickSheet Solve Blocks with Inequality Constraints.
Note Unlike most Mathcad functions, the solving functions Find, Maximize, Minerr, and Minimize
can be entered in math regions with either an initial lowercase or an initial capital letter.
Solve blocks can be used to solve parametric systems. In Figure 9-3, the solution is cast
in terms of several parameters in the solve block besides the unknown variable.
Same problem,
solved for a vector
of answers...
Solve blocks can also take matrices as unknowns and solve matrix equations. (See
Figure 9-4 and Figure 9-5.)
Two methods for computing a matrix square root (nonunique)
Using eigenanalysis:
Figure 9-4: A solve block for computing the square root of a matrix.
Note You can improve the solve block result in Figure 9-4, and those of many other sensitive
Figure 9-5: A solve block for computing the solution of a matrix equation
using the Riccati Equation from control theory.
The table below lists the constraints that can appear in a solve block between the
keyword Given and the functions Find, Maximize, Minerr, and Minimize. x and y
Boolean
Toolbar
Constraint
w = z
Equal
x<y
Less than
x>y
Greater than
xy
xy
Not
xy
And
xy
Or
xy
Mathcad does not allow the following between Given and Find in a solve block:
Constraints with .
to a set of equations. To find a different solution, try different guess values or enter an additional
inequality constraint that the current solution does not satisfy.
Tolerances for Solving
Constraint tolerance. This parameter, the built-in variable CTOL, controls how
closely a constraint must be met for a solution to be acceptable. For example, if the
constraint tolerance were 0.0001, a constraint such as x < 2 would be considered
satisfied if, in fact, the value of x satisfied x < 2.0001.
Procedures for modifying the values of these tolerances are described in Built-in
Variables on page 75.
Online Help
For more information on solving issues see Find, Minerr and Solver Problems in online
Help.
Linear. Applies a linear programming algorithm to the problem. Guess values for
the unknowns are not required.
Nonlinear. Applies either a conjugate gradient, Levenberg-Marquardt, or quasiNewton solving routine to the problem. Guess values for all unknowns must precede
the solve block. Choose Nonlinear > Advanced Options from the menu to control
settings for the conjugate gradient and quasi-Newton solvers.
Note When solving overdetermined systems, such as regression problems, the Levenberg-Marquardt
method performs best if given a vector of residual values set to zero, rather than a single sumof-squared errors objective function.