Getting Started Tutorial > Task 3–4: Defining and Evaluating Functions
  
Task 3–4: Defining and Evaluating Functions
Evaluating Built-In Functions and Disabling Math Regions
1. To name a variable θ, type q and then press Ctrl+G. To assign a value to θ, insert the definition operator and then type 67. On the Math tab, in the Units group, click Unit. The Unit list opens. Under the Angle category, click ° (Degree).
* 
Another way to insert degrees is to type deg after 67. When you evaluate degrees, the result is returned in radians:
2. Evaluate the built-in sine function for this angle. For a list of built-in functions, on the Functions tab, in the Functions group, click All Functions.
3. Select the math region. On the Calculation tab, in the Controls group, click Disable Region. The disabled math region is dimmed.
4. Change the angle definition to π/6. The disabled region is not recalculated to account for the change in the angle.
5. Select the disabled region, and then click Disable Region to toggle the control. The result is recalculated.
You can disable any region to freeze its result at a point in time. When you disable a variable definition, other regions that use this variable return an error until you reactivate the variable definition.
Defining New Functions and Checking Units
You can generalize a math expressions by assigning it to a function. You first define the function and its arguments, and then evaluate it at specific points.
1. Insert a function name and the list of its arguments.
2. Insert the definition operator and then type the following expression:
In this function, cm denotes centimeters, and x and y are the arguments of function f. You can define one function in terms of another function as long as their arguments match. Here, the argument of sin is x, and x is also an argument of function f.
3. Evaluate function f at x=π/2 and y=2kg.
An error is returned. PTC Mathcad performed unit checking on the function and found that the units of x and y are not compatible with the function definition (x must be an angle and y must be a length).
4. Evaluate function f at x=π/5and y=3in.
The result is returned in meters because the default unit system is the SI system. To change unit system, on the Math tab, in the Units group, select a new system from the Unit System list.
Practice
Before moving on to the next exercise, calculate the area of a triangle:
The general formula for the area of a triangle is 1/2 ∙ a ∙ b ∙ sin(θ), where a and b are the length of two of the sides of the triangle, and θ is the angle between these sides. Define a 3-argument function for calculating the area of triangles.
A triangle has two sides of 5mm and 1.5cm, and the angle between them is 32°. Define these variables. Make sure you type in all the units, including the degree for the angle.
Evaluate the function for this triangle and check that its area is 0.199cm2. Initially, the result is returned in m2, so you must convert the units to cm2.
Proceed to Exercise 4.