Task 1–1: Linear System of Equations
Read the problem defined below, and then find the solution using the following methods:
• Matrix calculation
• Solver
• Solve block
Problem Definition
The following functions are linear functions:
They intersect as shown in the following plot:
You want to find the coordinates of the crossing point (x, y) where the following equations hold true:
The equations can be rearranged so that the variables are on the left side of the equations:
The equations can be rewritten in terms of vectors and matrices:
Each vector and matrix in the equation above can be represented by a variable:
The arrays M and v are known, but X is unknown. X is a 2-element vector representing the x and y coordinates of the crossing point.
Solving with Matrix Calculation
1. Define the matrix M and the vector v.
2. Define X as the product of the inverse of matrix M and vector v.
3. Evaluate X.
The x value of the crossing point is 5.714 and the y value is -0.714.
Solving with a Solver
Solvers are functions for solving specific problems. You can use the lsolve built-in function to find the coordinates of the crossing point.
1. Define matrix M and vector v.
2. Call the lsolve function.
Solving with a Solve Block
A solve block is an area in which you define your problem using natural notation. You do not need to rearrange the equations as you did for matrix calculation and for the solver. Recall the linear functions y1 and y2:
The following solve block uses the find function to calculate the crossing point of the two functions:
Where:
1. Guess value for each unknown
2. Constraint for each unknown
3. Solve block function
1. To find the coordinates of the crossing point using a solve block, start by defining the two functions y1 and y2 in your worksheet.
2. To insert a solve block region, on the Math tab, in the Regions group, click Solve Block.
To resize a solve block region, you can drag one of its three square handles. When you move a solve block in your worksheet, all the regions in the solve block move with it.
3. In the solve block region, type guess values for your problem. PTC Mathcad uses the guess values as the starting point for finding the solution.
4. Type the constraints that limit the problem. You must use the Boolean operators when you define constraints. Insert the Boolean equal to operator.
The first constraint defines the value of x at the crossing point, and the second constraint defines the value of y at that point.
5. Insert the solve block function name and arguments. Here, type find, and then type x and y as the function arguments. The label of find is automatically set to keyword.
6. Evaluate the solve block.