CoCalc Shared Files2017-02-08-172629.sagews
Views : 6
%var x y z
g = golden_ratio; r = 4.77
p = 2 - (cos(x + g*y) + cos(x - g*y) + cos(y + g*z) +
cos(y - g*z) + cos(z - g*x) + cos(z + g*x))
show(implicit_plot3d(p, (x, -r, r), (y, -r, r), (z, -r, r),
plot_points=30, color='orange', mesh=1, opacity=.7), spin=1)

3D rendering not yet implemented
time??

   File: /projects/sage/sage-7.5/local/lib/python2.7/site-packages/smc_sagews/sage_salvus.py
Source:
class Time:
"""
Time execution of code exactly once in Salvus by:

- putting %time at the top of a cell to time execution of the entire cell
- put %time at the beginning of line to time execution of just that line
- write time('some code') to executation of the contents of the string.

If you want to time repeated execution of code for benchmarking purposes, use
"""
def __init__(self, start=False):
if start:
from sage.all import walltime, cputime
self._start_walltime = walltime()
self._start_cputime = cputime()

def before(self, code):
return Time(start=True)

def after(self, code):
from sage.all import walltime, cputime
print("CPU time: %.2f s, Wall time: %.2f s" % (cputime(self._start_cputime), walltime(self._start_walltime)))
self._start_cputime = self._start_walltime = None

def __call__(self, code):
from sage.all import walltime, cputime
not_as_decorator = self._start_cputime is None
if not_as_decorator:
self.before(code)
salvus.execute(code)
if not_as_decorator:
self.after(code)




numerical_integral(1 + x + x^2, 0, 3)[0]  # [1] gives error bound

16.500000000000004

v = [(0,0,0)]
for i in range(1000):
v.append([a+random()-.5 for a in v[-1]])
line3d(v, color='red', thickness=3, spin=3)

3D rendering not yet implemented
%time
stats.TimeSeries(1000000).randomize('normal').sums().plot()


CPU time: 0.34 s, Wall time: 0.35 s
@interact
def g(n=[1..10]):
print n^3

def f(n):
return factor(n+2)

f(10)

2^2 * 3
for i in range(10):
print i
sleep(1)

0 1 2 3 4 5 6 7 8 9
next_prime(2017)

2027
%var x, y
plot3d(x^3 + y^3, (x,0,2), (y,0,2))

3D rendering not yet implemented
g = graphs.RandomGNM(15, 20)  # 15 vertices and 20 edges
show(g)
g.incidence_matrix()

d3-based renderer not yet implemented
[1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0] [0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0] [0 0 0 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0] [0 0 0 0 0 0 0 1 0 0 0 0 1 1 0 1 1 0 0 0] [0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1] [0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 1 1 0] [0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1]
# what is next year like?
factor(2018)

2 * 1009
Example $x^3$

# Example $x^3$

2 + 3

5
stats.TimeSeries(1000).randomize('normal').sums().plot()

points = [(2,0,0), (0,2,0), (0,0,2), (-1,0,0), (0,-1,0), (0,0,-1)]
show(LatticePolytope(points).plot3d(), spin=5)

3D rendering not yet implemented

g

Graph on 15 vertices
show(g)

d3-based renderer not yet implemented