Skip to content

Navigation Menu

Sign up

Custom SageMath Functionality

Drew Lewis edited this page Mar 6, 2025 · 13 revisions

Authors can use the custom TBIL SageMath module in either SagePlots:

<image>
 <sageplot>
<xi:include parse="text" href="../../../common/sagemath/library.sage"/>
# code goes here, fully flush left (the above line needs to also be fully flushed left)
 </sageplot>
</image>

and in CheckIt generators:

# at top of file
load("../../../source/common/sagemath/library.sage")

See below for various options, along with their defaults if not provided. (If this page gets stale, see the code at https://github.com/TeamBasedInquiryLearning/library/blob/main/source/common/sagemath/library.sage for the most up-to-date versions.)

plot_angle

TBIL.plot_angle(
 angle, # in radians, multiply degrees by pi/180
 reference_angle=0,
 show_axes=True,
 show_unit_circle=False,
 show_unit_point=False,
 show_angle_value=False
)

plot_angle() is a function useful for plotting diagrams showing angles around the unit circle. It takes one mandatory argument, the angle, and other arguments can be set to True to provide various decorations.

TBIL.plot_angle(pi/3,show_unit_circle=True)

image

numberline_plot

TBIL.numberline_plot(
 center=0,
 radius=10
)

Generates a numberline. You can specify the center as well as the radius.

TBIL.numberline_plot(center=5,radius=15)

image

inequality_plot

TBIL.inequality_plot(
 start=None, 
 strict_start=True, 
 end=None, 
 strict_end=True,
 label_endpoints=True,
 scale=10
)

Generates decorations for a numberline_plot to represent inequalities. To have endpoints at infinity, you can omit the start or end parameters. The scale parameter should match the radius of a numberline_plot; both default to 10. You can add multiple of these to a plot if you need several intervals.

p=TBIL.numberline_plot(radius=15)
p+=TBIL.inequality_plot(start=-10,strict_start=True,end=-6,strict_end=False,label_endpoints=False,scale=15) 
p+=TBIL.inequality_plot(start=8,strict_start=False,label_endpoints=False,scale=15)
p.axes(False)

image

intervals_from_inequality

TBIL.intervals_from_inequality(
 inequality,
 partition_points,
 undefined_points=None,
 checkpoints=None
)

This is a helper function, primarily used in Checkit, to generate a list of intervals where an inequality is true. The returned list of strings is suitably formatted to use with TBIL.numberline_from_intervals(). You should supply a list of partition_points, between which it is assumed that the truth value of the inequality is constant between. If the inequality is undefined at any point, those should be supplied as well. The function determines if an inequality is true on an interval by evaluating at the points in checkpoints; if these are not supplied, these are either the midpoint (of a finite interval) or for infinite intervals one more or less than the finite endpoint.

numberline_from_intervals

TBIL.numberline_from_intervals(
 intervals
)

This can be combined with intervals_from_inequality() to generate a numberline plot of where the inequality is true.

TBIL.numberline_from_intervals(TBIL.intervals_from_inequality(x^2-4*x-5>0,partition_points=[-1,5]))

image

small_rationals

def small_rationals(
 numerators=range(-8,9), 
 denominators=None, # defaults to [2,3,5]
 dictionary=True,
 length=1
)
 '''Generates a list or dictionary of unique rational numbers with small numerators and denominators. 
 For a dictionary, keys are the rationals and values are the denominators.'''

small_irrationals

TBIL.small_irrationals(
 rational_part=range(-8,9), 
 irrational_part=None,
 denominators=None,
 dictionary=True,
 length=1,
 full_list=False
)

small_complex

line_from_points

line_from_point_slope

config_matrix_typesetting

RowOp

SetBuilder

BracedSet

VectorSet

VectorList

LinearCombination

Equation

VectorEquation

choices_from_list

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /