-
Notifications
You must be signed in to change notification settings - Fork 0
/
sage_cell.html
76 lines (76 loc) · 10.3 KB
/
sage_cell.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html>
<!--**************************************-->
<!--* Generated from MathBook XML source *-->
<!--* on 2016-03-05T09:10:50-05:00 *-->
<!--* *-->
<!--* http://mathbook.pugetsound.edu *-->
<!--* *-->
<!--**************************************-->
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>UML-MBX Sage Cell Calculations</title><meta name="Keywords" content="Authored in MathBook XML"></meta><meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"></meta><script xmlns:b64="https://github.com/ilyakharlamov/xslt_base64" type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [['\\(','\\)']],
},
TeX: {
extensions: ["AMSmath.js", "AMSsymbols.js", "extpfeil.js", "autobold.js", "https://aimath.org/mathbook/mathjaxknowl.js", ],
equationNumbers: { autoNumber: "none",
useLabelIds: true,
// JS comment, XML CDATA protect XHTML quality of file
// if removed in XSL, use entities
//<![CDATA[
formatID: function (n) {return String(n).replace(/[:'"<>&]/g,"")},
//]]>
},
TagSide: "right",
TagIndent: ".8em",
},
"HTML-CSS": {
scale: 88,
},
});
</script><script xmlns:b64="https://github.com/ilyakharlamov/xslt_base64" type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML-full"></script><script xmlns:b64="https://github.com/ilyakharlamov/xslt_base64" type="text/javascript" src="https://sagecell.sagemath.org/static/jquery.min.js"></script><script xmlns:b64="https://github.com/ilyakharlamov/xslt_base64" type="text/javascript" src="https://sagecell.sagemath.org/embedded_sagecell.js"></script><script xmlns:b64="https://github.com/ilyakharlamov/xslt_base64">
$(function () {
// Make *any* div with class 'sage-compute' an executable Sage cell
sagecell.makeSagecell({inputLocation: 'div.sage-compute',
linked: true,
evalButtonText: 'Evaluate'});
});
$(function () {
// Make *any* div with class 'sage-display' a visible, uneditable Sage cell
sagecell.makeSagecell({inputLocation: 'div.sage-display',
editor: 'codemirror-readonly',
hide: ['evalButton', 'editorToggle', 'language']});
});
</script><script xmlns:b64="https://github.com/ilyakharlamov/xslt_base64" type="text/javascript" src="https://code.jquery.com/jquery-latest.min.js"></script><link xmlns:b64="https://github.com/ilyakharlamov/xslt_base64" href="https://aimath.org/knowlstyle.css" rel="stylesheet" type="text/css"></link><script xmlns:b64="https://github.com/ilyakharlamov/xslt_base64" type="text/javascript" src="https://aimath.org/knowl.js"></script><script xmlns:b64="https://github.com/ilyakharlamov/xslt_base64" src="https://aimath.org/mathbook/js/lib/jquery.sticky.js"></script><script xmlns:b64="https://github.com/ilyakharlamov/xslt_base64" src="https://aimath.org/mathbook/js/lib/jquery.espy.min.js"></script><script xmlns:b64="https://github.com/ilyakharlamov/xslt_base64" src="https://aimath.org/mathbook/js/Mathbook.js"></script><link xmlns:b64="https://github.com/ilyakharlamov/xslt_base64" href="https://fonts.googleapis.com/css?family=Open+Sans:400,400italic,600,600italic|Source+Code+Pro:400" rel="stylesheet" type="text/css"></link><link xmlns:b64="https://github.com/ilyakharlamov/xslt_base64" href="https://aimath.org/mathbook/stylesheets/mathbook-3.css" rel="stylesheet" type="text/css"></link><link xmlns:b64="https://github.com/ilyakharlamov/xslt_base64" href="https://aimath.org/mathbook/mathbook-add-on.css" rel="stylesheet" type="text/css"></link></head><body class="mathbook-book has-toc has-sidebar-left"><div xmlns:b64="https://github.com/ilyakharlamov/xslt_base64" style="display:none;">\(\newcommand{\identity}{\mathrm{id}}
\newcommand{\notdivide}{{\not{\mid}}}
\newcommand{\notsubset}{\not\subset}
\newcommand{\lcm}{\operatorname{lcm}}
\newcommand{\gf}{\operatorname{GF}}
\newcommand{\inn}{\operatorname{Inn}}
\newcommand{\aut}{\operatorname{Aut}}
\newcommand{\Hom}{\operatorname{Hom}}
\newcommand{\cis}{\operatorname{cis}}
\newcommand{\chr}{\operatorname{char}}
\newcommand{\Null}{\operatorname{Null}}
\newcommand{\lt}{ < }
\newcommand{\gt}{ > }
\newcommand{\amp}{ & }\)</div><header id="masthead"><div class="banner"><div class="container"><a id="logo-link" href="http://faculty.uml.edu/klevasseur/uml-mbx/" target="_blank"><img src="http://faculty.uml.edu/klevasseur/images/small_umllogo.gif"></img></a><div class="title-container"><h1 class="heading"><span class="title">UMass Lowell Mathbook XML</span><span class="subtitle">a guide to creating open source STEM materials.</span></h1><p class="byline">Ken Levasseur</p></div></div></div><nav xmlns:b64="https://github.com/ilyakharlamov/xslt_base64" id="primary-navbar"><div class="container"><div class="navbar-top-buttons"><button class="sidebar-left-toggle-button button active">Contents</button><div class="tree-nav toolbar toolbar-divisor-3"><a class="previous-button toolbar-item button" href="chapter-4.html">Previous</a><a class="up-button button toolbar-item" href="chapter-4.html">Up</a><a class="next-button button toolbar-item" href="sageplot.html">Next</a></div><button class="sidebar-right-toggle-button button active">Annotations</button></div><div class="navbar-bottom-buttons toolbar toolbar-divisor-4"><button class="sidebar-left-toggle-button button toolbar-item active">Contents</button><a class="previous-button toolbar-item button" href="chapter-4.html">Previous</a><a class="up-button button toolbar-item" href="chapter-4.html">Up</a><a class="next-button button toolbar-item" href="sageplot.html">Next</a></div></div></nav></header><div class="page"><aside xmlns:b64="https://github.com/ilyakharlamov/xslt_base64" id="sidebar-left" class="sidebar"><div class="sidebar-content"><nav id="toc"><h2 class="link"><a href="index.html"><span class="title">Front Matter</span></a></h2><ul><li><a href="colophon-1.html">Colophon</a></li><li><a href="acknowledgement-1.html">Acknowledgements</a></li><li><a href="preface-1.html">Preface</a></li></ul><h2 class="link"><a href="overview.html"><span class="codenumber">1</span><span class="title">Overview</span></a></h2><ul><li><a href="mbx-structure.html">Structure of an MBX book</a></li><li><a href="html-conversion.html">The Conversion Process to html</a></li><li><a href="latex-conversion.html">The Conversion Process to LaTeX</a></li></ul><h2 class="link"><a href="chapter-2.html"><span class="codenumber">2</span><span class="title">LaTeX</span></a></h2><ul><li><a href="latex.html">LaTeX</a></li></ul><h2 class="link"><a href="features.html"><span class="codenumber">3</span><span class="title">MBX Features</span></a></h2><ul><li><a href="definition-xref-exercise.html">Definitions, referencing, and exercises</a></li><li><a href="theorem.html">Theorems</a></li></ul><h2 class="link active"><a href="chapter-4.html"><span class="codenumber">4</span><span class="title">Sage</span></a></h2><ul><li><a href="sage_cell.html" class="active">Sage Cell Calculations</a></li><li><a href="sageplot.html">Using sageplot to create images</a></li></ul><h2 class="link"><a href="backmatter.html"><span class="title">Reference</span></a></h2><ul><li><a href="chapter-5.html">Hints and Solutions to Selected Exercises</a></li><li><a href="chapter-6.html">Notation</a></li><li><a href="chapter-7.html">Lists of Elements</a></li></ul></nav><div class="extras"><nav><a class="mathbook-link" href="https://mathbook.pugetsound.edu">Authored in MathBook XML</a><a href="https://www.mathjax.org"><img title="Powered by MathJax" src="https://cdn.mathjax.org/mathjax/badge/badge.gif" border="0" alt="Powered by MathJax"></img></a></nav></div></div></aside><main class="main"><div id="content" class="mathbook-content"><section xmlns:b64="https://github.com/ilyakharlamov/xslt_base64" class="section" id="sage_cell"><header><h1 class="heading" alt="Section 4.1 Sage Cell Calculations" title="Section 4.1 Sage Cell Calculations"><span class="type">Section</span><span class="codenumber">4.1</span><span class="title">Sage Cell Calculations</span><a href="sage_cell.html" class="permalink">¶ permalink</a></h1></header><p>Sage cells are easily inserted into the text with a \(\texttt{sage}\) tag. Within that tag, Sage code is placed within an \(\texttt{input}\). Within the \(\texttt{input}\) tag, line breaks and indentation is maintained. The appeal to these cells is that the reader can edit default text to experiment with the concept that is being introduced.</p><p>Here is basic calculation from Chapter 2. It is part of the text, but using an XML id on the paragraph that it is contained in, a link to this cell can be inserted at exercises where similar calculations would need to be done.</p><div class="sage-compute"><script type="text/x-sage">binomial(52,13)*binomial(39,13)*binomial(26,13)
</script></div><p>Here is a graphic that appears in Chapter 1 of Applied Discrete Structures. Graphics calculations like this can be inserted into source code and through a Python script, the appropriate type of image can be created. For example, svg files are ideally created for html conversion. See <a href="sageplot.html" alt="Section 4.2 Using sageplot to create images" title="Section 4.2 Using sageplot to create images">Section 4.2</a> for more on the conversion process.</p><div class="sage-compute"><script type="text/x-sage">m=2
scale = 1.7
sx=3
sy=2
centers = [(cos(n*2*pi/m), sin(n*2*pi/m)) for n in range(m)]
clr = ['blue', 'blue', 'green']
G = Graphics()
r=lambda x,y:(x-centers[0][0])^2+(y-centers[0][1])^2 < scale^2 or (x-centers[1][0])^2+(y-centers[1][1])^2 < scale^2
G+=region_plot(r,(-sx,sx),(-sy,sy),plot_points=200,incol='lightblue',axes=False)
for i in range(m):
G += circle(centers[i], scale)
for i in range(m):
G += circle(centers[i], scale)
G+=line([[-sx,-sy],[sx,-sy],[sx,sy],[-sx,sy],[-sx,-sy]],rgbcolor=(0,0,0))
G+=text('B',centers[0],fontsize='x-large')
G+=text('A',centers[1],fontsize='x-large')
G.show()
</script></div></section></div></main></div></body></html>