Skip to content

Latest commit

 

History

History
137 lines (109 loc) · 3.09 KB

example.org

File metadata and controls

137 lines (109 loc) · 3.09 KB

Examples of code blocks

Versions

(princ "Emacs: ")
(princ emacs-version)
(princ "\n")
(princ "Org: ")
(princ (org-version))
Emacs: 26.0.50
Org: 9.0.5
print version()
SageMath version 8.0.beta2, Release Date: 2017-04-12

Basic math

factor(factorial(10))
2^8 * 3^4 * 5^2 * 7

Graphs

P = plot(sin(x), (0, 2*pi), figsize=[5, 4]); P

images/sin.png

This example is from the document of the method plot of a matrix object.

m = random_matrix(RDF, 50)
m.plot(figsize=5)

images/mat.png

This example is from the document of the function implicit_plot3d.

var('x,y,z')
T = RDF(golden_ratio)
p = 2 - (cos(x + T*y) + cos(x - T*y) + cos(y + T*z) + cos(y - T*z) + cos(z - T*x) + cos(z + T*x))
r = 4.77
implicit_plot3d(p, (x, -r, r), (y, -r, r), (z, -r, r), plot_points=40).show(viewer='tachyon', figsize=5)

images/implicit_plot3d_example.png

Tables

[(a, factor(2^a + 1)) for a in range(5)]
02
13
25
33^2
417
colnames = ("a", "Smallest prime greater than 2^a")
[colnames] + [(a, next_prime(2^a)) for a in range(50, 55)]
aSmallest prime greater than 2^a
501125899906842679
512251799813685269
524503599627370517
539007199254740997
5418014398509482143

You can also pass the header argument :colnames (an elisp) list to specify the column names.

[(a, next_prime(2^a)) for a in range(100, 105)]
aSmallest prime greater than 2^a
1001267650600228229401496703205653
1012535301200456458802993406410833
1025070602400912917605986812821771
10310141204801825835211973625643089
10420282409603651670423947251286127

Elliptic curve

E = EllipticCurve(u'389a'); E
Elliptic Curve defined by y^2 + y = x^3 + x^2 - 2*x over Rational Field
print "Rank", E.rank()
E.integral_points()
Rank 2

[(-2 : 0 : 1),
 (-1 : 1 : 1),
 (0 : 0 : 1),
 (1 : 0 : 1),
 (3 : 5 : 1),
 (4 : 8 : 1),
 (6 : 15 : 1),
 (39 : 246 : 1),
 (133 : 1539 : 1),
 (188 : 2584 : 1)]
E.plot(figsize=5)

images/e389a.png