How to Solve Systems of Equations Through Solve Blocks in PTC Mathcad




Solve blocks are a PTC Mathcad construct that lets you solve any number of equations and unknown variables.

The function Find returns a solution to a system of equations given by a solve block. You can use Find to solve a linear system or nonlinear systems.

How to Use PTC Mathcad Prime Solve Blocks

1. Insert a Solve Block from the Math tab and add two guess values. Note that the Guess Values label moves to bracket that section. The algorithm for Find starts at these values and moves toward a solution.The solve block box allows you to reposition the solve block on the page, without worrying about losing any of the pieces. Definitions inside the solve block are local to the solve block.

solveblocks_1 

Mathcad's Solve Block

2. Next add your constraints. You must have the same number of constraints as variables you are solving. You do not need the word Given, unlike earlier versions of PTC Mathcad.

3. For the equals sign, use the Boolean Equals operator, Ctrl+=Note: The entries of the solution vector correspond to the variables in the same order that the variables appear after Find. Type in Find(y, x) to return the entries in reverse order. Evaluate the left-hand sides of the system with the found results to confirm that the solution is correct.

solveblocks_2 


solveblocks_3

4. All of the data has been entered

Multiple Solutions

Take a look at the solve block below.

solveblocks_4 

Now, one as an example.

The first equation represents an ellipse, while the second represents a straight line. These are plotted below, along with the solution point.

solveblocks_1 

The same block, presented graphically.

As the graph shows, the solution corresponds to the point in the first quadrant where the curve and the line intersect. However, there is another solution to the system, corresponding to the point of intersection in the second quadrant. How can you get Find to return this second solution?

Change the Guess Value

Changing the guess values reveals other solutions. Keep in mind that the result returned by the function Find (as well as by the functions Minerr, Minimize, and Maximize) is directly related to the guess values for the unknown variables, and at most one solution is returned for a given set of guess values.

So changing the guess values might lead to a different solution.

Looking at the graph above, you can see that the second solution lies in the second quadrant. So it seems reasonable to try guess values corresponding to a point – the guess point – that also lies in the second quadrant. Try the guess point (-3, 3).

solveblocks_6 

The solver finds the same answer as the graphical solution.

This time Find returns the second solution.

Usually, if you choose a guess point close to a solution, Find returns that solution. However, as with the root function, Find does not always return the solution that is closest to the given guess point.

You can see the relationship between guess points and their corresponding solutions graphically by defining a function that takes a guess point to the resulting solution.

For any guess point (x, y), the function Pt(x,y) returns one of the two solutions. For example:Now, see what happens when you apply the Pt function to 25 guess points, equally spaced on a circle of radius 4 with center at the origin. Draw a line from each guess point to the solution produced by the Pt function for that guess. The resulting plot is quite interesting. By changing the guess point, you can find both possible solutions.

solveblocks_7 

Notice that most guess points in the right half-plane (x > 0) lead to the solution (4,3). However, some points in the right half-plane lead to the solution (-3.71, 0.657)Try changing R to 6 in the example above to see what happens when the guess points lie on a circle of radius 6.

Find uses the Levenberg-Marquardt method, a very stable routine that is tolerant of poor guesses.

What these examples show is that choosing guess values is actually a guessing game. A picture can help you identify the guess points that return the solutions you are looking for.

There’s lots more to learn about solve blocks, but this should get you going. Part two of this article will discuss what to do when the solve block does not find a solution.

>> Visit the Mathcad Community website for the PTC Mathcad Prime 3.1 and Mathcad 15.0 worksheets.

Why Not Try Our Latest Version, PTC Mathcad Prime 3.1? Download our Free for life version.