Plots > XY Plots > Plotting Functions > Example: Plotting Inequalities and Piecewise Functions
  
Example: Plotting Inequalities and Piecewise Functions
Use plots to visualize inequalities and piecewise functions.
Inequalities
1. In an empty plot, enter an inequality in the y-axis expression and the corresponding independent variable in the x-axis expression.
Click to copy this expression
* 
Since the inequality is a Boolean expression, PTC Mathcad plots both the values of r that are true (>2.5) and the values of r that are false (<2.5). The inequality is equal to 1 when it is true, and 0 when it is false.
2. Use the AND operator to add a second inequality to the first one.
Click to copy this expression
Piecewise Functions
A function that is not uniform over its domain is called a piecewise function. To plot a piecewise function you need to use the built-in conditional function if.
1. Define a function and plot it over a specific range.
Click to copy this expression
Click to copy this expression
Click to copy this expression
2. Define and plot a piecewise function that is equal to f(x) only when f(x) > 0.
Click to copy this expression
Click to copy this expression
3. Use the AND operator to define the range of x over which f(x) is plotted as such. For other values of x, plot the negative of function f.
Click to copy this expression
Click to copy this expression