Plotting Linear Inequalities

Description

Here we will graph the inequality

(1)
\begin{align} y \leq 1 - x^2 \end{align}

Sage doesn't have a specific function to plot an inequality, so instead we will be plotting $y = 1 - x^2$ and shading all points that violate the inequality. To shade, we will set the fill, fillcolor and fillalpha parameters. fill fills from the y-value specified to the curve, fillcolor sets the color being used to fill and fillalpha sets how transparent the fill will be. We will also set ymin and ymax, otherwise Sage will plot from y = 10 to the local minima.

Sage Cell

Code

plot(1 - x^2, (x, -2, 2), gridlines='minor', ymin=-2, ymax=2, fill=10, fillcolor='yellow', fillalpha=2/3)

Options

Filling under the curve

We can fill under the curve by setting fill to a y-value below the curve instead of above. We will use -10 instead of 10.

Code

plot(1 - x^2, (x, -2, 2), gridlines='minor', ymin=-2, ymax=2, fill=-10, fillcolor='yellow', fillalpha=2/3)

Tags

Primary Tags:

Secondary Tags:

A list of possible tags can be found at The WeBWorK Open Problem Library. For linear algebra tags see the Curated Courses Project.

Related Cells

Any related cells go here. Provide a link to the page containing the information about the cell.

Attribute

Permalink:

Author: Gregory V. Bard. Sage for Undergraduates. American Mathematical Society, Providence, RI, 2015. Available at http://www.gregorybard.com/Sage.html.

Date: 02 Mar 2019 21:20

Submitted by: Zane Corbiere

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License