├── .gitignore
├── APACHE-2.0.txt
├── README.md
├── RMarkdown
├── README.Rmd
├── basic.Rmd
├── beamer-demo.Rmd
├── html-document.Rmd
├── prettydoc-architect.rmd
├── python3.Rmd
├── readme.bib
└── rticles
│ ├── acm_article
│ ├── Makefile
│ ├── README.md
│ ├── acm_article.Rmd
│ ├── acm_proc_article-sp.cls
│ ├── sensys-abstract.cls
│ └── sigproc.bib
│ ├── acs_article
│ ├── acs_article.Rmd
│ └── acstest.bib
│ ├── aea_article
│ ├── AEA.cls
│ ├── BibFile.bib
│ ├── aea.bst
│ ├── aea_article.Rmd
│ ├── multicol.sty
│ ├── references.bib
│ └── setspace.sty
│ ├── amq_article
│ ├── amq_article.Rmd
│ ├── authorcommands.tex
│ ├── authorpackages.tex
│ ├── mybibliography.tex
│ └── pics
│ │ ├── Figure1.jpg
│ │ └── Figure2.pdf
│ ├── ams_article
│ ├── ams_article.Rmd
│ ├── amstest.bib
│ └── figure01.pdf
│ ├── asa_article
│ ├── agsm.bst
│ ├── asa_article.Rmd
│ └── bibliography.bib
│ ├── ctex.Rmd
│ ├── elsevier_article
│ ├── elsarticle.cls
│ ├── elsevier_article.Rmd
│ ├── mybibfile.bib
│ └── numcompress.sty
│ ├── generate.ipynb
│ ├── ieee_article
│ ├── IEEEtran.bst
│ ├── IEEEtran.cls
│ ├── ieee_article.Rmd
│ └── mybibfile.bib
│ ├── jss_article
│ ├── jss.bst
│ ├── jss.cls
│ ├── jss_article.Rmd
│ └── jsslogo.jpg
│ ├── mdpi_article
│ ├── appendix.tex
│ ├── chicago2.bst
│ ├── logo-ccby.eps
│ ├── logo-mdpi.eps
│ ├── mdpi.bst
│ ├── mdpi.cls
│ ├── mdpi_article.Rmd
│ └── mybibfile.bib
│ ├── mnras_article
│ ├── README.md
│ ├── example.png
│ ├── mnras.cls
│ ├── mnras_article.Rmd
│ └── references.bib
│ ├── peerj_article
│ ├── peerj_article.Rmd
│ ├── sample.bib
│ ├── view.jpg
│ └── wlpeerj.cls
│ ├── plos_article
│ ├── PLOS-submission.eps
│ ├── mybibfile.bib
│ ├── plos.csl
│ └── plos_article.Rmd
│ ├── pnas_article
│ ├── frog.png
│ ├── pnas-new.cls
│ ├── pnas-sample.bib
│ ├── pnas.csl
│ ├── pnas_article.Rmd
│ ├── pnasinvited.sty
│ ├── pnasmathematics.sty
│ ├── pnasresearcharticle.sty
│ └── widetext.sty
│ ├── rjournal_article
│ ├── RJournal.sty
│ ├── RJreferences.bib
│ ├── Rlogo.png
│ ├── preamble.tex
│ └── rjournal_article.Rmd
│ ├── rsos_article
│ ├── OPENSCIENCE.pdf
│ ├── OpenAccesslogo_bw.pdf
│ ├── RS.bst
│ ├── RSOS_Pubs_Logo_Line_CMYK.pdf
│ ├── RS_crossmark_logo.pdf
│ ├── rsos.cls
│ ├── rsos_article.Rmd
│ └── sample.bib
│ ├── rss_article
│ ├── amssym.def
│ ├── amssym.tex
│ ├── bibliography.bib
│ ├── natbib.sty
│ ├── rss.bst
│ ├── rss_article.Rmd
│ └── statsoc.cls
│ ├── sim_article
│ ├── WileyNJD-AMA.bst
│ ├── WileyNJD-v2.cls
│ ├── bibfile.bib
│ └── sim_article.Rmd
│ └── springer_article
│ ├── bibliography.bib
│ ├── spbasic.bst
│ ├── spmpsci.bst
│ ├── spphys.bst
│ ├── springer_article.Rmd
│ ├── svglov3.clo
│ └── svjour3.cls
├── d3
└── d3-tutorial.sagews
├── fortran
├── cylinder.f90
├── run.sh
└── run.term
├── gap
├── gap.sagews
└── gap_directly.sagews
├── go
├── go.pdf
└── go.sagews
├── index.yaml
├── julia
├── batman-demo-300.png
├── julia-first-steps.ipynb
└── julia-logo-325-by-225.png
├── latex
├── .gitignore
├── README.md
├── multiple-files
│ ├── 10-make.tex
│ ├── 20-subfiles.tex
│ ├── 30-komascript.tex
│ ├── 40-sagetex.tex
│ ├── bibliography.bib
│ ├── latexmkrc
│ ├── makefile
│ ├── master.tex
│ └── run-sagetex.py
├── presentation
│ └── presentation.tex
├── pythontex
│ └── pythontex.tex
└── sagetex
│ ├── README.md
│ └── minimal.tex
├── linux
└── Introduction.sagews
├── markdown
├── markdown-in-jupyter.ipynb
├── markdown-in-sage-worksheet.sagews
└── markdown-intro.md
├── ocaml
├── Readme.md
├── compile.term
└── example1.ml
├── octave
├── myfirst.m
├── octave-ipython.ipynb
└── octave-sage.sagews
├── pydata
└── OLSvsRLM.sagews
├── r
├── .gitignore
├── basics.sagews
├── r-plotting.sagews
├── rmagic.ipynb
├── rpy2.sagews
└── rpy2talk
│ ├── rpy2talk.pdf
│ └── rpy2talk.tex
├── sage
├── 2dSphere.sagews
├── 3dplot.sagews
├── MagicCommandsDoc.sagews
├── RiemannSumSampler.sagews
├── SageBeginnerTutorial.sagews
├── SageManifolds
│ ├── SM_AdS.sagews
│ ├── SM_Carter-Penrose_diag.sagews
│ ├── SM_Friedmann_equations.sagews
│ ├── SM_Kerr.sagews
│ ├── SM_Kerr_Newman.sagews
│ ├── SM_Schwarzschild.sagews
│ ├── SM_Simon-Mars_3p1_Kerr.sagews
│ ├── SM_Simon-Mars_3p1_TS2.sagews
│ ├── SM_Simon-Mars_Curzon-Chazy.sagews
│ ├── SM_Tolman-Oppenheimer-Volkoff_equations.sagews
│ ├── SM_Tomimatsu-Sato_3p1.sagews
│ ├── SM_de_Sitter.sagews
│ ├── SM_hyperbolic_plane.sagews
│ ├── SM_projective_plane_RP2.sagews
│ ├── SM_sphere_S2.sagews
│ ├── SM_tensors_modules.sagews
│ └── SM_tutorial.sagews
├── basics.sagews
├── interact
│ ├── Algebra
│ │ └── ideal.sagews
│ ├── Bioinformatics
│ │ └── coalescent.sagews
│ ├── Calculus
│ │ ├── contourMap.sagews
│ │ ├── deltaEpsilon.sagews
│ │ ├── differentialApprox2Var.sagews
│ │ ├── graph3DPointCurve.sagews
│ │ ├── latSurfaceArea.sagews
│ │ ├── midpointTwoVar.sagews
│ │ ├── multivarLimit.sagews
│ │ ├── newtonMethod.sagews
│ │ ├── numericalIntegral.sagews
│ │ ├── parametricSurfaceArea.sagews
│ │ ├── polarCurve.sagews
│ │ ├── quadricSurface.sagews
│ │ ├── symbolicFunction.sagews
│ │ ├── taylorApprox2Var.sagews
│ │ └── volumeNonRectangDomain.sagews
│ ├── DiffEq
│ │ ├── diffEqBoundary.sagews
│ │ ├── eulerBaroque.sagews
│ │ ├── eulerMarayumaBrownian.sagews
│ │ ├── eulerVectorField.sagews
│ │ ├── heatFourier.sagews
│ │ ├── picardIter.sagews
│ │ └── rungaKuttaFehlberg.sagews
│ ├── DynamicalSystems
│ │ └── cobweb.sagews
│ ├── Fractals
│ │ ├── digitSetDilationMatrix.sagews
│ │ ├── juliaVariableExp.sagews
│ │ ├── mandelbrotBinomDistrib.sagews
│ │ ├── mandlebrotVariableExp.sagews
│ │ ├── sierpinskiTri.sagews
│ │ ├── twinDragon.sagews
│ │ └── twinDragon3D.sagews
│ ├── Games
│ │ ├── nim.sagews
│ │ ├── queens.sagews
│ │ └── zeros.sagews
│ ├── Geometry
│ │ ├── banchoffPohl.sagews
│ │ ├── croftonFormula.sagews
│ │ ├── evolutes.sagews
│ │ ├── geodesicsParamSurf.sagews
│ │ └── tetReflect.sagews
│ ├── Graph
│ │ ├── automorphism.sagews
│ │ └── graphMinor.sagews
│ ├── Graphics
│ │ ├── 3DParametricPlot.sagews
│ │ ├── interactive2DPlot.sagews
│ │ ├── interactive3DPlot.sagews
│ │ ├── interactiveMatPlotLib.sagews
│ │ ├── paintEgg.sagews
│ │ ├── plotColor.sagews
│ │ ├── plt.png
│ │ ├── pursuitCurve.sagews
│ │ ├── rotateRayTrace.sagews
│ │ └── spirograph.sagews
│ ├── LinearAlgebra
│ │ ├── determTranspose.sagews
│ │ ├── discreteFourier.sagews
│ │ ├── gerschgorinCircle.sagews
│ │ ├── linearTransform.sagews
│ │ └── sVD.sagews
│ ├── LoopQuantumGravity
│ │ ├── holomorphicFactorQuantTetra.sagews
│ │ ├── quantumTetAreaEig.sagews
│ │ └── quantumTetNumbers.sagews
│ ├── Miscellaneous
│ │ ├── beatFreq.sagews
│ │ ├── cellularAutomata.sagews
│ │ ├── interactiveVenn.sagews
│ │ ├── karplusStrong.sagews
│ │ ├── minkowskiSum.sagews
│ │ ├── snippetProfile.sagews
│ │ └── unreadable.sagews
│ ├── NumberTheory
│ │ ├── Cryptography
│ │ │ └── cryptography.sagews
│ │ ├── IntegerFactorization
│ │ │ ├── divisibilityPoset.sagews
│ │ │ └── factorTrees.sagews
│ │ ├── ModularForms
│ │ │ ├── charpodyHecke.sagews
│ │ │ ├── computeCuspidalSubgroup.sagews
│ │ │ ├── computeModForm.sagews
│ │ │ ├── ellipticCurve.sagews
│ │ │ └── ellipticCurveFinite.sagews
│ │ ├── Other
│ │ │ ├── computeBernoulli.sagews
│ │ │ ├── fundDomainSL2.sagews
│ │ │ └── plotContinueFrac.sagews
│ │ └── PrimeNumbers
│ │ │ ├── primeNumbrThrm.sagews
│ │ │ └── primeSpiralPolar.sagews
│ ├── Statistics
│ │ ├── dishonestCasino.sagews
│ │ └── randomWalk.sagews
│ ├── Topology
│ │ └── winding.sagews
│ └── WebApp
│ │ └── pieChart.sagews
├── interactive.sagews
├── pi.sagews
├── xkcd.sagews
├── yoda.sagews
└── yodapose.mat
├── sagews-jupyter
├── bash.sagews
├── jupyter-python3.sagews
├── r-completion.png
├── r.sagews
├── sage.png
└── simpleLoop.wav
├── sympy
├── sympy-code.sagews
└── sympy-intro.sagews
├── thumbs
├── latex-beamer-in-cocalc.png
├── latex-multiple-documents.png
├── markdown-in-cocalc.png
├── pythontex.png
├── r-in-cocalc.png
├── rmd.png
├── sage-in-cocalc.png
└── sagetex-in-cocalc.png
├── web-app-worksheet
├── app.css
├── app.html
├── app.js
└── app.sagews
└── webservice
├── Readme.md
├── main.py
└── run.term
/.gitignore:
--------------------------------------------------------------------------------
1 | index.js
2 | octave/octave-workspace
3 | cmdline.term
4 | sage-plots-for*.tex
5 | *.sout
6 | *.scmd
7 | *.sage-backup
8 | *.synctex.gz
9 | .bashrc
10 | fortran/cylinder
11 | *.bak
12 | .bup/
13 | .cache/
14 | .forever/
15 | .gitconfig
16 | .sage/
17 | .sagemathcloud/
18 | .ssh/
19 | *.term
20 | *~
21 | \.*
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | CoCalc Templates
2 | ================
3 |
4 | [](https://cocalc.com/github/sagemathinc/cocalc-example-files)
5 |
6 | This is a collection of some templates for worksheets or scripts
7 | in [CoCalc](https://cocalc.com).
8 |
9 | Just clone them into your working directory via
10 |
11 | 1. Open the [+ New] tab,
12 | 1. Enter `https://github.com/sagemathinc/cocalc-example-files.git` in the text box,
13 | 1. Then click on `Download from Internet` to download and clone the entire project.
14 |
15 | Go back to `Files`, open the `cocalc-example-files` directory and you are ready to start exploring CoCalc!
16 |
17 | Authors
18 | -------
19 |
20 | * Harald Schilly
21 | * William Stein
22 | * Theron Hitchman (SageBeginnerTutorial)
23 | * Gustav Delius
24 | * Hal Snyder
25 |
26 | License
27 | -------
28 |
29 | Unless otherwise noted in the respective source file: Apache 2.0.
30 |
--------------------------------------------------------------------------------
/RMarkdown/README.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: "RMarkdown in CoCalc"
3 | bibliography: readme.bib
4 | ---
5 |
6 | ## Introduction
7 |
8 | RMarkdown allows you to write a HTML document, a scientific article, a presentation (interactive website or LaTeX beamer), or even a book by just using [Markdown](https://bookdown.org/yihui/rmarkdown/markdown-syntax.html) syntax and embedded programming code.
9 | The "**R**" in RMarkdown stands for the [R statistical computing](https://www.R-project.org/) language,
10 | but it also supports [Python](https://www.python.org) and many other langauges.
11 |
12 | To make full use of this approach, look at the included example documents,
13 | the [articles](./rticle) and make sure to check out advanced concepts like the "frontmatter" -- which you can see at the top between the triple dashes -- to configure the document.
14 |
15 | For example, you can use a [bibtex file](readme.bib) to collect other documents.
16 | Use it to include a reference in your file like for R (@R-base), SageMath (@sagemath) and CoCalc [@cocalc].
17 |
18 | Of course, you can include formulas like $$f(k) = {n \choose k} p^{k} (1-p)^{n-k}$$ and much more ...
19 |
20 | ## Included documents
21 |
22 | - [Basic.Rmd](basic.Rmd) -- this shows how to produce a simple HTML with some R code and plots.
23 | - [html-document.Rmd](html-document.Rmd) -- shows how to customize an HTML document.
24 | - [python3.Rmd](python3.Rmd) -- showcase how to use Python 3 for code and plots.
25 | - [beamer-demo.Rmd](beamer-demo.Rmd) -- a LaTeX beamer presentation (produces as PDF!)
26 |
27 | ## Learn more
28 |
29 | - [Website](https://rmarkdown.rstudio.com)
30 | - [Tutorial](https://rmarkdown.rstudio.com/lesson-1.html)
31 | - [The Definitive Guide](https://bookdown.org/yihui/rmarkdown/)
32 |
--------------------------------------------------------------------------------
/RMarkdown/basic.Rmd:
--------------------------------------------------------------------------------
1 | # Test
2 |
3 | ```
4 | just code formatted
5 | ```
6 |
7 | and some R code
8 |
9 | ```{r}
10 | xx <- rnorm(2000)
11 | paste("length of xx:", length(xx))
12 | plot(xx)
13 | ```
14 |
15 | **ok** _italic_ and $\tfrac{1}{997} = `r 1/997`$.
16 |
17 |
A 3D plot, displayed via the three.js library. Adding the threejs parameter show(…, threejs=True)
is no longer necessary.
Evaluate all cells via pressing the Shift
+Return
keys or the small “play” button in the menu.
Error: %s
' % msg 4 | 5 | @interact 6 | def interactive_2d_plotter(expression=input_box('sin(x)', 'Expression', str), x_range=range_slider(-10,10,1,(0,10), label='X Range'), square=checkbox(True, 'Square'), axes=checkbox(True, 'Show Axes')): 7 | if expression: 8 | try: 9 | expression = SR(expression) # turn string into a Sage expression 10 | except TypeError: 11 | print error_msg('This is not an expression.') 12 | return 13 | try: 14 | xmin, xmax = x_range 15 | if square or not axes: 16 | print "var('%s')\nplot(%s).show(%s%s%s)" % (expression.variables()[0], repr(expression), 'aspect_ratio=1' if square else '', ', ' if square and not axes else '', 'axes=False' if not axes else '') 17 | if square: 18 | plot(expression, xmin, xmax).show(aspect_ratio=1, axes=axes) 19 | else: 20 | plot(expression, xmin, xmax).show(axes=axes) 21 | else: 22 | print "var('%s')\nplot(%s)" % (expression.variables()[0], repr(expression)) 23 | plot(expression, xmin, xmax).show(axes=axes) 24 | except ValueError: 25 | print error_msg('This expression has more than one variable.') 26 | return 27 | except TypeError: 28 | print error_msg("This expression contains an unknown function.") 29 | return 30 | ︡89516b34-686a-48a6-9454-e1c81b214719︡{"interact":{"style":"None","flicker":false,"layout":[[["expression",12,null]],[["x_range",12,null]],[["square",12,null]],[["axes",12,null]],[["",12,null]]],"id":"85092596-6dd6-4f5c-8f79-b2323d437fc7","controls":[{"control_type":"input-box","default":"sin(x)","label":"Expression","nrows":1,"width":null,"readonly":false,"submit_button":null,"var":"expression","type":"$\\chi$ | Conductor | ' + \ 8 | ''.join('$B_{%s,\chi}$ | '%k for k in [1..n]) + '$%s$ | '%latex(eps.bernoulli(k)) for k in [1..n]]) 11 | s += '
%s | %s | %s
Interactive Elements
\n"}︡ 5 | ︠23f68532-7cac-4716-b716-773db178c3f3︠ 6 | u, x = var('u x') 7 | @interact 8 | def diff_interact(n = slider(range(1,10), default = 3)): 9 | ex = sin(2*x^2) * x 10 | show(latex(ex)) 11 | show(latex(ex.diff(n))) 12 | 13 | ︡92019d97-e523-41af-b43d-8d18f762ec92︡{"interact":{"style":"None","flicker":false,"layout":[[["n",12,null]],[["",12,null]]],"id":"6925e8eb-5cda-4818-a127-04765bc4ca89","controls":[{"control_type":"slider","default":2,"var":"n","width":null,"vals":["1","2","3","4","5","6","7","8","9"],"animate":true,"label":"n","display_value":true}]}}︡ 14 | ︠fa68aa2d-b93f-4131-aa57-a6241d2b1756︠ 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /sage/pi.sagews: -------------------------------------------------------------------------------- 1 | ︠b5eb3b78-dd91-4d03-9235-b33cf1924ec3i︠ 2 | %md 3 | # Different Approximations of $\pi$ 4 | ︡ae47d4fa-f622-49d3-b9e7-ca96dde9c507︡{"html":"Warning: If your browser uses canvas instead of webgl, this will be painfully slow. With webgl, it is very fast\nafter the model loads.
\n"}︡ 8 | ︠73e5841f-fa48-4ae3-aa41-310668ffb884a︠ 9 | %auto 10 | # Yoda! -- over 53,756 triangles. 11 | from scipy import io 12 | x = io.loadmat('yodapose.mat') 13 | from sage.plot.plot3d.index_face_set import IndexFaceSet 14 | V = x['V']; F3=x['F3']-1; F4=x['F4']-1 15 | Y = IndexFaceSet(F3,V,color='green') + IndexFaceSet(F4,V,color='green') 16 | Y = Y.rotateZ(-1); Y = Y.rotateX(-1) 17 | show(Y, frame=False) 18 | ︡fd3e1f76-4517-4d87-94cf-0fb6c95ddfa7︡{"auto":true}︡{"html":""}︡{"obj":"{\"foreground\": null, \"camera_distance\": 28.513779200054678, \"height\": null, \"width\": null, \"renderer\": null, \"background\": null}","javascript":{"coffeescript":false,"code":"$('#848dc08b-bb7b-4b77-a904-96c457ecdf67').salvus_threejs(obj)"},"once":false}︡ 19 | ︠5aaaee4f-595a-4775-99a3-d4dce36d5ae8︠ 20 | # 53756 vertices! 21 | len(x['V']) 22 | ︡8a1b1984-df55-4347-b733-598c69faf463︡{"stdout":"53756\n"}︡ 23 | ︠d6248cd2-8768-450d-a311-041d22fa372e︠ 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /sage/yodapose.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagemathinc/cocalc-example-files/ae6843467aeaadef9b1098816adf546a86b51c28/sage/yodapose.mat -------------------------------------------------------------------------------- /sagews-jupyter/r-completion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagemathinc/cocalc-example-files/ae6843467aeaadef9b1098816adf546a86b51c28/sagews-jupyter/r-completion.png -------------------------------------------------------------------------------- /sagews-jupyter/sage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagemathinc/cocalc-example-files/ae6843467aeaadef9b1098816adf546a86b51c28/sagews-jupyter/sage.png -------------------------------------------------------------------------------- /sagews-jupyter/simpleLoop.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagemathinc/cocalc-example-files/ae6843467aeaadef9b1098816adf546a86b51c28/sagews-jupyter/simpleLoop.wav -------------------------------------------------------------------------------- /sympy/sympy-code.sagews: -------------------------------------------------------------------------------- 1 | ︠191922d8-6385-4a48-a8a0-df9f7dcd9386i︠ 2 | %md 3 | Sympy Code Generating Test 4 | -------------------------- 5 | 6 | * [Codegen](http://docs.sympy.org/dev/modules/utilities/codegen.html) 7 | * [Autowrap](http://docs.sympy.org/dev/modules/utilities/autowrap.html) 8 | ︡12577e2c-c3d2-40a4-8c4c-e3d43188e02b︡{"html":"Cells are evaluated in Sage, hence there are a few differences.
\n\nr
, like 42r
.^
symbol automatically expands to **
.%(content)s
32 | 33 | 34 | 35 | """ 36 | 37 | 38 | @app.route(base_url + '/', strict_slashes=False) 39 | def info(): 40 | content = """SMC Webservice running
41 |Routes:
42 | 43 |Try something like %(base_url)s/get?something=foo
""" % { 56 | 'base_url': base_url 57 | } 58 | if request.method == 'GET': 59 | something = request.args.get("something", "") 60 | if len(something) > 0: 61 | content = "Got " + something 62 | return html_template % {'title': 'Info', 'content': content} 63 | 64 | 65 | @app.route(base_url + '/header', methods=['GET']) 66 | def get_header(): 67 | 68 | header = '' 69 | 70 | for k, v in request.headers.iteritems(): 71 | header += '{} = {}\n'.format(k, v) 72 | 73 | content = ''' 74 |76 | {header} 77 |78 | '''.format(header=header) 79 | 80 | return content 81 | 82 | 83 | if __name__ == "__main__": 84 | try: 85 | info = json.load( 86 | open(os.path.join(os.environ['HOME'], ".smc", "info.json"), 'r')) 87 | print("Try to open https://cocalc.com" + base_url + '/') 88 | app.run(host='0.0.0.0', port=port) 89 | import sys 90 | sys.exit(0) 91 | except Exception as e: 92 | print "... failed, try another port (change the port= line in the script) \n%s" % e 93 | -------------------------------------------------------------------------------- /webservice/run.term: -------------------------------------------------------------------------------- 1 | 41e9336f-ca0e-457a-a0cc-9b4e8841c6be --------------------------------------------------------------------------------