repo.or.cz
/
sympyx.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Show how to use functions.
[sympyx.git]
/
q.py
blob
901ff6cfec102d03f61408bb99ca4752bd0f1a50
1
#!/usr/bin/env python
2
from
timeit
import
default_timer
as
clock
3
from
sympy
import
*
4
5
6
class
sin
(
Basic
):
7
8
def
__new__
(
cls
,
arg
):
9
if
arg
==
0
:
10
return
Integer
(
0
)
11
else
:
12
obj
=
Basic
.__
new
__
(
cls
, (
arg
,))
13
return
obj
14
15
def
__repr__
(
self
):
16
return
"sin(
%s
)"
%
self
.
args
[
0
]
17
18
def
expand
(
self
):
19
print
"expand called"
20
return
self
21
22
23
x
=
Symbol
(
"x"
)
24
print
((
sin
(
1
)+
sin
(
0
)+
x
)**
2
).
expand
()