| Download
a simuw scratch worksheet
Project: Shared Project -- SIMUW 2019
Path: demo notebook.ipynb
Views: 385License: APACHE
Kernel: SageMath (stable)
In [8]:
Icosahedron
In [53]:
In [50]:
In [2]:
In [39]:
In [0]:
Icosahedron
In [4]:
In [11]:
Show a colored cube
In [0]:
In [1]:
2^2 * 5 * 101
Show a colored cube
In [0]:
Torus
In [1]:
In [2]:
Symbolic expressions are also Python objects. This means, there are ways to inspect and take them apart.
In this example here, we start with an equation and "zoom in" to a small part of it.
Tipp: Combine this technique with substitutions to build new expressions out of existing ones.
Transitions and a plot of a Finite State Machine
In [40]:
Transition from 0 to 0: 0|-
Transition from 0 to 1: 1|-
Transition from 0 to 0: 2|-
Transition from 1 to 2: 2|-
Transition from 2 to 0: 0|-
Show a colored cube
In [0]:
SageMath's preparser makes it easy to define functions.
In [15]:
In [6]:
In [39]:
In [12]:
In [0]:
In [0]:
In [20]:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-20-5b4a735ee13e> in <module>()
----> 1 G = Cylinder(Integer(1), RealNumber('.5')) + Cylinder(RealNumber('.25'), Integer(3)).translate(Integer(0), Integer(0), -Integer(3))
NameError: name 'Cylinder' is not defined
In [19]:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-19-fc0dca25130a> in <module>()
----> 1 sum(Cone(RealNumber('.1'), sin(n)).translate(n, sin(n), Integer(0)) for n in (ellipsis_range(Integer(0),Ellipsis,Integer(10), step=RealNumber('.1'))))
/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/sage/misc/functional.pyc in symbolic_sum(expression, *args, **kwds)
575 return expression.sum(*args, **kwds)
576 elif len(args) <= 1:
--> 577 return sum(expression, *args)
578 else:
579 from sage.symbolic.ring import SR
<ipython-input-19-fc0dca25130a> in <genexpr>((n,))
----> 1 sum(Cone(RealNumber('.1'), sin(n)).translate(n, sin(n), Integer(0)) for n in (ellipsis_range(Integer(0),Ellipsis,Integer(10), step=RealNumber('.1'))))
/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/sage/geometry/cone.pyc in Cone(rays, lattice, check, normalize)
427 # Cone from rays
428 if check or normalize:
--> 429 rays = normalize_rays(rays, lattice)
430 if lattice is None:
431 if rays:
/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/sage/geometry/cone.pyc in normalize_rays(rays, lattice)
643 raise TypeError(
644 "rays must be given as a list or a compatible structure!"
--> 645 "\nGot: %s" % rays)
646 if rays:
647 if lattice is None:
TypeError: rays must be given as a list or a compatible structure!
Got: 0.100000000000000
In [18]:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-18-be3c25c908c1> in <module>()
----> 1 sum(Cone(RealNumber('.1'), sin(n), color='yellow').translate(n, sin(n), Integer(0)) for n in (ellipsis_range(Integer(0),Ellipsis,Integer(10), step=RealNumber('.1'))))
/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/sage/misc/functional.pyc in symbolic_sum(expression, *args, **kwds)
575 return expression.sum(*args, **kwds)
576 elif len(args) <= 1:
--> 577 return sum(expression, *args)
578 else:
579 from sage.symbolic.ring import SR
<ipython-input-18-be3c25c908c1> in <genexpr>((n,))
----> 1 sum(Cone(RealNumber('.1'), sin(n), color='yellow').translate(n, sin(n), Integer(0)) for n in (ellipsis_range(Integer(0),Ellipsis,Integer(10), step=RealNumber('.1'))))
TypeError: Cone() got an unexpected keyword argument 'color'
In [0]:
In [0]:
Icosahedron
In [0]:
In [0]:
SageMath's preparser makes it easy to define functions.
In [47]:
In [0]:
plot(sin(x)^(x^3),(x,-5,5))
In [0]:
In [12]:
3
In [3]:
In [23]:
In [0]:
In [0]:
In [26]:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-26-d1d15f9d8156> in <module>()
----> 1 plot()
/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/sage/misc/decorators.pyc in wrapper(*args, **kwds)
490 options['__original_opts'] = kwds
491 options.update(kwds)
--> 492 return func(*args, **options)
493
494 #Add the options specified by @options to the signature of the wrapped
TypeError: plot() takes at least 1 argument (0 given)
In [0]:
3D plot of .
In [3]:
Show a colored cube
In [14]:
In [40]:
In [34]:
In [0]:
In [0]:
In [0]:
Torus
In [13]:
In [0]: