Authoring Interactive Sage Worksheets
Total Page:16
File Type:pdf, Size:1020Kb
Authoring Interactive Sage Worksheets Rob Beezer [email protected] Department of Mathematics and Computer Science University of Puget Sound Sage Days 15 University of Washington May 16, 2009 Write about using mathematics, and relevant Sage Write about mathematics, with a little help from Sage Read about using Sage, with Sage present Read about using mathematics, with Sage present Read about Sage and mathematics, and take notes (=TinyMCE) (I won't talk much about this, but it should be obvious) Convert a Sage worksheet into a high-quality publishable print format (Thursday night's idea) Goals Write about using Sage, and relevant mathematics Rob Beezer (U Puget Sound) Authoring Interactive Sage Worksheets Sage Days 15 May 16, 2009 2 / 15 Write about mathematics, with a little help from Sage Read about using Sage, with Sage present Read about using mathematics, with Sage present Read about Sage and mathematics, and take notes (=TinyMCE) (I won't talk much about this, but it should be obvious) Convert a Sage worksheet into a high-quality publishable print format (Thursday night's idea) Goals Write about using Sage, and relevant mathematics Write about using mathematics, and relevant Sage Rob Beezer (U Puget Sound) Authoring Interactive Sage Worksheets Sage Days 15 May 16, 2009 2 / 15 Read about using Sage, with Sage present Read about using mathematics, with Sage present Read about Sage and mathematics, and take notes (=TinyMCE) (I won't talk much about this, but it should be obvious) Convert a Sage worksheet into a high-quality publishable print format (Thursday night's idea) Goals Write about using Sage, and relevant mathematics Write about using mathematics, and relevant Sage Write about mathematics, with a little help from Sage Rob Beezer (U Puget Sound) Authoring Interactive Sage Worksheets Sage Days 15 May 16, 2009 2 / 15 Read about using mathematics, with Sage present Read about Sage and mathematics, and take notes (=TinyMCE) (I won't talk much about this, but it should be obvious) Convert a Sage worksheet into a high-quality publishable print format (Thursday night's idea) Goals Write about using Sage, and relevant mathematics Write about using mathematics, and relevant Sage Write about mathematics, with a little help from Sage Read about using Sage, with Sage present Rob Beezer (U Puget Sound) Authoring Interactive Sage Worksheets Sage Days 15 May 16, 2009 2 / 15 Read about Sage and mathematics, and take notes (=TinyMCE) (I won't talk much about this, but it should be obvious) Convert a Sage worksheet into a high-quality publishable print format (Thursday night's idea) Goals Write about using Sage, and relevant mathematics Write about using mathematics, and relevant Sage Write about mathematics, with a little help from Sage Read about using Sage, with Sage present Read about using mathematics, with Sage present Rob Beezer (U Puget Sound) Authoring Interactive Sage Worksheets Sage Days 15 May 16, 2009 2 / 15 Convert a Sage worksheet into a high-quality publishable print format (Thursday night's idea) Goals Write about using Sage, and relevant mathematics Write about using mathematics, and relevant Sage Write about mathematics, with a little help from Sage Read about using Sage, with Sage present Read about using mathematics, with Sage present Read about Sage and mathematics, and take notes (=TinyMCE) (I won't talk much about this, but it should be obvious) Rob Beezer (U Puget Sound) Authoring Interactive Sage Worksheets Sage Days 15 May 16, 2009 2 / 15 Goals Write about using Sage, and relevant mathematics Write about using mathematics, and relevant Sage Write about mathematics, with a little help from Sage Read about using Sage, with Sage present Read about using mathematics, with Sage present Read about Sage and mathematics, and take notes (=TinyMCE) (I won't talk much about this, but it should be obvious) Convert a Sage worksheet into a high-quality publishable print format (Thursday night's idea) Rob Beezer (U Puget Sound) Authoring Interactive Sage Worksheets Sage Days 15 May 16, 2009 2 / 15 Today's Talk LATEX Dan Drake's SageTeX Eitan Guiari's tex4ht Davide Cervone's jsMath Sage notebook and worksheets Sage @interact framework Taylor Series in the Classroom Rob Beezer (U Puget Sound) Authoring Interactive Sage Worksheets Sage Days 15 May 16, 2009 3 / 15 LATEX Well-known to many mathematicians Sources are long-lived (1980's for me) Widely available, many platforms Many add-on packages A comfortable place to write for many mathematicians, scientists So a low barrier to getting started LaTeX Public Project License (LPPL) Rob Beezer (U Puget Sound) Authoring Interactive Sage Worksheets Sage Days 15 May 16, 2009 4 / 15 SageTeX Designed to allow Sage commands to be placed inline with LATEX Creates latex() and plot() output “on-the-fly” GNU Public License (GPL) Extensions? \sageinline{} small amounts Sage code verbatim (syntax package) \begin{sageverbatim}\end{sageverbatim} environment produces a Sage input cell \begin{sagecell}[output] Sage input, optionally with computed output cell Rob Beezer (U Puget Sound) Authoring Interactive Sage Worksheets Sage Days 15 May 16, 2009 5 / 15 Sample SageTeX Extensions For example the code below will (1) create n s a g e i n l i n e fGg as the symmetric group on five symbols, (2) specify n s a g e i n l i n e f sigma g as an element of n s a g e i n l i n e fGg , ( 3 ) use n s a g e i n l i n e f sigma g as the generator of a cyclic subgroup n s a g e i n l i n e fHg , ( 4 ) l i s t all the elements of n s a g e i n l i n e fHg . I n more mathematical notation , we might write $n l a n g l e ( 1 n , 2 n , 3 ) ( 4 n , 5 ) n rangle=Hn subseteq G=S 5 $ . % n b e g i n f sageverbatim g G = SymmetricGroup(5) sigma = G("(1,2,3)(4,5)") H = G.subgroup([sigma]) H. l i s t ( ) nendf sageverbatim g Rob Beezer (U Puget Sound) Authoring Interactive Sage Worksheets Sage Days 15 May 16, 2009 6 / 15 Sample Input Cell As a workbook As a PDF Rob Beezer (U Puget Sound) Authoring Interactive Sage Worksheets Sage Days 15 May 16, 2009 7 / 15 tex4ht Translator - \TEX for HyperText" NSF funded project Creates HTML, XML/XHTML/MathML, JSMath, OpenOffice, DocBook, Text Encoding Initiative, JavaHelp, speech (!) Two small platform-specific binaries, compiles easily from source Three-pass operation, uses unmodified TEX to create DVI LATEX packages are modified for use, by request (very responsive) Fast and accurate More finicky than TEX, like unmatched (,) in text LaTeX Public Project License (LPPL) Rob Beezer (U Puget Sound) Authoring Interactive Sage Worksheets Sage Days 15 May 16, 2009 8 / 15 jsMath Render a (large) subset of TEX in web browser Relies heavily on Javascript Scalable fonts. Locally, or from a server Well-integrated, tested in notebook Paste tex4ht-generated jsMath into a worksheet as text and it \just works" Apache 2.0 License Rob Beezer (U Puget Sound) Authoring Interactive Sage Worksheets Sage Days 15 May 16, 2009 9 / 15 tex4ht Customization A tex4ht “configuration” file Tags Sage code blocks n Preamble f xhtml ,jsmath , info g n S c r i p t E n v f sageverbatim g fn ifvmode n I g n o r e P a r n f i nEndPnHCodef<sage >gnNoFonts n break g fn ifvmode n I g n o r e P a r n f i nEndPnHCodef</sage >gnEndNoFonts ncsname par nendcsnamenShowParg n b e g i n fdocumentg n EndPreamble Rob Beezer (U Puget Sound) Authoring Interactive Sage Worksheets Sage Days 15 May 16, 2009 10 / 15 Worksheets and @interact Sage's framework for interactive demonstration @interact decorator on a function Function arguments create checkboxes, text input fields, sliders GNU Public License (GPL) Rob Beezer (U Puget Sound) Authoring Interactive Sage Worksheets Sage Days 15 May 16, 2009 11 / 15 Sample Embedded Sage Interact n b e g i n f sageverbatim g %auto @ i n t e r a c t def ( n = i n p u t box(default=12, label = "Cyclic group o f order:", type=Integer) ): cyclic = CyclicPermutationGroup(n) subgroups = cyclic.conjugacy c l a s s e s subgroups() html ( " A l l s u b g r o u p s o f a c y c l i c group o f o r d e r $%s$nn" % latex(n) ) t a b l e = "$nn b e g i n f a r r a y gf l l g" f o r sg i n s u b g r o u p s : table = table + latex(sg.order()) + n " & nn l e f t nn langle" + latex(sg.gens()[0]) + n "nn r i g h t nn r a n g l e nnnn" table = table + "nnendf a r r a y g$" html(table) html ( "nnHint : $%s$ f a c t o r s as $%s$" % ( latex(n), latex(factor(n)) ) ) nendf sageverbatim g Rob Beezer (U Puget Sound) Authoring Interactive Sage Worksheets Sage Days 15 May 16, 2009 12 / 15 Sample Embedded Sage Interact Rob Beezer (U Puget Sound) Authoring Interactive Sage Worksheets Sage Days 15 May 16, 2009 13 / 15 Workflow Process with tex4ht Cut/paste into a worksheet, or automate *.sws creation Wish List Extensions to SageTeX Cross-worksheet links in notebook Putting it All Together \Regular" LATEX for narrative, mathematics, references, sectioning, etc SageTeX for inline Sage code, Sage cells (input/output) do the right thing for print AND for worksheet as targets @interact for interactive functionality Rob Beezer (U Puget Sound) Authoring Interactive Sage Worksheets Sage Days 15 May 16, 2009 14 / 15 Wish List Extensions to SageTeX Cross-worksheet links in notebook Putting it All Together \Regular" LATEX for narrative, mathematics, references, sectioning, etc SageTeX for inline Sage code, Sage cells (input/output) do the right thing for print AND for worksheet as targets @interact for interactive functionality Workflow Process with tex4ht Cut/paste into a worksheet, or automate *.sws creation Rob Beezer (U Puget Sound) Authoring Interactive